-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglog_initializer.h
More file actions
35 lines (28 loc) · 924 Bytes
/
glog_initializer.h
File metadata and controls
35 lines (28 loc) · 924 Bytes
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
#include <glog/logging.h>
#include <glog/raw_logging.h>
#include <iomanip>
#include <iostream>
namespace cc {
using namespace std;
using namespace google;
void CustomPrefix(std::ostream &s, const LogMessageInfo &l, void *) {
// s << l.severity[0]
s << "[" << setw(4) << 1900 + l.time.year() << setw(2) << 1 + l.time.month()
<< setw(2) << l.time.day() << ' ' << setw(2) << l.time.hour() << ':'
<< setw(2) << l.time.min() << ':' << setw(2) << l.time.sec() << "."
<< setw(6) << l.time.usec() << "]" << ' ' << setfill(' ')
<< "[tid:" << setw(5) << l.thread_id << setfill('0') << "]" << ' ' << "["
<< l.severity[0] << "]"
<< " [" << l.filename << ':' << l.line_number << "]";
}
class GlogInitializer {
public:
static void Init(const char* argv0) {
google::InitGoogleLogging(argv0, &CustomPrefix);
google::LogToStderr();
}
private:
GlogInitializer() {
}
};
} // namespace cc