Reputation: 2745
I am finding a way to implement a log mechanism that several processes write their behaviors (mainly for error and execution sequence of processes) to it by C with Linux?
Just open a file that shared for multi-processes and let processes fprintf() to it? Any smart way to implement an option/mechanism that controls the level of log such as error/detail/high or something like it?
It would be better if you could refer me to a light opensource for this?
Thanks.
Upvotes: 3
Views: 554
Reputation: 32831
In other languages, log4c is very popular (log4j, log4net). It has a lot of functionality just baked in, and since it is so common, other developers who work on your code will be familiar with it.
Upvotes: 2
Reputation: 15347
Using fprintf is ok, however I am not sure if fprintf is threadsafe, if not use a lock mechanism to block the fprintf call for multiple simultaneous accesses.
Upvotes: 1