forked from matth-x/MicroOcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebug.h
More file actions
77 lines (62 loc) · 1.91 KB
/
Copy pathDebug.h
File metadata and controls
77 lines (62 loc) · 1.91 KB
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
70
71
72
73
74
75
76
77
// matth-x/ArduinoOcpp
// Copyright Matthias Akstaller 2019 - 2022
// MIT License
#ifndef AO_DEBUG_H
#define AO_DEBUG_H
#include <ArduinoOcpp/Platform.h>
#define AO_DL_NONE 0x00 //suppress all output to the console
#define AO_DL_ERROR 0x01 //report failures
#define AO_DL_WARN 0x02 //report observed or assumed inconsistent state
#define AO_DL_INFO 0x03 //make internal state apparent
#define AO_DL_DEBUG 0x04 //relevant info for debugging
#define AO_DL_VERBOSE 0x05 //all output
#ifndef AO_DBG_LEVEL
#define AO_DBG_LEVEL AO_DL_INFO //default
#endif
#define AO_DBG(level, X) \
do { \
AO_CONSOLE_PRINTF("[AO] %s (%s:%i): ",level, __FILE__,__LINE__); \
AO_CONSOLE_PRINTF X; \
AO_CONSOLE_PRINTF("\n"); \
} while (0);
#if AO_DBG_LEVEL >= AO_DL_ERROR
#define AO_DBG_ERR(...) AO_DBG("ERROR",(__VA_ARGS__))
#else
#define AO_DBG_ERR(...)
#endif
#if AO_DBG_LEVEL >= AO_DL_WARN
#define AO_DBG_WARN(...) AO_DBG("warning",(__VA_ARGS__))
#else
#define AO_DBG_WARN(...)
#endif
#if AO_DBG_LEVEL >= AO_DL_INFO
#define AO_DBG_INFO(...) AO_DBG("info",(__VA_ARGS__))
#else
#define AO_DBG_INFO(...)
#endif
#if AO_DBG_LEVEL >= AO_DL_DEBUG
#define AO_DBG_DEBUG(...) AO_DBG("debug",(__VA_ARGS__))
#else
#define AO_DBG_DEBUG(...)
#endif
#if AO_DBG_LEVEL >= AO_DL_VERBOSE
#define AO_DBG_VERBOSE(...) AO_DBG("verbose",(__VA_ARGS__))
#else
#define AO_DBG_VERBOSE(...)
#endif
#ifdef AO_TRAFFIC_OUT
#define AO_DBG_TRAFFIC_OUT(...) \
do { \
AO_CONSOLE_PRINTF("[AO] Send: %s",__VA_ARGS__); \
AO_CONSOLE_PRINTF("\n"); \
} while (0)
#define AO_DBG_TRAFFIC_IN(...) \
do { \
AO_CONSOLE_PRINTF("[AO] Recv: %.*s",__VA_ARGS__); \
AO_CONSOLE_PRINTF("\n"); \
} while (0)
#else
#define AO_DBG_TRAFFIC_OUT(...)
#define AO_DBG_TRAFFIC_IN(...)
#endif
#endif