|
CXI
|
Provides unified logging. More...
Public Types | |
| enum | levels { LEVEL_NONE = 0 , LEVEL_ERROR , LEVEL_WARNING , LEVEL_INFO , LEVEL_TRACE , LEVEL_DEBUG , LEVEL_NONE = 0 , LEVEL_ERROR , LEVEL_WARNING , LEVEL_INFO , LEVEL_TRACE , LEVEL_DEBUG } |
| enum | levels { LEVEL_NONE = 0 , LEVEL_ERROR , LEVEL_WARNING , LEVEL_INFO , LEVEL_TRACE , LEVEL_DEBUG , LEVEL_NONE = 0 , LEVEL_ERROR , LEVEL_WARNING , LEVEL_INFO , LEVEL_TRACE , LEVEL_DEBUG } |
Public Member Functions | |
| Log (char *filename=NULL, int level=Log::LEVEL_NONE, int size=0) | |
| Log (const Log &log) | |
| Log (Config &config) | |
| void | init (const char *filename=NULL, int level=Log::LEVEL_NONE, int size=0) |
| void | init (Config &config) |
| void | print (const char *where, const char *format,...) |
| void | print (const char *where, int line, const char *format,...) |
| void | xprint (const char *where, const char *text, const char *data, int len) |
| void | xprint (const char *where, const char *text, const ByteArray &ba) |
Static Public Member Functions | |
| static Log & | getInstance (void) |
Provides unified logging.
This class can be used in the following ways:
In the second case the log file contains log messages written by the application as well as the log messages written by the CXI API.
The following example illustrates the usage of the Log class:
| enum levels |
Log Level
| enum levels |
Log Level
| Log | ( | char * | filename = NULL, |
| int | level = Log::LEVEL_NONE, |
||
| int | size = 0 |
||
| ) |
Default Constructor
Initializes log file according to the given configuration object.
| config | Configuration object. The following key names will be recognized:
|
| void init | ( | const char * | filename = NULL, |
| int | level = Log::LEVEL_NONE, |
||
| int | size = 0 |
||
| ) |
Initializes log file.
| filename | path name of log file to be written. |
| level | log level (see Log::levels) |
| size | maximum size of log file. If the actual log file size extends this limit the log file is renamed to *.bak and a new log file is created. If the log size value is given as '0' the log file may grow without limitation. |
| void init | ( | Config & | config | ) |
Initializes log file according to the given configuration object.
| config | Configuration object. The following key names will be recognized:
|
| void print | ( | const char * | where, |
| const char * | format, | ||
| ... | |||
| ) |
Adds string to log file.
| where | name of function or method, which generates log entry |
| format | format specifier of variable argument list |
| void print | ( | const char * | where, |
| int | line, | ||
| const char * | format, | ||
| ... | |||
| ) |
Adds a string to log file.
| where | name of function or method, which generates log entry |
| line | number in source code |
| format | format specifier of variable argument list |
| void xprint | ( | const char * | where, |
| const char * | text, | ||
| const char * | data, | ||
| int | len | ||
| ) |
Adds binary data to log file. The binary data is converted to hexadecimal notation.
| where | name of function, which generates log entry |
| text | tag (optional) |
| data | pointer to binary data |
| len | length of binary data |
| void xprint | ( | const char * | where, |
| const char * | text, | ||
| const ByteArray & | ba | ||
| ) |
Adds binary data to log file. The binary data is converted to hexadecimal notation.
| where | name of function, which generates log entry |
| text | tag (optional) |
| ba | byte array to be logged |
|
static |
Default log instance used to provide a unique log file for CXIAPI and application.
From your application you can enable logging as follows:
cxi::Log::getInstance().init(<filename>,<level>,<max_size>);