What design pattern might apply to logging? What is normally used in this type of situation? Any good tutorials?
I am writing a client-server application using C89 and gcc 4.4.4. I now need to implement some logging feature that will display log messages on the screen as well as log to a file.
However, I don’t want to display all log messages (warning, error, critical, unrecoverable, debug, etc). Maybe I can set so that it will display just errors and nothing else. For example, the user might not be interested in the debug messages on the screen output.
Some hints/concepts:
Often the idea is to defer the string processing to the background thread so the actual work threads generating the log aren’t wasting time with string manipulation. However, it makes printing variable strings difficult since they tend to go out of scope by the time the background processes them. So in these cases numeric values are preferred. If real time is not as much an issue, you can copy strings through the log interface instead of just passing the pointers and numeric parameter values.
Good luck.