7namespace tinyrobotics {
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
57 enum Level { ERROR = 0, WARN = 1, INFO = 2, DEBUG = 3 };
59 LoggerClass(Level level = INFO) : minLevel(level) {}
68 bool begin(Level level) { setLevel(level);
return true; }
71 void setLevel(Level level) { minLevel = level; }
73 void error(
const char* fmt, ...) {
76 vlog(ERROR, fmt, args);
79 void warn(
const char* fmt, ...) {
82 vlog(WARN, fmt, args);
85 void info(
const char* fmt, ...) {
88 vlog(INFO, fmt, args);
91 void debug(
const char* fmt, ...) {
94 vlog(DEBUG, fmt, args);
104 void vlog(Level level,
const char* fmt, va_list args) {
105 if (level > minLevel)
return;
106 const char* levelStr = levelToString(level);
108 vsnprintf(buf,
sizeof(buf), fmt, args);
110 p_out->print(levelStr);
114 printf(
"%s: %s\n", levelStr, buf);
118 const char* levelToString(Level level)
const {
136
137
138
139
140
141
142
143
Simple, cross-platform logger for Arduino and C++ environments.
Definition: LoggerClass.h:55