libqi-api
2.1.4.13
|
Convenient log macro. More...
#include <string>
#include <iostream>
#include <sstream>
#include <cstdarg>
#include <cstdio>
#include <boost/format.hpp>
#include <boost/function/function_fwd.hpp>
#include <qi/os.hpp>
#include <qi/details/warn_push_ignore_deprecated.hpp>
#include <qi/details/warn_pop_ignore_deprecated.hpp>
#include <qi/details/log.hxx>
Go to the source code of this file.
Namespaces | |
qi | |
qi general namespace | |
qi::log | |
Log functions with different levels of verbosity. | |
qi::log::detail | |
Macros | |
#define | _QI_LOG_HPP_ |
#define | qiLogCategory(Cat) |
#define | qiLogDebug(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Debug, Debug , __VA_ARGS__) |
Log in debug mode. This level is not shown by default. More... | |
#define | qiLogDebugF(Msg,...) _QI_LOG_MESSAGE(LogLevel_Debug, _QI_LOG_FORMAT(Msg, __VA_ARGS__)) |
#define | qiLogVerbose(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Verbose, Verbose, __VA_ARGS__) |
Log in verbose mode. This level is not shown by default. More... | |
#define | qiLogVerboseF(Msg,...) _QI_LOG_MESSAGE(LogLevel_Verbose, _QI_LOG_FORMAT(Msg, __VA_ARGS__)) |
#define | qiLogInfo(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Info, Info, __VA_ARGS__) |
Log in info mode. More... | |
#define | qiLogInfoF(Msg,...) _QI_LOG_MESSAGE(LogLevel_Info, _QI_LOG_FORMAT(Msg, __VA_ARGS__)) |
#define | qiLogWarning(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Warning, Warning, __VA_ARGS__) |
Log in warning mode. More... | |
#define | qiLogWarningF(Msg,...) _QI_LOG_MESSAGE(LogLevel_Warning, _QI_LOG_FORMAT(Msg, __VA_ARGS__)) |
#define | qiLogError(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Error, Error, __VA_ARGS__) |
Log in error mode. More... | |
#define | qiLogErrorF(Msg,...) _QI_LOG_MESSAGE(LogLevel_Error, _QI_LOG_FORMAT(Msg, __VA_ARGS__)) |
#define | qiLogFatal(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Fatal, Fatal, __VA_ARGS__) |
Log in fatal mode. More... | |
#define | qiLogFatalF(Msg,...) _QI_LOG_MESSAGE(LogLevel_Fatal, _QI_LOG_FORMAT(Msg, __VA_ARGS__)) |
Typedefs | |
typedef int | qi::LogContext |
typedef unsigned int | qi::log::SubscriberId |
typedef boost::function7< void, const qi::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). More... | |
Enumerations | |
enum | qi::LogLevel { qi::LogLevel_Silent = 0, qi::LogLevel_Fatal, qi::LogLevel_Error, qi::LogLevel_Warning, qi::LogLevel_Info, qi::LogLevel_Verbose, qi::LogLevel_Debug } |
Log level verbosity. More... | |
enum | qi::LogColor { qi::LogColor_Never, qi::LogColor_Auto, qi::LogColor_Always } |
enum | qi::LogContextAttr { qi::LogContextAttr_None = 0, qi::LogContextAttr_Verbosity = 1 << 0, qi::LogContextAttr_ShortVerbosity = 1 << 1, qi::LogContextAttr_Date = 1 << 2, qi::LogContextAttr_Tid = 1 << 3, qi::LogContextAttr_Category = 1 << 4, qi::LogContextAttr_File = 1 << 5, qi::LogContextAttr_Function = 1 << 6, qi::LogContextAttr_Return = 1 << 7 } |
Functions | |
void | 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) More... | |
void | qi::log::destroy () |
Stop and flush the logging system. More... | |
void | 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. More... | |
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::LogLevel | qi::log::stringToLogLevel (const char *verb) |
Convert string to log verbosity. More... | |
qi::LogLevel | qi::log::verbosity (SubscriberId sub=0) |
std::vector< std::string > | qi::log::categories () |
void | qi::log::setVerbosity (const std::string &rules, SubscriberId sub=0) |
void | qi::log::setVerbosity (const qi::LogLevel lv, SubscriberId sub=0) |
Set log verbosity. More... | |
CategoryType | qi::log::addCategory (const std::string &name) |
Add/get a category. More... | |
void | qi::log::enableCategory (const std::string &cat, SubscriberId sub=0) |
Set. More... | |
void | qi::log::disableCategory (const std::string &cat, SubscriberId sub=0) |
Set. More... | |
void | qi::log::setCategory (const std::string &cat, qi::LogLevel level, SubscriberId sub=0) |
Set per-subscriber. More... | |
bool | qi::log::isVisible (CategoryType category, qi::LogLevel level) |
bool | qi::log::isVisible (const std::string &category, qi::LogLevel level) |
void | qi::log::setContext (int ctx) |
Set log context verbosity. More... | |
int | qi::log::context () |
Get log context. More... | |
void | qi::log::setColor (LogColor color) |
LogColor | qi::log::color () |
void | qi::log::setSynchronousLog (bool sync) |
Enables or disables synchronous logs. More... | |
SubscriberId | qi::log::addLogHandler (const std::string &name, qi::log::logFuncHandler fct, qi::LogLevel defaultLevel=LogLevel_Info) |
void | qi::log::removeLogHandler (const std::string &name) |
Remove a log handler. More... | |
void | qi::log::flush () |
Flush asynchronous logs. More... | |
QI_API_DEPRECATED void | qi::log::setVerbosity (SubscriberId sub, const qi::log::LogLevel lv) |
QI_API_DEPRECATED void | qi::log::setCategory (SubscriberId sub, const std::string &cat, qi::log::LogLevel level) |
Variables | |
QI_API_DEPRECATED typedef qi::LogLevel | qi::log::LogLevel |
QI_API_DEPRECATED typedef unsigned int | qi::log::Subscriber |
Convenient log macro.
Definition in file log.hpp.
#define qiLogCategory | ( | Cat | ) |
#define qiLogDebug | ( | ... | ) | _QI_LOG_MESSAGE_STREAM(LogLevel_Debug, Debug , __VA_ARGS__) |
Log in debug mode. This level is not shown by default.
* Log in debug mode. Not compiled on release. Use as follow: * * .. code-block:: cpp * * qiLogDebug("foo.bar", "my foo is %d bar", 42); * // or * qiLogDebug("foo.bar") << "my foo is " << 42 << "bar"; * * If you don't want to see any log, use silent log level. *
#define qiLogDebugF | ( | Msg, | |
... | |||
) | _QI_LOG_MESSAGE(LogLevel_Debug, _QI_LOG_FORMAT(Msg, __VA_ARGS__)) |
#define qiLogError | ( | ... | ) | _QI_LOG_MESSAGE_STREAM(LogLevel_Error, Error, __VA_ARGS__) |
#define qiLogErrorF | ( | Msg, | |
... | |||
) | _QI_LOG_MESSAGE(LogLevel_Error, _QI_LOG_FORMAT(Msg, __VA_ARGS__)) |
#define qiLogFatal | ( | ... | ) | _QI_LOG_MESSAGE_STREAM(LogLevel_Fatal, Fatal, __VA_ARGS__) |
#define qiLogFatalF | ( | Msg, | |
... | |||
) | _QI_LOG_MESSAGE(LogLevel_Fatal, _QI_LOG_FORMAT(Msg, __VA_ARGS__)) |
#define qiLogInfo | ( | ... | ) | _QI_LOG_MESSAGE_STREAM(LogLevel_Info, Info, __VA_ARGS__) |
#define qiLogInfoF | ( | Msg, | |
... | |||
) | _QI_LOG_MESSAGE(LogLevel_Info, _QI_LOG_FORMAT(Msg, __VA_ARGS__)) |
#define qiLogVerbose | ( | ... | ) | _QI_LOG_MESSAGE_STREAM(LogLevel_Verbose, Verbose, __VA_ARGS__) |
Log in verbose mode. This level is not shown by default.
#define qiLogVerboseF | ( | Msg, | |
... | |||
) | _QI_LOG_MESSAGE(LogLevel_Verbose, _QI_LOG_FORMAT(Msg, __VA_ARGS__)) |
#define qiLogWarning | ( | ... | ) | _QI_LOG_MESSAGE_STREAM(LogLevel_Warning, Warning, __VA_ARGS__) |
#define qiLogWarningF | ( | Msg, | |
... | |||
) | _QI_LOG_MESSAGE(LogLevel_Warning, _QI_LOG_FORMAT(Msg, __VA_ARGS__)) |