radar-bgt60 1.1.1
C++ library for the BGT60LTR11AIP - XENSIV™ 60 Ghz Radar from Infineon
 
Loading...
Searching...
No Matches
bgt60-logger.hpp
Go to the documentation of this file.
1
10#ifndef BGT60_LOGGER_HPP_
11#define BGT60_LOGGER_HPP_
12
13#include "bgt60-conf.hpp"
14
15#if (BGT60_LOGGER_ENABLED == 1)
16
17#include <stdint.h>
18#include <stdio.h>
19#include <stdarg.h>
20#include <string.h>
21#include "bgt60-pal-logger.hpp"
22
23namespace bgt60
24{
25
26class Logger
27{
28 public:
29 Logger();
30 Logger(LoggerPAL *logpal);
31 ~Logger();
32 void init();
33 void deinit();
34 void print(const char * format, ...);
35 void printfModule(const char * format, const char *module, const char * color, ...);
36 void printModuleHex(const uint8_t * array, uint32_t length, const char * module, const char * color);
37
38 private:
39 LoggerPAL *logpal;
40
41};
42
47extern Logger bgt60_log;
48
52#define BGT60_LOGGER_COLOR_RED "\x1b[31m"
53#define BGT60_LOGGER_COLOR_GREEN "\x1b[32m"
54#define BGT60_LOGGER_COLOR_YELLOW "\x1b[33m"
55#define BGT60_LOGGER_COLOR_BLUE "\x1b[34m"
56#define BGT60_LOGGER_COLOR_MAGENTA "\x1b[35m"
57#define BGT60_LOGGER_COLOR_CYAN "\x1b[36m"
58#define BGT60_LOGGER_COLOR_LIGHT_GREY "\x1b[90m"
59#define BGT60_LOGGER_COLOR_LIGHT_RED "\x1b[91m"
60#define BGT60_LOGGER_COLOR_LIGHT_GREEN "\x1b[92m"
61#define BGT60_LOGGER_COLOR_LIGHT_YELLOW "\x1b[93m"
62#define BGT60_LOGGER_COLOR_LIGHT_BLUE "\x1b[94m"
63#define BGT60_LOGGER_COLOR_LIGHT_MAGENTA "\x1b[95m"
64#define BGT60_LOGGER_COLOR_LIGHT_CYAN "\x1b[96m"
65#define BGT60_LOGGER_COLOR_DEFAULT "\x1b[0m"
66
74#define BGT60_LOGGER_ERROR_COLOR BGT60_LOGGER_COLOR_RED
75#define BGT60_LOGGER_WARNING_COLOR BGT60_LOGGER_COLOR_YELLOW
76
77#define BGT60_LOG_INIT()\
78{\
79 bgt60_log.init();\
80}
81
82#define BGT60_LOG_DEINIT()\
83{\
84 bgt60_log.deinit();\
85}
86
90#if (BGT60_CORE_LOGGER_ENABLED == 1)
91
92#define BGT60_LOGGER_SERVICE "[bgt60] : "
93#define BGT60_LOGGER_COLOR BGT60_LOGGER_COLOR_GREEN
94
95#define BGT60_LOG_MSG(str)\
96{\
97bgt60_log.printfModule(str, BGT60_LOGGER_SERVICE, BGT60_LOGGER_COLOR);\
98}
99
100#define BGT60_LOG_RETURN(ret)\
101{\
102 if(0 > ret)\
103 {\
104 bgt60_log.printfModule("fail with return code %i", BGT60_LOGGER_SERVICE, BGT60_LOGGER_ERROR_COLOR, ret);\
105 }\
106 else\
107 {\
108 bgt60_log.printfModule("pass", BGT60_LOGGER_SERVICE, BGT60_LOGGER_COLOR);\
109 }\
110}
111
112#else
113
114#define BGT60_LOG_MSG(str) { }
115#define BGT60_LOG_RETURN(ret) { }
116
117#endif
122#if (BGT60_APP_LOGGER_ENABLED == 1)
123
127#define BGT60_APP_LOGGER_ERROR_COLOR BGT60_LOGGER_COLOR_RED
128#define BGT60_APP_LOGGER_WARNING_COLOR BGT60_LOGGER_COLOR_LIGHT_YELLOW
129
130#define BGT60_APP_LOGGER_SERVICE "[bgt60 app] : "
131#define BGT60_APP_LOGGER_COLOR BGT60_LOGGER_COLOR_MAGENTA
132
133#define BGT60_APP_LOG_MSG(str)\
134{\
135 bgt60_log.printfModule(str, BGT60_APP_LOGGER_SERVICE, BGT60_APP_LOGGER_COLOR);\
136}
137
138#define BGT60_APP_LOG_VAR(str, var)\
139{\
140 bgt60_log.printfModule(str, BGT60_APP_LOGGER_SERVICE, BGT60_APP_LOGGER_COLOR, var);\
141}
142
143#define BGT60_APP_LOG_RETURN(ret)\
144{\
145 if(0 > ret)\
146 {\
147 bgt60_log.printfModule("fail with return code %i", BGT60_APP_LOGGER_SERVICE, BGT60_APP_LOGGER_ERROR_COLOR, ret);\
148 }\
149 else\
150 {\
151 bgt60_log.printfModule("pass", BGT60_APP_LOGGER_SERVICE, BGT60_APP_LOGGER_COLOR);\
152 }\
153}
154
155#else
156
157#define BGT60_APP_LOG_MSG(str) { }
158#define BGT60_APP_LOG_VAR(str, var) { }
159#define BGT60_APP_LOG_RETURN(ret) { }
160
161#endif /* BGT60_APP_LOGGER_ENABLED */
162
163}
164
165#else
166
171#define BGT60_LOG_INIT() { }
172#define BGT60_LOG_DEINIT() { }
173
174#define BGT60_LOG_MSG(str) { }
175#define BGT60_LOG_RETURN(ret) { }
176
177#define BGT60_APP_LOG_MSG(str) { }
178#define BGT60_APP_LOG_VAR(str, var) { }
179#define BGT60_APP_LOG_RETURN(ret) { }
180
181#endif /* BGT60_LOGGER_ENABLED */
182
183#endif /* BGT60_LOGGER_HPP */
Radar BGT60 Library Configuration.
Radar BGT60 Logger Platform Abstraction Layer.
Definition bgt60-types.hpp:14