libqi  1.14
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
Classes | Namespaces | Macros | Typedefs | Enumerations | Functions
log.hpp File Reference

Convenient log macro. More...

#include <map>
#include <string>
#include <iostream>
#include <sstream>
#include <cstdarg>
#include <cstdio>
#include <boost/function/function_fwd.hpp>
#include <qi/config.hpp>
#include <qi/os.hpp>

Go to the source code of this file.

Classes

class  qi::log::LogStream
 Each log macro create a LogStream object. More...

Namespaces

namespace  qi
 qi general namespace
namespace  qi::log
 Log functions.

Macros

#define _LIBQI_QI_LOG_HPP_
#define qiLogDebug(...)   qi::log::LogStream(qi::log::debug, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__).self()
#define qiLogVerbose(...)   qi::log::LogStream(qi::log::verbose, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__).self()
#define qiLogInfo(...)   qi::log::LogStream(qi::log::info, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__).self()
#define qiLogWarning(...)   qi::log::LogStream(qi::log::warning, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__).self()
#define qiLogError(...)   qi::log::LogStream(qi::log::error, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__).self()
#define qiLogFatal(...)   qi::log::LogStream(qi::log::fatal, __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__).self()

Typedefs

typedef boost::function7< void,
const qi::log::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). e.g.

Enumerations

enum  qi::log::LogLevel {
  qi::log::silent = 0, qi::log::fatal, qi::log::error, qi::log::warning,
  qi::log::info, qi::log::verbose, qi::log::debug
}
 Log level verbosity. More...

Functions

QI_API void qi::log::init (qi::log::LogLevel verb=qi::log::info, int ctx=0, bool synchronous=true)
 init the logging system (could be avoided)
QI_API void qi::log::destroy ()
 stop and flush the logging systemshould be called in the main of program using atexit. for example: atexit(qi::log::destroy) This is useful only for asynchronous log.
QI_API void qi::log::log (const qi::log::LogLevel verb, const char *category, const char *msg, const char *file="", const char *fct="", const int line=0)
 Log functionYou should call qiLog* macro.
QI_API const char * qi::log::logLevelToString (const qi::log::LogLevel verb)
 Convert log verbosity to char*.
QI_API qi::log::LogLevel qi::log::stringToLogLevel (const char *verb)
 Convert string to log verbosity.
QI_API void qi::log::setVerbosity (const qi::log::LogLevel lv)
 Set log verbosity.If you don't want any log use silent mode.
QI_API qi::log::LogLevel qi::log::verbosity ()
 Get log verbosity.
QI_API void qi::log::setContext (int ctx)
 Set log context.Display log context (line, function, file).
QI_API int qi::log::context ()
 Get log context.
QI_API void qi::log::setSynchronousLog (bool sync)
 Set synchronous logs.
QI_API void qi::log::addLogHandler (const std::string &name, qi::log::logFuncHandler fct)
 Add log handler.
QI_API void qi::log::removeLogHandler (const std::string &name)
 remove log handler.
QI_API void qi::log::flush ()
 flush asynchronous log.

Detailed Description

Convenient log macro.

Definition in file log.hpp.