Logger
[Tools Library]

Collaboration diagram for Logger:

Located in stechec/tools/logger directory.

This is a facility to log debug message, with customizable verbosity level. More...

Classes

class  Log
 Application logger. More...
#define MODULE_NAME   "unset"
#define MODULE_COLOR   ""
#define C_NONE   ""
#define C_RED   ""
#define C_GREEN   ""
#define C_BROWN   ""
#define C_BLUE   ""
#define C_PURPLE   ""
#define C_CYAN   ""
#define C_GRAY   ""
#define C_BRED   ""
#define C_BGREEN   ""
#define C_YELLOW   ""
#define C_BBLUE   ""
#define C_BPURPLE   ""
#define C_BCYAN   ""
#define LOG(Level, Msg)
#define ERR(Msg...)   LOG(0, String::compose(Msg))
#define WARN(Msg...)   LOG(1, String::compose(Msg))
#define LOG1(Msg...)   LOG(2, String::compose(Msg))
#define LOG2(Msg...)   LOG(3, String::compose(Msg))
#define LOG3(Msg...)   LOG(4, String::compose(Msg))
#define LOG4(Msg...)   LOG(5, String::compose(Msg))
#define LOG5(Msg...)   LOG(6, String::compose(Msg))
#define LOG6(Msg...)   LOG(7, String::compose(Msg))


Detailed Description

Located in stechec/tools/logger directory.

This is a facility to log debug message, with customizable verbosity level.

This module could be used to log debug and error message into a c++ iostream (usually std::cerr). This is still experimental, and could be changed in the futur. It is designed to be thread-safe, and could log each thread in a separate ostream.

Currently, it could log only into std::cerr.

To use it, define the following macro to your compilator:

 -DMODULE_NAME=\"server\"  // Name of your module (eg: server).
 -DMODULE_COLOR=C_GREEN    // Color to use.

Then, somewhere in your code, keep a Log object per thread. If you don't do this, it will happily segfault. (hint: put it at the beginning of your main() and thread starting functions).

 Log log(3);         // Verbose level to 3.
 log.setPrintLoc();

Now, you are ready to use it ! Only thinks that LOG1 or other macros will be replaced by 'stdcout <<'

 int foo() {
   LOG1("hello " << 42 << " world!");
   while (true) ;
   ERR("Your computer stinks.");
 }

The module name will be printed into bracket before each line. Beware, the the printed module name will reflect which compilation unit possess it, and may not reflect the source directory module. This is only true for LOG in headers.


Generated on Sat Jun 23 16:08:46 2007 for Stechec/TBT by  doxygen 1.4.7