ZeroErr
载入中...
搜索中...
未找到
zeroerr::LogStream类 参考

LogStream is a class to manage the log messages. 更多...

#include <log.h>

Public 类型

enum  FlushMode { FLUSH_AT_ONCE , FLUSH_WHEN_FULL , FLUSH_MANUALLY }
 
enum  LogMode { ASYNC , SYNC }
 
enum  DirMode { SINGLE_FILE = 0 , DAILY_FILE = 1 , SPLIT_BY_SEVERITY = 1 << 1 , SPLIT_BY_CATEGORY = 1 << 2 }
 

Public 成员函数

 LogStream ()
 
virtual ~LogStream ()
 
template<typename... T>
PushResult push (T &&... args)
 push a log message to the stream
 
template<typename T >
getLog (std::string func, unsigned line, std::string name)
 get a log message from the stream
 
template<typename T >
getLog (std::string func, std::string msg, std::string name)
 get a log message from the stream
 
LogIterator begin (std::string message="", std::string function_name="", int line=-1)
 
LogIterator end ()
 
LogIterator current (std::string message="", std::string function_name="", int line=-1)
 
void flush ()
 
void setFileLogger (std::string name, DirMode mode1=SINGLE_FILE, DirMode mode2=SINGLE_FILE, DirMode mode3=SINGLE_FILE)
 
void setStdoutLogger ()
 
void setStderrLogger ()
 
void setFlushAtOnce ()
 
void setFlushWhenFull ()
 
void setFlushManually ()
 
void setAsyncLog ()
 
void setSyncLog ()
 
FlushMode getFlushMode () const
 
void setFlushMode (FlushMode mode)
 
LogMode getLogMode () const
 
void setLogMode (LogMode mode)
 

静态 Public 成员函数

static LogStreamgetDefault ()
 

Public 属性

bool use_lock_free = true
 

友元

class LogIterator
 

详细描述

LogStream is a class to manage the log messages.

LogStream is a class to manage the log messages. It can be used to create log messages and push them to the logger. A default LogStream is created when the first time you call getDefault() function (or first log happens). You can also adjust the way to flush the messages and how the log messages are written to the log file.

成员枚举类型说明

◆ DirMode

枚举值
SINGLE_FILE 
DAILY_FILE 
SPLIT_BY_SEVERITY 
SPLIT_BY_CATEGORY 

◆ FlushMode

枚举值
FLUSH_AT_ONCE 
FLUSH_WHEN_FULL 
FLUSH_MANUALLY 

◆ LogMode

枚举值
ASYNC 
SYNC 

构造及析构函数说明

◆ LogStream()

zeroerr::LogStream::LogStream ( )

◆ ~LogStream()

zeroerr::LogStream::~LogStream ( )
virtual

成员函数说明

◆ begin()

LogIterator zeroerr::LogStream::begin ( std::string  message = "",
std::string  function_name = "",
int  line = -1 
)
inline

◆ current()

LogIterator zeroerr::LogStream::current ( std::string  message = "",
std::string  function_name = "",
int  line = -1 
)

◆ end()

LogIterator zeroerr::LogStream::end ( )
inline

◆ flush()

void zeroerr::LogStream::flush ( )

◆ getDefault()

LogStream & zeroerr::LogStream::getDefault ( )
static

◆ getFlushMode()

FlushMode zeroerr::LogStream::getFlushMode ( ) const
inline

◆ getLog() [1/2]

template<typename T >
T zeroerr::LogStream::getLog ( std::string  func,
std::string  msg,
std::string  name 
)
inline

get a log message from the stream

模板参数
TThe type of the log message
参数
funcThe function name of the log message
msgThe message of the log message
nameThe name of field you want to get

This function is used to get a log message from the stream and extract the field with the name. The function will return the field with the type T. However, this type must be specified by the caller.

◆ getLog() [2/2]

template<typename T >
T zeroerr::LogStream::getLog ( std::string  func,
unsigned  line,
std::string  name 
)
inline

get a log message from the stream

模板参数
TThe type of the log message
参数
funcThe function name of the log message
lineThe line number of the log message
nameThe name of field you want to get

This function is used to get a log message from the stream and extract the field with the name. The function will return the field with the type T. However, this type must be specified by the caller.

◆ getLogMode()

LogMode zeroerr::LogStream::getLogMode ( ) const
inline

◆ push()

template<typename... T>
PushResult zeroerr::LogStream::push ( T &&...  args)
inline

push a log message to the stream

模板参数
TThe types of the arguments
参数
argsThe arguments
返回
PushResult The result of the push

This function is used to push a log message to the stream. You can pass any type of arguments to this function and it will create a log message with the arguments. The log message is not written to the log file until the stream is flushed.

The log message is structured as a tuple of the arguments in the inner implementation class LogMessageImpl. After the log message is created, it used type erasure to return a LogMessage pointer to the caller.

The stored data type is determined by the to_store_type_t<T> template. For all the string type in raw pointer like const char* or char[], it will be converted to std::string. All reference type (including right value reference) will be converted to the original type.

◆ setAsyncLog()

void zeroerr::LogStream::setAsyncLog ( )
inline

◆ setFileLogger()

void zeroerr::LogStream::setFileLogger ( std::string  name,
DirMode  mode1 = SINGLE_FILE,
DirMode  mode2 = SINGLE_FILE,
DirMode  mode3 = SINGLE_FILE 
)

◆ setFlushAtOnce()

void zeroerr::LogStream::setFlushAtOnce ( )
inline

◆ setFlushManually()

void zeroerr::LogStream::setFlushManually ( )
inline

◆ setFlushMode()

void zeroerr::LogStream::setFlushMode ( FlushMode  mode)
inline

◆ setFlushWhenFull()

void zeroerr::LogStream::setFlushWhenFull ( )
inline

◆ setLogMode()

void zeroerr::LogStream::setLogMode ( LogMode  mode)
inline

◆ setStderrLogger()

void zeroerr::LogStream::setStderrLogger ( )

◆ setStdoutLogger()

void zeroerr::LogStream::setStdoutLogger ( )

◆ setSyncLog()

void zeroerr::LogStream::setSyncLog ( )
inline

友元及相关函数文档

◆ LogIterator

friend class LogIterator
friend

类成员变量说明

◆ use_lock_free

bool zeroerr::LogStream::use_lock_free = true

该类的文档由以下文件生成: