forked from idealvin/coost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.cc
44 lines (34 loc) · 1.13 KB
/
log.cc
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
#include "co/log.h"
#include "co/time.h"
DEF_bool(perf, false, "performance testing");
bool static_log() {
DLOG << "hello static";
LOG << "hello again, static";
return true;
}
bool __ = static_log();
int main(int argc, char** argv) {
flag::init(argc, argv);
log::init();
if (FLG_perf) {
// test performance by writting 100W logs
COUT << "print 100W logs, every log is about 50 bytes";
Timer t;
for (int k = 0; k < 1000000; k++) {
LOG << "hello world " << 3;
}
int64 write_to_cache = t.us();
log::close();
int64 write_to_file = t.us();
COUT << "All logs written to cache in " << write_to_cache << " us";
COUT << "All logs written to file in " << write_to_file << " us";
} else {
// usage of other logs
DLOG << "This is DLOG (debug).. " << 23;
LOG << "This is LOG (info).. " << 23;
WLOG << "This is WLOG (warning).. " << 23;
ELOG << "This is ELOG (error).. " << 23;
//FLOG << "This is FLOG (fatal).. " << 23;
}
return 0;
}