23 # include <boost/format.hpp>
24 # include <boost/function/function_fwd.hpp>
30 # include <boost/exception/exception.hpp>
31 # include <boost/exception/diagnostic_information.hpp>
32 # include <ka/macroregular.hpp>
33 # include <ka/typetraits.hpp>
34 # include <ka/utility.hpp>
53 #define qiLogCategory(Cat) \
54 static ::qi::log::CategoryType _QI_LOG_CATEGORY_GET() QI_ATTR_UNUSED = \
55 ::qi::log::addCategory(Cat)
72 #if defined(NO_QI_DEBUG) || defined(NDEBUG)
73 # define qiLogDebug(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
74 # define qiLogDebugF(Msg, ...) do {} while(0)
76 # define qiLogDebug(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Debug, Debug , __VA_ARGS__)
77 # define qiLogDebugF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Debug, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
83 #if defined(NO_QI_VERBOSE)
84 # define qiLogVerbose(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
85 # define qiLogVerboseF(Msg, ...) do {} while(0)
87 # define qiLogVerbose(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Verbose, Verbose, __VA_ARGS__)
88 # define qiLogVerboseF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Verbose, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
94 #if defined(NO_QI_INFO)
95 # define qiLogInfo(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
96 # define qiLogInfoF(Msg, ...) do {} while(0)
98 # define qiLogInfo(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Info, Info, __VA_ARGS__)
99 # define qiLogInfoF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Info, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
105 #if defined(NO_QI_WARNING)
106 # define qiLogWarning(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
107 # define qiLogWarningF(Msg, ...) do {} while(0)
109 # define qiLogWarning(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Warning, Warning, __VA_ARGS__)
110 # define qiLogWarningF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Warning, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
116 #if defined(NO_QI_ERROR)
117 # define qiLogError(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
118 # define qiLogErrorF(Msg, ...) do {} while(0)
120 # define qiLogError(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Error, Error, __VA_ARGS__)
121 # define qiLogErrorF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Error, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
127 #if defined(NO_QI_FATAL)
128 # define qiLogFatal(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
129 # define qiLogFatalF(Msg, ...) do {} while(0)
131 # define qiLogFatal(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Fatal, Fatal, __VA_ARGS__)
132 # define qiLogFatalF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Fatal, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
225 const qi::os::timeval,
235 using
Handler = boost::function8<
void,
237 const qi::
Clock::time_point,
248 namespace QI_DEFAULT_LOGHANDLER {
321 bool synchronous =
true);
351 const char* category,
353 const char* file =
"",
354 const char* fct =
"",
362 const std::string& msg,
363 const char* file =
"",
364 const char* fct =
"",
635 template<
typename O,
typename S =
char const*>
643 void operator()(const std::exception& e)
const
689 template<
typename O,
typename S>
693 ka::fwd<O>(prefix) };
698 #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...
char const *const debugger
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 operator()(const boost::exception &e) const
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.
#define qiLogError(...)
Log in error mode.
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.
ExceptionLogError< ka::Decay< O >, ka::Decay< S > > exceptionLogError(S &&category, O &&prefix)
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 Creates and registers the default log handler according to QI_DE...
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.