|
ZeroErr
|
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 > | |
| T | getLog (zeroerr::String func, unsigned line, zeroerr::String name) |
| get a log message from the stream | |
| template<typename T > | |
| T | getLog (zeroerr::String func, zeroerr::String msg, zeroerr::String name) |
| get a log message from the stream | |
| LogIterator | begin (zeroerr::String message="", zeroerr::String function_name="", int line=-1) |
| LogIterator | end () |
| LogIterator | current (zeroerr::String message="", zeroerr::String function_name="", int line=-1) |
| void | flush () |
| void | setFileLogger (zeroerr::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 LogStream & | getDefault () |
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.
| zeroerr::LogStream::LogStream | ( | ) |
|
virtual |
|
inline |
| LogIterator zeroerr::LogStream::current | ( | zeroerr::String | message = "", |
| zeroerr::String | function_name = "", |
||
| int | line = -1 |
||
| ) |
|
inline |
| void zeroerr::LogStream::flush | ( | ) |
|
static |
|
inline |
|
inline |
get a log message from the stream
| T | The type of the log message |
| func | The function name of the log message |
| line | The line number of the log message |
| name | The 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.
|
inline |
get a log message from the stream
| T | The type of the log message |
| func | The function name of the log message |
| msg | The message of the log message |
| name | The 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.
|
inline |
|
inline |
push a log message to the stream
| T | The types of the arguments |
| args | The arguments |
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 zeroerr::String. All reference type (including right value reference) will be converted to the original type.
|
inline |
| void zeroerr::LogStream::setFileLogger | ( | zeroerr::String | name, |
| DirMode | mode1 = SINGLE_FILE, |
||
| DirMode | mode2 = SINGLE_FILE, |
||
| DirMode | mode3 = SINGLE_FILE |
||
| ) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
| void zeroerr::LogStream::setStderrLogger | ( | ) |
| void zeroerr::LogStream::setStdoutLogger | ( | ) |
|
inline |
|
friend |
| bool zeroerr::LogStream::use_lock_free = true |