libqi-api  2.0.6.8
Namespaces | Defines | Typedefs | Enumerations | Functions | Variables
/home/opennao/work/master/sdk/libqi/qi/log.hpp File Reference

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

namespace  qi
 

qi general namespace


namespace  qi::log
 

Log functions with different levels of verbosity.


namespace  qi::log::detail

Defines

#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.
#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.
#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.
#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.
#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.
#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.
#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).

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)
void qi::log::destroy ()
 Stop and flush the logging system.
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.
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.
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.
CategoryType qi::log::addCategory (const std::string &name)
 Add/get a category.
void qi::log::enableCategory (const std::string &cat, SubscriberId sub=0)
 Set.
void qi::log::disableCategory (const std::string &cat, SubscriberId sub=0)
 Set.
void qi::log::setCategory (const std::string &cat, qi::LogLevel level, SubscriberId sub=0)
 Set per-subscriber.
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.
int qi::log::context ()
 Get log context.
void qi::log::setColor (LogColor color)
LogColor qi::log::color ()
void qi::log::setSynchronousLog (bool sync)
 Enables or disables synchronous logs.
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.
void qi::log::flush ()
 Flush asynchronous logs.
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

Detailed Description

Convenient log macro.

Definition in file log.hpp.


Define Documentation

#define qiLogCategory (   Cat)
Value:

Definition at line 28 of file log.hpp.

#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.
 * 
Examples:
log_example.cpp.

Definition at line 38 of file log.hpp.

#define qiLogDebugF (   Msg,
  ... 
)    _QI_LOG_MESSAGE(LogLevel_Debug, _QI_LOG_FORMAT(Msg, __VA_ARGS__))

Definition at line 39 of file log.hpp.

#define qiLogError (   ...)    _QI_LOG_MESSAGE_STREAM(LogLevel_Error, Error, __VA_ARGS__)

Log in error mode.

Examples:
log_example.cpp.

Definition at line 70 of file log.hpp.

#define qiLogErrorF (   Msg,
  ... 
)    _QI_LOG_MESSAGE(LogLevel_Error, _QI_LOG_FORMAT(Msg, __VA_ARGS__))

Definition at line 71 of file log.hpp.

#define qiLogFatal (   ...)    _QI_LOG_MESSAGE_STREAM(LogLevel_Fatal, Fatal, __VA_ARGS__)

Log in fatal mode.

Examples:
log_example.cpp.

Definition at line 78 of file log.hpp.

#define qiLogFatalF (   Msg,
  ... 
)    _QI_LOG_MESSAGE(LogLevel_Fatal, _QI_LOG_FORMAT(Msg, __VA_ARGS__))

Definition at line 79 of file log.hpp.

#define qiLogInfo (   ...)    _QI_LOG_MESSAGE_STREAM(LogLevel_Info, Info, __VA_ARGS__)

Log in info mode.

Examples:
log_example.cpp.

Definition at line 54 of file log.hpp.

#define qiLogInfoF (   Msg,
  ... 
)    _QI_LOG_MESSAGE(LogLevel_Info, _QI_LOG_FORMAT(Msg, __VA_ARGS__))

Definition at line 55 of file log.hpp.

#define qiLogVerbose (   ...)    _QI_LOG_MESSAGE_STREAM(LogLevel_Verbose, Verbose, __VA_ARGS__)

Log in verbose mode. This level is not shown by default.

Examples:
log_example.cpp.

Definition at line 46 of file log.hpp.

#define qiLogVerboseF (   Msg,
  ... 
)    _QI_LOG_MESSAGE(LogLevel_Verbose, _QI_LOG_FORMAT(Msg, __VA_ARGS__))

Definition at line 47 of file log.hpp.

#define qiLogWarning (   ...)    _QI_LOG_MESSAGE_STREAM(LogLevel_Warning, Warning, __VA_ARGS__)

Log in warning mode.

Examples:
log_example.cpp.

Definition at line 62 of file log.hpp.

#define qiLogWarningF (   Msg,
  ... 
)    _QI_LOG_MESSAGE(LogLevel_Warning, _QI_LOG_FORMAT(Msg, __VA_ARGS__))

Definition at line 63 of file log.hpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines