9 #ifndef TLE94112_LOGGER_HPP_
10 #define TLE94112_LOGGER_HPP_
14 #if (TLE94112_LOGGER_ENABLED == 1)
27 Logger (LoggerPAL *logpal);
31 void print (
const char * format,
33 void printfModule (
const char * format,
37 void printModuleHex (
const uint8_t * array,
49 extern Logger tle_log;
54 #define TLE94112_LOGGER_COLOR_RED "\x1b[31m"
55 #define TLE94112_LOGGER_COLOR_GREEN "\x1b[32m"
56 #define TLE94112_LOGGER_COLOR_YELLOW "\x1b[33m"
57 #define TLE94112_LOGGER_COLOR_BLUE "\x1b[34m"
58 #define TLE94112_LOGGER_COLOR_MAGENTA "\x1b[35m"
59 #define TLE94112_LOGGER_COLOR_CYAN "\x1b[36m"
60 #define TLE94112_LOGGER_COLOR_LIGHT_GREY "\x1b[90m"
61 #define TLE94112_LOGGER_COLOR_LIGHT_RED "\x1b[91m"
62 #define TLE94112_LOGGER_COLOR_LIGHT_GREEN "\x1b[92m"
63 #define TLE94112_LOGGER_COLOR_LIGHT_YELLOW "\x1b[93m"
64 #define TLE94112_LOGGER_COLOR_LIGHT_BLUE "\x1b[94m"
65 #define TLE94112_LOGGER_COLOR_LIGHT_MAGENTA "\x1b[95m"
66 #define TLE94112_LOGGER_COLOR_LIGHT_CYAN "\x1b[96m"
67 #define TLE94112_LOGGER_COLOR_DEFAULT "\x1b[0m"
76 #define TLE94112_LOGGER_ERROR_COLOR TLE94112_LOGGER_COLOR_RED
77 #define TLE94112_LOGGER_WARNING_COLOR TLE94112_LOGGER_COLOR_YELLOW
80 #define TLE94112_LOG_INIT()\
85 #define TLE94112_LOG_DEINIT()\
93 #if (TLE94112_CORE_LOGGER_ENABLED == 1)
95 #define TLE94112_LOGGER_SERVICE "[tle94112] : "
96 #define TLE94112_LOGGER_COLOR TLE94112_LOGGER_COLOR_GREEN
98 #define TLE94112_LOG_MSG(str)\
100 tle_log.printfModule(str, TLE94112_LOGGER_SERVICE, TLE94112_LOGGER_COLOR);\
103 #define TLE94112_LOG_RETURN(ret)\
107 tle_log.printfModule("fail with return code %i", TLE94112_LOGGER_SERVICE, TLE94112_LOGGER_ERROR_COLOR, ret);\
111 tle_log.printfModule("pass", TLE94112_LOGGER_SERVICE, TLE94112_LOGGER_COLOR);\
117 #define TLE94112_LOG_MSG(str) { }
118 #define TLE94112_LOG_RETURN(ret) { }
125 #if (TLE94112_MOTOR_LOGGER_ENABLED == 1)
127 #define TLE94112_MOTOR_LOGGER_SERVICE "[tle94112 motor] : "
128 #define TLE94112_MOTOR_LOGGER_COLOR TLE94112_LOGGER_COLOR_BLUE
130 #define TLE94112_MOTOR_LOG_MSG(str)\
132 tle_log.printfModule(str, TLE94112_MOTOR_LOGGER_SERVICE, TLE94112_MOTOR_LOGGER_COLOR);\
135 #define TLE94112_MOTOR_LOG_RETURN(ret)\
139 tle_log.printfModule("fail with return code %i", TLE94112_MOTOR_LOGGER_SERVICE, TLE94112_LOGGER_ERROR_COLOR, ret);\
143 tle_log.printfModule("pass", TLE94112_MOTOR_LOGGER_SERVICE, TLE94112_MOTOR_LOGGER_COLOR);\
149 #define TLE94112_MOTOR_LOG_MSG(str) { }
150 #define TLE94112_MOTOR_LOG_RETURN(ret) { }
157 #if (TLE94112_REG_LOGGER_ENABLED == 1)
159 #define TLE94112_REG_LOGGER_SERVICE "[tle94112 reg] : "
160 #define TLE94112_REG_LOGGER_COLOR TLE94112_LOGGER_COLOR_GREEN
162 #define TLE94112_REG_LOG_MSG(str)\
164 tle_log.printfModule(str, TLE94112_REG_LOGGER_SERVICE, TLE94112_REG_LOGGER_COLOR);\
167 #define TLE94112_REG_LOG_RETURN(ret)\
171 tle_log.printfModule("fail with return code %i", TLE94112_REG_LOGGER_SERVICE, TLE94112_LOGGER_ERROR_COLOR, ret);\
175 tle_log.printfModule("pass", TLE94112_REG_LOGGER_SERVICE, TLE94112_REG_LOGGER_COLOR);\
179 #define TLE94112_REG_VALUE_HEX(addr_ptr)\
181 tle_log.printModuleHex(addr_ptr, 1, TLE94112_REG_LOGGER_SERVICE, TLE94112_REG_LOGGER_COLOR);\
184 #define TLE94112_REG_BITF_VALUE(map, addr, bitf)\
186 tle_log.printfModule("%x :: 0x%02x -> bfield 0x%02x", TLE94112_REG_LOGGER_SERVICE, TLE94112_REG_LOGGER_COLOR, addr, map[addr], bitf);\
189 #define TLE94112_REG_MAP_HEX(map, length, addr)\
191 tle_log.print("%s%s", TLE94112_REG_LOGGER_COLOR, TLE94112_REG_LOGGER_SERVICE);\
192 tle_log.print("%x :: 0x%02x\r\n", 0, map[0]);\
193 for(uint8_t i = 1; i < length; i++)\
195 tle_log.print("%17x :: ", i);\
196 tle_log.print("0x%02x", map[i]);\
198 tle_log.print("<---");\
200 tle_log.print("\r\n");\
202 tle_log.print("%s", TLE94112_LOGGER_COLOR_DEFAULT);\
207 #define TLE94112_REG_VALUE_HEX(addr_ptr) { }
208 #define TLE94112_REG_BITF_VALUE(map, addr, bitf) { }
209 #define TLE94112_REG_MAP_HEX(map, length, addr) { }
217 #if (TLE94112_APP_LOGGER_ENABLED == 1)
222 #define TLE94112_APP_LOGGER_ERROR_COLOR TLE94112_LOGGER_COLOR_RED
223 #define TLE94112_APP_LOGGER_WARNING_COLOR TLE94112_LOGGER_COLOR_YELLOW
226 #define TLE94112_APP_LOGGER_SERVICE "[tle94112 app] : "
227 #define TLE94112_APP_LOGGER_COLOR TLE94112_LOGGER_COLOR_MAGENTA
229 #define TLE94112_APP_LOG_MSG(str)\
231 tle_log.printfModule(str, TLE94112_APP_LOGGER_SERVICE, TLE94112_APP_LOGGER_COLOR);\
234 #define TLE94112_APP_LOG_VAR(str, var)\
236 tle_log.printfModule(str, TLE94112_APP_LOGGER_SERVICE, TLE94112_APP_LOGGER_COLOR, var);\
239 #define TLE94112_APP_LOG_RETURN(ret)\
243 tle_log.printfModule("fail with return code %i", TLE94112_APP_LOGGER_SERVICE, TLE94112_APP_LOGGER_ERROR_COLOR, ret);\
247 tle_log.printfModule("pass", TLE94112_APP_LOGGER_SERVICE, TLE94112_APP_LOGGER_COLOR);\
253 #define TLE94112_APP_LOG_MSG(str) {}
254 #define TLE94112_APP_LOG_VAR(str, var) {}
255 #define TLE94112_APP_LOG_RETURN(ret) {}
267 #define TLE94112_LOG_INIT() { }
268 #define TLE94112_LOG_DEINIT() { }
270 #define TLE94112_LOG_MSG(str) { }
271 #define TLE94112_LOG_RETURN(ret) { }
273 #define TLE94112_MOTOR_LOG_MSG(str) { }
274 #define TLE94112_MOTOR_LOG_RETURN(ret) { }
276 #define TLE94112_REG_BITF_VALUE(map, addr, bitf) { }
277 #define TLE94112_REG_MAP_HEX(map, length, addr) { }
279 #define TLE94112_APP_LOG_MSG(str) { }
280 #define TLE94112_APP_LOG_VAR(str, var) { }
281 #define TLE94112_APP_LOG_RETURN(ret) { }
TLE94112 Logger Platform Abstraction Layer.
Definition: tle94112-types.hpp:14
TLE94112 Library Configuration.