23 # include <boost/format.hpp>
24 # include <boost/function/function_fwd.hpp>
45 #define qiLogCategory(Cat) \
46 static ::qi::log::CategoryType _QI_LOG_CATEGORY_GET() QI_ATTR_UNUSED = \
47 ::qi::log::addCategory(Cat)
64 #if defined(NO_QI_DEBUG) || defined(NDEBUG)
65 # define qiLogDebug(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
66 # define qiLogDebugF(Msg, ...)
68 # define qiLogDebug(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Debug, Debug , __VA_ARGS__)
69 # define qiLogDebugF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Debug, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
75 #if defined(NO_QI_VERBOSE)
76 # define qiLogVerbose(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
77 # define qiLogVerboseF(Msg, ...)
79 # define qiLogVerbose(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Verbose, Verbose, __VA_ARGS__)
80 # define qiLogVerboseF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Verbose, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
86 #if defined(NO_QI_INFO)
87 # define qiLogInfo(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
88 # define qiLogInfoF(Msg, ...)
90 # define qiLogInfo(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Info, Info, __VA_ARGS__)
91 # define qiLogInfoF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Info, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
97 #if defined(NO_QI_WARNING)
98 # define qiLogWarning(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
99 # define qiLogWarningF(Msg, ...)
101 # define qiLogWarning(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Warning, Warning, __VA_ARGS__)
102 # define qiLogWarningF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Warning, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
108 #if defined(NO_QI_ERROR)
109 # define qiLogError(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
110 # define qiLogErrorF(Msg, ...)
112 # define qiLogError(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Error, Error, __VA_ARGS__)
113 # define qiLogErrorF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Error, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
119 #if defined(NO_QI_FATAL)
120 # define qiLogFatal(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
121 # define qiLogFatalF(Msg, ...)
123 # define qiLogFatal(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Fatal, Fatal, __VA_ARGS__)
124 # define qiLogFatalF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Fatal, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
217 const qi::os::timeval,
227 using
Handler = boost::function8<
void,
229 const qi::
Clock::time_point,
245 bool synchronous = true);
275 const
char* category,
277 const
char* file = "",
278 const
char* fct = "",
286 const std::
string& msg,
287 const
char* file = "",
288 const
char* fct = "",
373 QI_API bool isVisible(const std::
string& category, qi::LogLevel level);
473 qi::LogLevel defaultLevel = LogLevel_Info);
485 qi::LogLevel defaultLevel = LogLevel_Info);
507 #include <qi/detail/warn_push_ignore_deprecated.hpp>
550 #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 for this process' logs.
Print an end line between contexts and logs.
void setContext(int ctx)
Set log context verbosity.
void setVerbosity(SubscriberId sub, const qi::log::LogLevel lv)
CategoryType addCategory(const std::string &name)
Add/get a category.
LogLevel
Log level verbosity.
The SystemClock class represents the system-wide real time wall clock. It may not be monotonic: on mo...
qi::LogLevel logLevel(SubscriberId sub=0)
Get log verbosity.
SubscriberId addLogHandler(const std::string &name, qi::log::logFuncHandler fct, qi::LogLevel defaultLevel=LogLevel_Info)
Add a log handler.
unsigned int SubscriberId
Subscriber Identifier.
void disableCategory(const std::string &cat, SubscriberId sub=0)
Set category to silent log level. Globbing is supported.
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.
#define QI_API_DEPRECATED_MSG(msg__)
Compiler flags to mark a function as deprecated. It will generate a compiler warning.
bool isVisible(CategoryType category, qi::LogLevel level)
Check if the given combination of category and level is enable.
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 removeHandler(const std::string &name)
Remove a log handler.
Show qi::SystemClock dates.
LogColor color()
Get log color.
int LogContext
Logs context attribute value.
The Clock class represents a system-wide clock, best suitable for timestamping events. Typically monotonic and unaffected by the system clock adjustment, altough this is not guaranteed.
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)
void setCategory(SubscriberId sub, const std::string &cat, qi::log::LogLevel level)
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).
int context()
Get log context.
void removeLogHandler(const std::string &name)
Remove a log handler.