2. Few logging concepts.

Log Levels

The application can have several log levels depending on the severity/importance. The following log levels have been inspired by log4j . The following log levels are supported (in increasing order of priority): The Application using liblogger can decide the logs above a certain level it wants to appear. For example, if a source file contains all the above logs and the desired log level is set as Warn, then only logs with equal / higher priority than Warn (i.e the Warn, Error, Fatal) logs will appear, all the below logs will be made null statements during compilation phase without any runtime overhead. The log level can be set

Logging Functions.

The following are the initalization functions: Logging functions ( usage is similar to printf() ) : Log entry / exit from function (same priority as of Trace level log): The above functions are thread safe (unless thread safety is disabled during build).

Variadic Macros

The output of the the log depends on the variadic macro support of the compiler. To include the module name, the filename, the function name and the line number in the generated log the compiler must support variadic macros. The following compilers have this feature:

Example of a log created.

NOTE: An open braces is inserted by the function log entry and a closing braces is added by function exit log, this is to facilitate isolation of logs that appear between function calls and to identify nested function calls. Also this is very helpful when the log is being veiwed in editors (like vim) which support braces matching.

Example (compiler with variadic macro support):
{ TestFuncMin 
[T]:testapp/src_min.cpp:TestFuncMin:11:Trace log Test 1.066000
[D]:testapp/src_min.cpp:TestFuncMin:12:Debug level log
[I]:testapp/src_min.cpp:TestFuncMin:13:Info level log 0
[W]:testapp/src_min.cpp:TestFuncMin:14:Warn level log
[E]:testapp/src_min.cpp:TestFuncMin:15:Error level log
[F]:testapp/src_min.cpp:TestFuncMin:16:Fatal level log
TestFuncMin : 21 }

liblogger © 2007 - SourceForge.net Logo