MiniOB 1
MiniOB is one mini database, helping developers to learn how database works.
载入中...
搜索中...
未找到
| Public 成员函数 | 静态 Public 成员函数 | Private 类型 | Private 成员函数 | Private 属性 | 所有成员列表
common::Log类 参考

struct  _LogDate
 

Public 成员函数

 Log (const string &log_name, const LOG_LEVEL log_level=LOG_LEVEL_INFO, const LOG_LEVEL console_level=LOG_LEVEL_WARN)
 
template<class T >
Logoperator<< (T message)
 
template<class T >
int panic (T message)
 
template<class T >
int error (T message)
 
template<class T >
int warnning (T message)
 
template<class T >
int info (T message)
 
template<class T >
int debug (T message)
 
template<class T >
int trace (T message)
 
int output (const LOG_LEVEL level, const char *module, const char *prefix, const char *f,...)
 
int set_console_level (const LOG_LEVEL console_level)
 
LOG_LEVEL get_console_level ()
 
int set_log_level (const LOG_LEVEL log_level)
 
LOG_LEVEL get_log_level ()
 
int set_rotate_type (LOG_ROTATE rotate_type)
 
LOG_ROTATE get_rotate_type ()
 
const char * prefix_msg (const LOG_LEVEL level)
 
void set_default_module (const string &modules)
 
bool check_output (const LOG_LEVEL log_level, const char *module)
 
int rotate (const int year=0, const int month=0, const int day=0)
 
void set_context_getter (function< intptr_t()> context_getter)
 设置一个在日志中打印当前上下文信息的回调函数 更多...
 
intptr_t context_id ()
 

静态 Public 成员函数

static int init (const string &log_file)
 

Private 类型

typedef struct common::Log::_LogDate LogDate
 
typedef map< LOG_LEVEL, string > LogPrefixMap
 
typedef set< string > DefaultSet
 

Private 成员函数

void check_param_valid ()
 
int rotate_by_size ()
 
int rename_old_logs ()
 
int rotate_by_day (const int year, const int month, const int day)
 
template<class T >
int out (const LOG_LEVEL console_level, const LOG_LEVEL log_level, T &message)
 

Private 属性

pthread_mutex_t lock_
 
ofstream ofs_
 
string log_name_
 
LOG_LEVEL log_level_
 
LOG_LEVEL console_level_
 
LogDate log_date_
 
int log_line_
 
int log_max_line_
 
LOG_ROTATE rotate_type_
 
LogPrefixMap prefix_map_
 
DefaultSet default_set_
 
function< intptr_t()> context_getter_
 

成员函数说明

◆ operator<<()

template<class T >
Log & common::Log::operator<< ( message)

These functions won't output header information such as FUNCTION, The user should control these information If the header information should be outputed please use LOG_PANIC, LOG_ERROR ...

◆ set_context_getter()

void common::Log::set_context_getter ( function< intptr_t()>  context_getter)

设置一个在日志中打印当前上下文信息的回调函数

比如设置一个获取当前session标识的函数,那么每次在打印日志时都会输出session信息。 这个回调函数返回了一个intptr_t类型的数据,可能返回字符串更好,但是现在够用了。

◆ set_default_module()

void common::Log::set_default_module ( const string &  modules)

Set Default Module list if one module is default module, it will output whatever output level is lower than log_level_ or not


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