-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdefault_logger.h
58 lines (48 loc) · 1.18 KB
/
default_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
#ifndef __DEFAULT_LOGGER__
#define __DEFAULT_LOGGER__
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "logger.h"
#define doLog(c) va_list args; \
va_start(args, fmt); \
log(c, file, line, fmt, args); \
va_end(args);
class DefaultLogger : public Logger
{
public:
const static int kMaxLogBufSize = 2048;
bool panic_;
void log(const char *level, const char *file, int line, const char *fmt, va_list args);
public:
DefaultLogger() : panic_(false)
{
}
void Debugf(const char *file, int line, const char *fmt, ...)
{
doLog("D");
}
void Infof(const char *file, int line, const char *fmt, ...)
{
doLog("I");
}
void Warningf(const char *file, int line, const char *fmt, ...)
{
doLog("W");
}
void Errorf(const char *file, int line, const char *fmt, ...)
{
doLog("E");
}
void Fatalf(const char *file, int line, const char *fmt, ...)
{
doLog("F");
abort();
}
void Panicf(const char *file, int line, const char *fmt, ...)
{
doLog("P");
}
};
extern DefaultLogger kDefaultLogger;
#endif