|
libqi-api
2.1.0.18
|
Log functions with different levels of verbosity. More...
Namespaces | |
| namespace | detail |
Classes | |
| class | LogStream |
| Each log macro creates a LogStream object. More... | |
| class | ConsoleLogHandler |
| Print colored logs to the console. More... | |
| class | FileLogHandler |
| Log messages to a file. More... | |
| class | HeadFileLogHandler |
| Log the first length lines to a file. More... | |
| class | TailFileLogHandler |
| Keeps at most 2 MiB of logs. More... | |
Typedefs | |
| typedef detail::Category * | CategoryType |
| typedef unsigned int | SubscriberId |
| typedef boost::function7< void, const qi::LogLevel, const qi::os::timeval, const char *, const char *, const char *, const char *, int > | logFuncHandler |
| Boost delegate to log function (verbosity lv, date of log, category, message, file, function, line). | |
Functions | |
| void | init (qi::LogLevel verb=qi::LogLevel_Info, qi::LogContext context=qi::LogContextAttr_ShortVerbosity|qi::LogContextAttr_Tid|qi::LogContextAttr_Category, bool synchronous=true) |
| init the logging system (could be avoided) | |
| void | destroy () |
| Stop and flush the logging system. | |
| void | log (const qi::LogLevel verb, const char *category, const char *msg, const char *file="", const char *fct="", const int line=0) |
| Log function. You should call qiLog* macros instead. | |
| void | log (const qi::LogLevel verb, CategoryType category, const std::string &msg, const char *file="", const char *fct="", const int line=0) |
| const char * | logLevelToString (const qi::LogLevel verb, bool verbose=true) |
| qi::LogLevel | stringToLogLevel (const char *verb) |
| Convert string to log verbosity. | |
| qi::LogLevel | verbosity (SubscriberId sub=0) |
| std::vector< std::string > | categories () |
| void | setVerbosity (const std::string &rules, SubscriberId sub=0) |
| void | setVerbosity (const qi::LogLevel lv, SubscriberId sub=0) |
| Set log verbosity. | |
| CategoryType | addCategory (const std::string &name) |
| Add/get a category. | |
| void | enableCategory (const std::string &cat, SubscriberId sub=0) |
| Set. | |
| void | disableCategory (const std::string &cat, SubscriberId sub=0) |
| Set. | |
| void | setCategory (const std::string &cat, qi::LogLevel level, SubscriberId sub=0) |
| Set per-subscriber. | |
| bool | isVisible (CategoryType category, qi::LogLevel level) |
| bool | isVisible (const std::string &category, qi::LogLevel level) |
| void | setContext (int ctx) |
| Set log context verbosity. | |
| int | context () |
| Get log context. | |
| void | setColor (LogColor color) |
| LogColor | color () |
| void | setSynchronousLog (bool sync) |
| Enables or disables synchronous logs. | |
| SubscriberId | addLogHandler (const std::string &name, qi::log::logFuncHandler fct, qi::LogLevel defaultLevel=LogLevel_Info) |
| void | removeLogHandler (const std::string &name) |
| Remove a log handler. | |
| void | flush () |
| Flush asynchronous logs. | |
| QI_API_DEPRECATED void | setVerbosity (SubscriberId sub, const qi::log::LogLevel lv) |
| QI_API_DEPRECATED void | setCategory (SubscriberId sub, const std::string &cat, qi::log::LogLevel level) |
Variables | |
| QI_API_DEPRECATED typedef qi::LogLevel | LogLevel |
| QI_API_DEPRECATED typedef unsigned int | Subscriber |
Log functions with different levels of verbosity.
Each log has a category defined by the call to QI_LOG_CATEGORY() found in scope. So you must call QI_LOG_CATEGORY at least once, for instance at the beginning of your source file or function.
Logging is performed by invoking the QiLog* macro families, one per severity level: QiLogError, QiLogWarning, QiLogInfo, QiLogVerbose, and QiLogDebug. Those macros accept either a format syntax inside them, or a stream syntax outside.
*
* .. code-block:: cpp
*
* {
* qiLogCategory(my.category);
* qiLogInfoF("1 + 1 is %s", 1+1);
* qiLogInfo() << "1 + 1 is " << 1+1;
* }
*
* Listeners for all log messages can be added with addLogHandler().
Logs can be filtered per-listener per-category with setCategory() Globbing is supported each time a category name must be specified:
* setCategory("internal.*", silent);
*
* One can also set a filtering rule in QI_LOG_FILTERS environment variable.
* syntax is colon-separated list of rules of the form (+|-)CAT or CAT=level.
* For example, -internal.*:file=verbose
*
* | typedef detail::Category * qi::log::CategoryType |
| typedef unsigned int qi::log::SubscriberId |
| CategoryType qi::log::addCategory | ( | const std::string & | name | ) |
Add/get a category.
| SubscriberId qi::log::addLogHandler | ( | const std::string & | name, |
| qi::log::logFuncHandler | fct, | ||
| qi::LogLevel | defaultLevel = LogLevel_Info |
||
| ) |
| std::vector<std::string> qi::log::categories | ( | ) |
| qi::log::context | ( | ) |
Get log context.
| qi::log::destroy | ( | ) |
Stop and flush the logging system.
* Should be called in the main of program using atexit. For example: * * .. code-block:: cpp * * atexit(qi::log::destroy) * * This is useful only for asynchronous log. *
| void qi::log::disableCategory | ( | const std::string & | cat, |
| SubscriberId | sub = 0 |
||
| ) |
Set.
| cat | to silent log level. Globbing is supported. |
| void qi::log::enableCategory | ( | const std::string & | cat, |
| SubscriberId | sub = 0 |
||
| ) |
Set.
| cat | to current verbosity level. Globbing is supported. |
| qi::log::flush | ( | ) |
Flush asynchronous logs.
| qi::log::init | ( | qi::LogLevel | verb = qi::LogLevel_Info, |
| qi::LogContext | context = qi::LogContextAttr_ShortVerbosity | qi::LogContextAttr_Tid | qi::LogContextAttr_Category, |
||
| bool | synchronous = true |
||
| ) |
init the logging system (could be avoided)
| verb | Log verbosity |
| ctx | Display Context |
| synchronous | Synchronous log? |
| bool qi::log::isVisible | ( | CategoryType | category, |
| qi::LogLevel | level | ||
| ) |
| bool qi::log::isVisible | ( | const std::string & | category, |
| qi::LogLevel | level | ||
| ) |
| qi::log::log | ( | const qi::LogLevel | verb, |
| const char * | category, | ||
| const char * | msg, | ||
| const char * | file = "", |
||
| const char * | fct = "", |
||
| const int | line = 0 |
||
| ) |
Log function. You should call qiLog* macros instead.
| verb | The verbosity of the message. |
| category | Log category (for filtering in the future). |
| msg | Log message. |
| file | Filename from which this function was called (ex: __FILE__). |
| fct | Function name from which this function was called (ex: __FUNCTION__). |
| line | Line from which this function was called (ex: __LINE__). |
| void qi::log::log | ( | const qi::LogLevel | verb, |
| CategoryType | category, | ||
| const std::string & | msg, | ||
| const char * | file = "", |
||
| const char * | fct = "", |
||
| const int | line = 0 |
||
| ) |
| const char* qi::log::logLevelToString | ( | const qi::LogLevel | verb, |
| bool | verbose = true |
||
| ) |
| qi::log::removeLogHandler | ( | const std::string & | name | ) |
| void qi::log::setCategory | ( | const std::string & | cat, |
| qi::LogLevel | level, | ||
| SubscriberId | sub = 0 |
||
| ) |
Set per-subscriber.
| cat | to level |
| level. | Globbing is supported. |
| QI_API_DEPRECATED void qi::log::setCategory | ( | SubscriberId | sub, |
| const std::string & | cat, | ||
| qi::log::LogLevel | level | ||
| ) | [inline] |
| void qi::log::setColor | ( | LogColor | color | ) |
| qi::log::setContext | ( | int | ctx | ) |
Set log context verbosity.
Display log context (line, function, file).
| ctx | Value to set context. |
* Context values possible: * * - 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) *
| qi::log::setSynchronousLog | ( | bool | sync | ) |
Enables or disables synchronous logs.
Set logs synchronicity
When setting to async, this function must be called after main has started.
| sync | Value to set or unset synchronous. |
| void qi::log::setVerbosity | ( | const std::string & | rules, |
| SubscriberId | sub = 0 |
||
| ) |
Parse and execute a set of verbosity rules Colon separated of rules. Each rule can be:
Each category can include a '*' for globbing.
| qi::log::setVerbosity | ( | const qi::LogLevel | lv, |
| SubscriberId | sub = 0 |
||
| ) |
Set log verbosity.
| lv | Default verbosity level shown in the logs. |
If you don't want any log use silent mode.
| QI_API_DEPRECATED void qi::log::setVerbosity | ( | SubscriberId | sub, |
| const qi::log::LogLevel | lv | ||
| ) | [inline] |
| qi::log::stringToLogLevel | ( | const char * | verb | ) |
Convert string to log verbosity.
| verb | debug, verbose, info, warning, error, fatal, silent |
| qi::LogLevel qi::log::verbosity | ( | SubscriberId | sub = 0 | ) |
| QI_API_DEPRECATED typedef unsigned int qi::log::Subscriber |