logging facilities (with rt support)
See qi::log Developer Guide for a global overview of the logging system.
More...
Namespaces |
namespace | qi::log |
| Log functions.
|
Macros |
#define | qiLogDebug(...) qi::log::LogStream(qi::log::debug, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__).self() |
#define | qiLogVerbose(...) qi::log::LogStream(qi::log::verbose, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__).self() |
#define | qiLogInfo(...) qi::log::LogStream(qi::log::info, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__).self() |
#define | qiLogWarning(...) qi::log::LogStream(qi::log::warning, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__).self() |
#define | qiLogError(...) qi::log::LogStream(qi::log::error, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__).self() |
#define | qiLogFatal(...) qi::log::LogStream(qi::log::fatal, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__).self() |
Typedefs |
typedef boost::function7< void,
const qi::log::LogLevel, const
qi::os::timeval, const char
*, const char *, const char
*, const char *, int > | qi::log::logFuncHandler |
| Boost delegate to log function (verbosity lv, date of log, category, message, file, function, line). e.g.
|
Functions |
QI_API void | qi::log::init (qi::log::LogLevel verb=qi::log::info, int ctx=0, bool synchronous=true) |
| init the logging system (could be avoided)
|
QI_API void | qi::log::destroy () |
| stop and flush the logging systemshould be called in the main of program using atexit. for example: atexit(qi::log::destroy) This is useful only for asynchronous log.
|
QI_API void | qi::log::log (const qi::log::LogLevel verb, const char *category, const char *msg, const char *file="", const char *fct="", const int line=0) |
| Log functionYou should call qiLog* macro.
|
QI_API const char * | qi::log::logLevelToString (const qi::log::LogLevel verb) |
| Convert log verbosity to char*.
|
QI_API qi::log::LogLevel | qi::log::stringToLogLevel (const char *verb) |
| Convert string to log verbosity.
|
QI_API void | qi::log::setVerbosity (const qi::log::LogLevel lv) |
| Set log verbosity.If you don't want any log use silent mode.
|
QI_API qi::log::LogLevel | qi::log::verbosity () |
| Get log verbosity.
|
QI_API void | qi::log::setContext (int ctx) |
| Set log context.Display log context (line, function, file).
|
QI_API int | qi::log::context () |
| Get log context.
|
QI_API void | qi::log::setSynchronousLog (bool sync) |
| Set synchronous logs.
|
QI_API void | qi::log::addLogHandler (const std::string &name, qi::log::logFuncHandler fct) |
| Add log handler.
|
QI_API void | qi::log::removeLogHandler (const std::string &name) |
| remove log handler.
|
QI_API void | qi::log::flush () |
| flush asynchronous log.
|
Detailed Description
logging facilities (with rt support)
See qi::log Developer Guide for a global overview of the logging system.
How to use log:
#include <cstdlib>
void main() {
qiLogInfo(
"foo.bar",
"%s kick %s" ,
"foo",
"bar");
qiLogInfo(
"foo.bar",
"%s punch %s",
"bar",
"foo");
qiLogInfo(
"tic.tac") <<
"tic, " <<
"tac " << 42 <<
" times";
}
- Warning:
- You should call qi::log::init at the start of your program and register a handler when the program exit to destroy the logger.
Macro Definition Documentation
Log in debug mode. Not compile on release. use as follow:
or
qiLogDebug(
"foo.bar") <<
"my foo is " << 42 <<
"bar";
- Examples:
- log_example.cpp.
Definition at line 33 of file log.hpp.
Log in verbose mode. This mode isn't show by default but always compile.
- Examples:
- log_example.cpp.
Definition at line 41 of file log.hpp.
Enumeration Type Documentation
Log level verbosity.
- Enumerator:
silent |
silent log level
|
fatal |
fatal log level
|
error |
error log level
|
warning |
warning log level
|
info |
info log level
|
verbose |
verbose log level
|
debug |
debug log level
|
Definition at line 119 of file log.hpp.
Function Documentation
Add log handler.
- Parameters:
-
fct | Boost delegate to log handler function. |
name | name of the handler, this is the one used to remove handler (prefer lowcase). |
Get log context.
- Returns:
- true if active, false otherwise.
init the logging system (could be avoided)
- Parameters:
-
verb | Log verbosity |
ctx | Display Context |
synchronous | Synchronous log? |
void qi::log::log |
( |
const qi::log::LogLevel |
verb, |
|
|
const char * |
category, |
|
|
const char * |
msg, |
|
|
const char * |
file = "" , |
|
|
const char * |
fct = "" , |
|
|
const int |
line = 0 |
|
) |
| |
Log functionYou should call qiLog* macro.
- Parameters:
-
verb | { debug = 6, verbose = 5, info = 4, warning = 3, error = 2, fatal = 1, silent = 0 } |
category | Log category. |
msg | Log message. |
file | FILE |
fct | FUNCTION |
line | LINE |
Convert log verbosity to char*.
- Parameters:
-
verb | { debug = 6, verbose=5, info = 4, warning = 3, error = 2, fatal = 1, silent = 0 } |
- Returns:
- one of [SILENT], [FATAL], [ERROR], [WARN ], [INFO ], [VERB ], [DEBUG]
void qi::log::removeLogHandler |
( |
const std::string & |
name | ) |
|
void qi::log::setContext |
( |
int |
ctx | ) |
|
Set log context.Display log context (line, function, file).
- Parameters:
-
ctx | Value to set context.
- 0: none
- 1: categories
- 2: date
- 3: file+line
- 4: date+categories
- 5: date+line+file
- 6: categories+line+file
- 7: all (date+categories+line+file+function)
|
- Examples:
- log_example.cpp.
void qi::log::setSynchronousLog |
( |
bool |
sync | ) |
|
Set synchronous logs.
- Parameters:
-
sync | Value to set context. |
- Examples:
- log_example.cpp.
Set log verbosity.If you don't want any log use silent mode.
- Parameters:
-
lv | maximal verbosity shown |
- Examples:
- log_example.cpp.
Convert string to log verbosity.
- Parameters:
-
verb | debug, verbose, info, warning, error, fatal, silent |
- Returns:
- Log level verbosity
Get log verbosity.
- Returns:
- Maximal verbosity display.