-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyLog.cpp
More file actions
75 lines (61 loc) · 1.7 KB
/
MyLog.cpp
File metadata and controls
75 lines (61 loc) · 1.7 KB
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
#include "MyLog.h"
#include<log4cpp/PropertyConfigurator.hh>
MyLog* MyLog::plog_ = NULL;
MyLog& MyLog::getInstance() {
if (plog_ == NULL) {
plog_ = new MyLog;
}
return *plog_;
}
void MyLog::destory() {
if (plog_) {
plog_->table.info("Mylog destory");
plog_->table.shutdown();
delete plog_;
}
}
MyLog::MyLog() :
table(log4cpp::Category::getInstance(std::string("Sgk.Table")))
{
QString logConfigFileName = "log4cpp.properties";
std::string logConfigFile = (configPath + logConfigFileName).toStdString();
log4cpp::PropertyConfigurator::configure(logConfigFile);
//log4cpp::Category& root = log4cpp::Category::getRoot();
//log4cpp::Category& sgk = log4cpp::Category::getInstance(std::string("Sgk"));
}
void MyLog::tableError(const char* msg, ...) {
size_t size = 1024;
char* buffer = new char[size];
va_list args;
va_start(args, msg);
vsnprintf(buffer, size, msg, args);
this->table.error(buffer);
va_end(args);
}
void MyLog::tableWarn(const char* msg, ...) {
size_t size = 1024;
char* buffer = new char[size];
va_list args;
va_start(args, msg);
vsnprintf(buffer, size, msg, args);
this->table.warn(buffer);
va_end(args);
}
void MyLog::tableInfo(const char* msg, ...) {
size_t size = 1024;
char* buffer = new char[size];
va_list args;
va_start(args, msg);
vsnprintf(buffer, size, msg, args);
this->table.info(buffer);
va_end(args);
}
void MyLog::tableDebug(const char* msg, ...) {
size_t size = 1024;
char* buffer = new char[size];
va_list args;
va_start(args, msg);
vsnprintf(buffer, size, msg, args);
this->table.debug(buffer);
va_end(args);
}