-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.h
79 lines (64 loc) · 1.9 KB
/
logger.h
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef LOGGER_H
#define LOGGER_H
#include <log4cplus/logger.h>
#include <log4cplus/loggingmacros.h>
#include <log4cplus/configurator.h>
#include <log4cplus/consoleappender.h>
#include <log4cplus/fileappender.h>
#include <log4cplus/appender.h>
#include <string>
#include <memory>
using namespace log4cplus;
class mlogger
{
static Logger* s_p_logger();
static Logger* m_p_logger();
public:
static void init();
static void init_common_log(const std::string& log_file);
static void init_script_log(const std::string& log_file);
static void deinit();
template<typename... Args>
static void info(const char* fmt, Args&&... args)
{
LOG4CPLUS_INFO_FMT(*m_p_logger(), fmt, std::forward<Args>(args)...);
}
static void info(const char* msg)
{
LOG4CPLUS_INFO(*m_p_logger(), msg);
}
template<typename... Args>
static void warn(const char* fmt, Args&&... args)
{
LOG4CPLUS_WARN_FMT(*m_p_logger(), fmt, std::forward<Args>(args)...);
}
static void warn(const char* msg)
{
LOG4CPLUS_WARN(*m_p_logger(), msg);
}
template<typename... Args>
static void error(const char* fmt, Args&&... args)
{
LOG4CPLUS_ERROR_FMT(*m_p_logger(), fmt, std::forward<Args>(args)...);
}
static void error(const char* msg)
{
LOG4CPLUS_ERROR(*m_p_logger(), msg);
}
template<typename... Args>
static void __info(const char* fmt, Args&&... args)
{
LOG4CPLUS_INFO_FMT(*s_p_logger(), fmt, std::forward<Args>(args)...);
}
template<typename... Args>
static void __warn(const char* fmt, Args&&... args)
{
LOG4CPLUS_WARN_FMT(*s_p_logger(), fmt, std::forward<Args>(args)...);
}
template<typename... Args>
static void __error(const char* fmt, Args&&... args)
{
LOG4CPLUS_ERROR_FMT(*s_p_logger(), fmt, std::forward<Args>(args)...);
}
};
#endif // LOGGER_H