This code is under BSD license.
I wanted to have a minimalistic debug logging in one of my projects and I wanted to implement this myself because I didn't want to use log4c or similar libraries and mosty just because-I-can...
main() shows how to initialize and start logging (either to a file or syslog). Currently support for remote syslog is not implemented.
func1() shows how to write logging inside yor code, these macros only show the message when the corresponding logging level is active.
func2() shows how to activate and deactivate the different logging levels (as defined in the logger.h)
func3() shows how to print (IP) packet hex dumps.
See the provided Makefile how to compile liblogger.so.1 and the example code. Please note that you must use -rdynamic if you want to have full backtrace support.
You can activate and deactivate logging levels at runtime. In one of my projects, I trap SIGUSR1 and SIGUSR2 signals to activate/deactivate the DEBUG1 and DEBUG2 levels. See test2.c for a working example.