-
Notifications
You must be signed in to change notification settings - Fork 0
/
TraceLogger.h
69 lines (56 loc) · 1.76 KB
/
TraceLogger.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
59
60
61
62
63
64
65
66
67
68
69
#ifndef TRACE_LOGGER_H
#define TRACE_LOGGER_H
#include <Arduino.h>
#include "dumpHex.h"
class TraceLogger {
const char * logger;
void printHeader(){
Serial.print(logger);
Serial.print(" - ");
};
void printModule(const char * module){
Serial.print("[");
Serial.print(module);
Serial.print("] ");
};
public:
TraceLogger(const char * logger): logger(logger){
}
void log(const char* module, const char* message, const char* argument) {
// Implement logging logic here, I'll move it to .cpp after making sure it works, easy fix
Serial.print("[");
Serial.print(module);
Serial.print("] ");
Serial.print(message);
Serial.print(": ");
Serial.println(argument);
}
void log(const char* module, const char* message) {
// Implement logging logic here, I'll move it to .cpp after making sure it works, easy fix
Serial.print("[");
Serial.print(module);
Serial.print("] ");
Serial.println(message);
}
void log(const char* module, const char* message, long argument) {
// Implement logging logic here, I'll move it to .cpp after making sure it works, easy fix
Serial.print("[");
Serial.print(module);
Serial.print("] ");
Serial.print(message);
Serial.print(": ");
Serial.println(argument);
}
void logHex(const char* module, const char* message, const void* data, size_t size) {
Serial.print("[");
Serial.print(module);
Serial.print("] ");
Serial.print(message);
Serial.println(":");
dumpHex(&Serial, data, size);
}
};
//extern TraceLogger trace;
TraceLogger trace("DEBUG");
TraceLogger error("ERROR");
#endif // TRACE_LOGGER_H