22 #include <boost/format.hpp>
23 #include <boost/function/function_fwd.hpp>
28 # define qiLogCategory(Cat) \
29 static ::qi::log::CategoryType _QI_LOG_CATEGORY_GET() QI_ATTR_UNUSED = \
30 ::qi::log::addCategory(Cat)
34 #if defined(NO_QI_DEBUG) || defined(NDEBUG)
35 # define qiLogDebug(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
36 # define qiLogDebugF(Msg, ...)
38 # define qiLogDebug(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Debug, Debug , __VA_ARGS__)
39 # define qiLogDebugF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Debug, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
42 #if defined(NO_QI_VERBOSE)
43 # define qiLogVerbose(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
44 # define qiLogVerboseF(Msg, ...)
46 # define qiLogVerbose(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Verbose, Verbose, __VA_ARGS__)
47 # define qiLogVerboseF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Verbose, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
50 #if defined(NO_QI_INFO)
51 # define qiLogInfo(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
52 # define qiLogInfoF(Msg, ...)
54 # define qiLogInfo(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Info, Info, __VA_ARGS__)
55 # define qiLogInfoF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Info, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
58 #if defined(NO_QI_WARNING)
59 # define qiLogWarning(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
60 # define qiLogWarningF(Msg, ...)
62 # define qiLogWarning(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Warning, Warning, __VA_ARGS__)
63 # define qiLogWarningF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Warning, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
66 #if defined(NO_QI_ERROR)
67 # define qiLogError(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
68 # define qiLogErrorF(Msg, ...)
70 # define qiLogError(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Error, Error, __VA_ARGS__)
71 # define qiLogErrorF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Error, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
74 #if defined(NO_QI_FATAL)
75 # define qiLogFatal(...) ::qi::log::detail::qiFalse() && false < qi::log::detail::NullStream().self()
76 # define qiLogFatalF(Msg, ...)
78 # define qiLogFatal(...) _QI_LOG_MESSAGE_STREAM(LogLevel_Fatal, Fatal, __VA_ARGS__)
79 # define qiLogFatalF(Msg, ...) _QI_LOG_MESSAGE(LogLevel_Fatal, _QI_LOG_FORMAT(Msg, __VA_ARGS__))
142 typedef boost::function7<void,
153 bool synchronous =
true);
158 const char* category,
160 const char* file =
"",
161 const char* fct =
"",
166 const std::string& msg,
167 const char* file =
"",
168 const char* fct =
"",
246 #endif // _QI_LOG_HPP_
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.
int context()
Get log context.
void removeLogHandler(const std::string &name)
Remove a log handler.
std::vector< std::string > categories()
void setCategory(const std::string &cat, qi::LogLevel level, SubscriberId sub=0)
Set per-subscriber.
CategoryType addCategory(const std::string &name)
Add/get a category.
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 setVerbosity(const std::string &rules, SubscriberId sub=0)
void setSynchronousLog(bool sync)
Enables or disables synchronous logs.
void destroy()
Stop and flush the logging system.
QI_API_DEPRECATED typedef unsigned int Subscriber
bool isVisible(CategoryType category, qi::LogLevel level)
void log(const qi::LogLevel verb, CategoryType category, const std::string &msg, const char *file="", const char *fct="", const int line=0)
detail::Category * CategoryType
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).
unsigned int SubscriberId
const char * logLevelToString(const qi::LogLevel verb, bool verbose=true)
#define QI_API_DEPRECATED
Compiler flags to mark a function as deprecated. It will generate a compiler warning.
SubscriberId addLogHandler(const std::string &name, qi::log::logFuncHandler fct, qi::LogLevel defaultLevel=LogLevel_Info)
void setContext(int ctx)
Set log context verbosity.
qi::LogLevel verbosity(SubscriberId sub=0)
qi::LogLevel stringToLogLevel(const char *verb)
Convert string to log verbosity.
LogLevel
Log level verbosity.
void flush()
Flush asynchronous logs.
void disableCategory(const std::string &cat, SubscriberId sub=0)
Set.
void enableCategory(const std::string &cat, SubscriberId sub=0)
Set.
QI_API_DEPRECATED typedef qi::LogLevel LogLevel
void setColor(LogColor color)