Today I uploaded
klumpat, a simple logging framework for the C programming language, and especially for dietlibc applications.
The idea is that you have a set of specialized loggers, e.g. for the console, files, syslog or
logging to other loggers, which you create with a specialized function, and then log to them with a unified logging function. Every logger has a loglevel, which specifies the threshold from which loglevel on messages shall be logged. One special feature is the so-called meta logger: it's a logger to dispatch a log message to 0 to n other loggers, e.g. a debug logfile (with loglevel DEBUG), an error logfile (with loglevel ERROR) and a console logger (with loglevel NOTICE). The API itself is trivial, as the following example shows:
klumpat flogger = kl_new_file("file",DEBUG,"testlog.txt");
klumpat clogger = kl_new_console("console",ERROR);
klumpat * logger = kl_new_meta("meta",DEBUG);
kl_add_logger(logger,flogger);
kl_add_logger(logger,clogger);
kl_log(logger,DEBUG,"this is a debug message");
kl_log(logger,NOTICE,"this is a notice");
kl_log(logger,ERROR,"this is an error message");
kl_delete(logger);
Another nice thing is that messages in different loglevels are getting colored differently when being printed to the console. That makes the visual perception of e.g. error messages much easier.
Why the name "klumpat"? Well, "klumpat" means (roughly translated) "crap". It was just a random name that came to my mind when I started implementing the whole thing.