-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.cpp
55 lines (39 loc) · 1.35 KB
/
logger.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "logger.h"
Logger m_logger;
Logger s_logger;
void mlogger::init()
{
log4cplus::initialize();
log4cplus::BasicConfigurator config;
config.configure();
}
void mlogger::init_common_log(const std::string& log_file)
{
SharedAppenderPtr rolling_main_App(new RollingFileAppender(log_file, 10 *1024 *1024, 3));
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
std::string pattern = "%d{%m-%d-%y %H:%M:%S} %m%n";
std::auto_ptr<Layout> layout(new PatternLayout(pattern));
rolling_main_App->setLayout(layout);
#pragma GCC diagnostic pop
m_logger = Logger::getInstance("main");
m_logger.addAppender(rolling_main_App);
}
void mlogger::init_script_log(const std::string& log_file)
{
SharedAppenderPtr rolling_script_App(new RollingFileAppender(log_file));
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
std::string pattern = "%d{%m-%d-%y %H:%M:%S} %m%n";
std::auto_ptr<Layout> layout(new PatternLayout(pattern));
rolling_script_App->setLayout(layout);
#pragma GCC diagnostic pop
s_logger = Logger::getInstance("script");
s_logger.addAppender(rolling_script_App);
}
Logger* mlogger::m_p_logger(){return & m_logger;}
Logger* mlogger::s_p_logger(){return & s_logger;}
void mlogger::deinit()
{
Logger::shutdown();
}