24 # include <boost/format.hpp>
25 # include <boost/function/function_fwd.hpp>
46 #define qiLogCategory(Cat) \
47 static ::qi::log::CategoryType _QI_LOG_CATEGORY_GET() QI_ATTR_UNUSED = \
48 ::qi::log::addCategory(Cat)
65 #if defined(NO_QI_DEBUG) || defined(NDEBUG)
66 # define qiLogDebug(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
67 # define qiLogDebugF(Msg, ...)
69 # define qiLogDebug(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Debug, Debug , __VA_ARGS__)
70 # define qiLogDebugF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Debug, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
76 #if defined(NO_QI_VERBOSE)
77 # define qiLogVerbose(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
78 # define qiLogVerboseF(Msg, ...)
80 # define qiLogVerbose(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Verbose, Verbose, __VA_ARGS__)
81 # define qiLogVerboseF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Verbose, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
87 #if defined(NO_QI_INFO)
88 # define qiLogInfo(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
89 # define qiLogInfoF(Msg, ...)
91 # define qiLogInfo(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Info, Info, __VA_ARGS__)
92 # define qiLogInfoF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Info, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
98 #if defined(NO_QI_WARNING)
99 # define qiLogWarning(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
100 # define qiLogWarningF(Msg, ...)
102 # define qiLogWarning(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Warning, Warning, __VA_ARGS__)
103 # define qiLogWarningF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Warning, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
109 #if defined(NO_QI_ERROR)
110 # define qiLogError(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
111 # define qiLogErrorF(Msg, ...)
113 # define qiLogError(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Error, Error, __VA_ARGS__)
114 # define qiLogErrorF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Error, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
120 #if defined(NO_QI_FATAL)
121 # define qiLogFatal(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
122 # define qiLogFatalF(Msg, ...)
124 # define qiLogFatal(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Fatal, Fatal, __VA_ARGS__)
125 # define qiLogFatalF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Fatal, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
216 typedef boost::function7<void,
228 typedef boost::function8<void,
246 bool synchronous =
true);
276 const char* category,
278 const char* file =
"",
279 const char* fct =
"",
287 const std::string& msg,
288 const char* file =
"",
289 const char* fct =
"",
544 #endif // _QI_LOG_HPP_
void destroy()
Stop and flush the logging system.
std::vector< std::string > categories()
Get the list of all categories.
SubscriberId addHandler(const std::string &name, qi::log::Handler fct, qi::LogLevel defaultLevel=LogLevel_Info)
Add a log handler.
Print an end line between contexts and logs.
void setContext(int ctx)
Set log context verbosity.
int LogContext
Logs context attribute value.
CategoryType addCategory(const std::string &name)
Add/get a category.
LogLevel
Log level verbosity.
QI_API_DEPRECATED void removeLogHandler(const std::string &name)
Remove a log handler.
QI_API_DEPRECATED typedef unsigned int Subscriber
boost::chrono::time_point< Clock > time_point
QI_API_DEPRECATED SubscriberId addLogHandler(const std::string &name, qi::log::logFuncHandler fct, qi::LogLevel defaultLevel=LogLevel_Info)
Add a log handler.
qi::LogLevel logLevel(SubscriberId sub=0)
Get log verbosity.
QI_API_DEPRECATED qi::LogLevel verbosity(SubscriberId sub=0)
boost::function8< void, const qi::LogLevel, const qi::Clock::time_point, const qi::SystemClock::time_point, const char *, const char *, const char *, const char *, int > Handler
Boost delegate to log function (verbosity lv, dates of log, category, message, file, function, line).
void disableCategory(const std::string &cat, SubscriberId sub=0)
Set category to silent log level. Globbing is supported.
QI_API_DEPRECATED typedef qi::LogLevel LogLevel
QI_API_DEPRECATED void setCategory(SubscriberId sub, const std::string &cat, qi::log::LogLevel level)
void setColor(LogColor color)
Set log color.
void addFilter(const std::string &cat, qi::LogLevel level, SubscriberId sub=0)
Set per-subscriber category to level. Globbing is supported.
const char * logLevelToString(const qi::LogLevel verb, bool verbose=true)
Convert log verbosity to a readable string.
void addFilters(const std::string &rules, SubscriberId sub=0)
Parse and execute a set of verbosity rules.
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 setSynchronousLog(bool sync)
Enables or disables synchronous logs.
qi::LogLevel stringToLogLevel(const char *verb)
Convert string to log verbosity.
void log(const qi::LogLevel verb, CategoryType category, const std::string &msg, const char *file="", const char *fct="", const int line=0)
Log function. You should call qiLog* macros instead.
void setLogLevel(const qi::LogLevel lv, SubscriberId sub=0)
Set log Level.
unsigned int SubscriberId
Subscriber Identifier.
detail::Category * CategoryType
Catergory Informations.
struct similar to POSIX timeval
bool isVisible(CategoryType category, qi::LogLevel level)
Check if the given combination of category and level is enable.
void removeHandler(const std::string &name)
Remove a log handler.
Show qi::SystemClock dates.
#define QI_API_DEPRECATED
Compiler flags to mark a function as deprecated. It will generate a compiler warning.
boost::chrono::time_point< SystemClock > time_point
LogColor color()
Get log color.
QI_API_DEPRECATED void setVerbosity(SubscriberId sub, const qi::log::LogLevel lv)
void enableCategory(const std::string &cat, SubscriberId sub=0)
Set category to current verbosity level. Globbing is supported.
LogContextAttr
Logs context attribute.
void flush()
Flush asynchronous logs.
void init(qi::LogLevel verb=qi::LogLevel_Info, qi::LogContext context=qi::LogContextAttr_ShortVerbosity|qi::LogContextAttr_Tid|qi::LogContextAttr_Category, bool synchronous=true)
Initialization of the logging system (could be avoided)
int context()
Get log context.
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).