10 #ifndef PAS_CO2_LOGGER_HPP_ 11 #define PAS_CO2_LOGGER_HPP_ 15 #if (PAS_CO2_LOGGER_ENABLED == 1) 32 void print (
const char * format,
55 #define PAS_CO2_LOGGER_COLOR_RED "\x1b[31m" 56 #define PAS_CO2_LOGGER_COLOR_GREEN "\x1b[32m" 57 #define PAS_CO2_LOGGER_COLOR_YELLOW "\x1b[33m" 58 #define PAS_CO2_LOGGER_COLOR_BLUE "\x1b[34m" 59 #define PAS_CO2_LOGGER_COLOR_MAGENTA "\x1b[35m" 60 #define PAS_CO2_LOGGER_COLOR_CYAN "\x1b[36m" 61 #define PAS_CO2_LOGGER_COLOR_LIGHT_GREY "\x1b[90m" 62 #define PAS_CO2_LOGGER_COLOR_LIGHT_RED "\x1b[91m" 63 #define PAS_CO2_LOGGER_COLOR_LIGHT_GREEN "\x1b[92m" 64 #define PAS_CO2_LOGGER_COLOR_LIGHT_YELLOW "\x1b[93m" 65 #define PAS_CO2_LOGGER_COLOR_LIGHT_BLUE "\x1b[94m" 66 #define PAS_CO2_LOGGER_COLOR_LIGHT_MAGENTA "\x1b[95m" 67 #define PAS_CO2_LOGGER_COLOR_LIGHT_CYAN "\x1b[96m" 68 #define PAS_CO2_LOGGER_COLOR_DEFAULT "\x1b[0m" 77 #define PAS_CO2_LOGGER_ERROR_COLOR PAS_CO2_LOGGER_COLOR_RED 78 #define PAS_CO2_LOGGER_WARNING_COLOR PAS_CO2_LOGGER_COLOR_YELLOW 81 #define PAS_CO2_LOG_INIT()\ 86 #define PAS_CO2_LOG_DEINIT()\ 94 #if (PAS_CO2_CORE_LOGGER_ENABLED == 1) 96 #define PAS_CO2_LOGGER_SERVICE "[pasco2] : " 97 #define PAS_CO2_LOGGER_COLOR PAS_CO2_LOGGER_COLOR_GREEN 99 #define PAS_CO2_LOG_MSG(str)\ 101 cotwo_log.printfModule(str, PAS_CO2_LOGGER_SERVICE, PAS_CO2_LOGGER_COLOR);\ 104 #define PAS_CO2_LOG_RETURN(ret)\ 108 cotwo_log.printfModule("fail with return code %i", PAS_CO2_LOGGER_SERVICE, PAS_CO2_LOGGER_ERROR_COLOR, ret);\ 112 cotwo_log.printfModule("pass", PAS_CO2_LOGGER_SERVICE, PAS_CO2_LOGGER_COLOR);\ 118 #define PAS_CO2_LOG_MSG(str) { } 119 #define PAS_CO2_LOG_RETURN(ret) { } 126 #if (PAS_CO2_SERIAL_LOGGER_ENABLED == 1) 132 #define PAS_CO2_SERIAL_LOGGER_SERVICE "[pasco2 serial] : " 133 #define PAS_CO2_SERIAL_LOGGER_COLOR PAS_CO2_LOGGER_COLOR_BLUE 135 #define PAS_CO2_SERIAL_LOG_MSG(str)\ 137 cotwo_log.printfModule(str, PAS_CO2_SERIAL_LOGGER_SERVICE, PAS_CO2_SERIAL_LOGGER_COLOR);\ 140 #define PAS_CO2_SERIAL_LOG_RETURN(ret)\ 144 cotwo_log.printfModule("fail with return code %i", PAS_CO2_SERIAL_LOGGER_SERVICE, PAS_CO2_SERIAL_LOGGER_COLOR, ret);\ 148 cotwo_log.printfModule("pass", PAS_CO2_SERIAL_LOGGER_SERVICE, PAS_CO2_SERIAL_LOGGER_COLOR);\ 154 #define PAS_CO2_SERIAL_LOG_MSG(str) { } 155 #define PAS_CO2_SERIAL_LOG_RETURN(ret) { } 162 #if (PAS_CO2_PULSE_LOGGER_ENABLED == 1) 168 #define PAS_CO2_PULSE_LOGGER_SERVICE "[pasco2 pulse] : " 169 #define PAS_CO2_PULSE_LOGGER_COLOR PAS_CO2_LOGGER_COLOR_BLUE 171 #define PAS_CO2_PULSE_LOG_MSG(str)\ 173 cotwo_log.printfModule(str, PAS_CO2_PULSE_LOGGER_SERVICE, PAS_CO2_PULSE_LOGGER_COLOR);\ 176 #define PAS_CO2_PULSE_LOG_RETURN(ret)\ 180 cotwo_log.printfModule("fail with return code %i", PAS_CO2_PULSE_LOGGER_SERVICE, PAS_CO2_PULSE_LOGGER_COLOR, ret);\ 184 cotwo_log.printfModule("pass", PAS_CO2_PULSE_LOGGER_SERVICE, PAS_CO2_PULSE_LOGGER_COLOR);\ 190 #define PAS_CO2_PULSE_LOG_MSG(str) { } 191 #define PAS_CO2_PULSE_LOG_RETURN(ret) { } 198 #if (PAS_CO2_I2C_LOGGER_ENABLED == 1) 200 #define PAS_CO2_I2C_LOGGER_SERVICE "[pasco2 i2c] : " 201 #define PAS_CO2_I2C_LOGGER_WRITE_SERVICE "[pasco2 i2c] : >>> " 202 #define PAS_CO2_I2C_LOGGER_READ_SERVICE "[pasco2 i2c] : <<< " 203 #define PAS_CO2_I2C_LOGGER_COLOR PAS_CO2_LOGGER_COLOR_CYAN 205 #define PAS_CO2_I2C_LOG_MSG(str)\ 207 cotwo_log.printfModule(str, PAS_CO2_I2C_LOGGER_SERVICE, PAS_CO2_I2C_LOGGER_COLOR);\ 210 #define PAS_CO2_I2C_LOG_RETURN(ret)\ 214 cotwo_log.printfModule("fail with return code %i", PAS_CO2_I2C_LOGGER_SERVICE, PAS_CO2_LOGGER_ERROR_COLOR, ret);\ 218 cotwo_log.printfModule("pass", PAS_CO2_I2C_LOGGER_SERVICE, PAS_CO2_I2C_LOGGER_COLOR);\ 222 #define PAS_CO2_I2C_LOG_READ_HEX(array, length)\ 224 cotwo_log.printModuleHex(array, length, PAS_CO2_I2C_LOGGER_READ_SERVICE, PAS_CO2_I2C_LOGGER_COLOR);\ 227 #define PAS_CO2_I2C_LOG_WRITE_HEX(array, length)\ 229 cotwo_log.printModuleHex(array, length, PAS_CO2_I2C_LOGGER_WRITE_SERVICE, PAS_CO2_I2C_LOGGER_COLOR);\ 234 #define PAS_CO2_I2C_LOG_MSG(str) { } 235 #define PAS_CO2_I2C_LOG_RETURN(ret) { } 236 #define PAS_CO2_I2C_LOG_READ_HEX(array, length) { } 237 #define PAS_CO2_I2C_LOG_WRITE_HEX(array, length) { } 244 #if (PAS_CO2_UART_LOGGER_ENABLED == 1) 246 #define PAS_CO2_UART_LOGGER_SERVICE "[pasco2 uart] : " 247 #define PAS_CO2_UART_LOGGER_WRITE_SERVICE "[pasco2 uart] : >>> " 248 #define PAS_CO2_UART_LOGGER_READ_SERVICE "[pasco2 uart] : <<< " 249 #define PAS_CO2_UART_LOGGER_COLOR PAS_CO2_LOGGER_COLOR_LIGHT_GREY 251 #define PAS_CO2_UART_LOG_MSG(str)\ 253 cotwo_log.printfModule(str, PAS_CO2_UART_LOGGER_SERVICE, PAS_CO2_UART_LOGGER_COLOR);\ 256 #define PAS_CO2_UART_LOG_RETURN(ret)\ 260 cotwo_log.printfModule("fail with return code %i", PAS_CO2_UART_LOGGER_SERVICE, PAS_CO2_LOGGER_ERROR_COLOR, ret);\ 264 cotwo_log.printfModule("pass", PAS_CO2_UART_LOGGER_SERVICE, PAS_CO2_UART_LOGGER_COLOR);\ 268 #define PAS_CO2_UART_LOG_READ_HEX(array, length)\ 270 cotwo_log.printModuleHex(array, length, PAS_CO2_UART_LOGGER_READ_SERVICE, PAS_CO2_UART_LOGGER_COLOR);\ 273 #define PAS_CO2_UART_LOG_WRITE_HEX(array, length)\ 275 cotwo_log.printModuleHex(array, length, PAS_CO2_UART_LOGGER_WRITE_SERVICE, PAS_CO2_UART_LOGGER_COLOR);\ 280 #define PAS_CO2_UART_LOG_MSG(str) { } 281 #define PAS_CO2_UART_LOG_RETURN(ret) { } 282 #define PAS_CO2_UART_LOG_READ_HEX(array, length) { } 283 #define PAS_CO2_UART_LOG_WRITE_HEX(array, length) { } 291 #if (PAS_CO2_PWM_LOGGER_ENABLED == 1) 297 #define PAS_CO2_PWM_LOGGER_SERVICE "[pasco2 pwm] : " 298 #define PAS_CO2_PWM_LOGGER_COLOR PAS_CO2_LOGGER_COLOR_BLUE 300 #define PAS_CO2_PWM_LOG_MSG(str)\ 302 cotwo_log.printfModule(str, PAS_CO2_PWM_LOGGER_SERVICE, PAS_CO2_PULSE_LOGGER_COLOR);\ 305 #define PAS_CO2_PWM_LOG_RETURN(ret)\ 309 cotwo_log.printfModule("fail with return code %i", PAS_CO2_PWM_LOGGER_SERVICE, PAS_CO2_PULSE_LOGGER_COLOR, ret);\ 313 cotwo_log.printfModule("pass", PAS_CO2_PWM_LOGGER_SERVICE, PAS_CO2_PULSE_LOGGER_COLOR);\ 319 #define PAS_CO2_PWM_LOG_MSG(str) { } 320 #define PAS_CO2_PWM_LOG_RETURN(ret) { } 327 #if (PAS_CO2_REG_LOGGER_ENABLED == 1) 329 #define PAS_CO2_REG_LOGGER_SERVICE "[pasco2 reg] : " 330 #define PAS_CO2_REG_LOGGER_COLOR PAS_CO2_LOGGER_COLOR_GREEN 332 #define PAS_CO2_REG_LOG_MSG(str)\ 334 cotwo_log.printfModule(str, PAS_CO2_REG_LOGGER_SERVICE, PAS_CO2_REG_LOGGER_COLOR);\ 337 #define PAS_CO2_REG_LOG_RETURN(ret)\ 341 cotwo_log.printfModule("fail with return code %i", PAS_CO2_REG_LOGGER_SERVICE, PAS_CO2_LOGGER_ERROR_COLOR, ret);\ 345 cotwo_log.printfModule("pass", PAS_CO2_REG_LOGGER_SERVICE, PAS_CO2_REG_LOGGER_COLOR);\ 349 #define PAS_CO2_REG_VALUE_HEX(addr_ptr)\ 351 cotwo_log.printModuleHex(addr_ptr, 1, PAS_CO2_REG_LOGGER_SERVICE, PAS_CO2_REG_LOGGER_COLOR);\ 354 #define PAS_CO2_REG_BITF_VALUE(map, addr, bitf)\ 356 cotwo_log.printfModule("%x :: 0x%02x -> bfield 0x%02x", PAS_CO2_REG_LOGGER_SERVICE, PAS_CO2_REG_LOGGER_COLOR, addr, map[addr], bitf);\ 359 #define PAS_CO2_REG_MAP_HEX(map, length, addr)\ 361 cotwo_log.print("%s%s", PAS_CO2_REG_LOGGER_COLOR, PAS_CO2_REG_LOGGER_SERVICE);\ 362 cotwo_log.print("%x :: 0x%02x\r\n", 0, map[0]);\ 363 for(uint8_t i = 1; i < length; i++)\ 365 cotwo_log.print("%17x :: ", i);\ 366 cotwo_log.print("0x%02x", map[i]);\ 368 cotwo_log.print("<---");\ 370 cotwo_log.print("\r\n");\ 372 cotwo_log.print("%s", PAS_CO2_LOGGER_COLOR_DEFAULT);\ 377 #define PAS_CO2_REG_VALUE_HEX(addr_ptr) { } 378 #define PAS_CO2_REG_BITF_VALUE(map, addr, bitf) { } 379 #define PAS_CO2_REG_MAP_HEX(map, length, addr) { } 387 #if (PAS_CO2_APP_LOGGER_ENABLED == 1) 392 #define PAS_CO2_APP_LOGGER_ERROR_COLOR PAS_CO2_LOGGER_COLOR_RED 393 #define PAS_CO2_APP_LOGGER_WARNING_COLOR PAS_CO2_LOGGER_COLOR_YELLOW 396 #define PAS_CO2_APP_LOGGER_SERVICE "[pasco2 app] : " 397 #define PAS_CO2_APP_LOGGER_COLOR PAS_CO2_LOGGER_COLOR_MAGENTA 399 #define PAS_CO2_APP_LOG_MSG(str)\ 401 cotwo_log.printfModule(str, PAS_CO2_APP_LOGGER_SERVICE, PAS_CO2_APP_LOGGER_COLOR);\ 404 #define PAS_CO2_APP_LOG_VAR(str, var)\ 406 cotwo_log.printfModule(str, PAS_CO2_APP_LOGGER_SERVICE, PAS_CO2_APP_LOGGER_COLOR, var);\ 409 #define PAS_CO2_APP_LOG_RETURN(ret)\ 413 cotwo_log.printfModule("fail with return code %i", PAS_CO2_APP_LOGGER_SERVICE, PAS_CO2_APP_LOGGER_ERROR_COLOR, ret);\ 417 cotwo_log.printfModule("pass", PAS_CO2_APP_LOGGER_SERVICE, PAS_CO2_APP_LOGGER_COLOR);\ 423 #define PAS_CO2_APP_LOG_MSG(str) {} 424 #define PAS_CO2_APP_LOG_VAR(str, var) {} 425 #define PAS_CO2_APP_LOG_RETURN(ret) {} 437 #define PAS_CO2_LOG_INIT() { } 438 #define PAS_CO2_LOG_DEINIT() { } 440 #define PAS_CO2_LOG_MSG(str) { } 441 #define PAS_CO2_LOG_RETURN(ret) { } 443 #define PAS_CO2_SERIAL_LOG_MSG(str) { } 444 #define PAS_CO2_SERIAL_LOG_RETURN(ret) { } 446 #define PAS_CO2_PULSE_LOG_MSG(str) { } 447 #define PAS_CO2_PULSE_LOG_RETURN(ret) { } 449 #define PAS_CO2_I2C_LOG_MSG(str) { } 450 #define PAS_CO2_I2C_LOG_RETURN(ret) { } 451 #define PAS_CO2_I2C_LOG_READ_HEX(array, length) { } 452 #define PAS_CO2_I2C_LOG_WRITE_HEX(array, length) { } 454 #define PAS_CO2_UART_LOG_MSG(str) { } 455 #define PAS_CO2_UART_LOG_RETURN(ret) { } 456 #define PAS_CO2_UART_LOG_READ_HEX(array, length) { } 457 #define PAS_CO2_UART_LOG_WRITE_HEX(array, length){ } 459 #define PAS_CO2_PWM_LOG_MSG(str) { } 460 #define PAS_CO2_PWM_LOG_RETURN(ret) { } 462 #define PAS_CO2_REG_LOG_MSG(str) { } 463 #define PAS_CO2_REG_LOG_RETURN(ret) { } 464 #define PAS_CO2_REG_VALUE_HEX(addr_ptr) { } 465 #define PAS_CO2_REG_BITF_VALUE(map, addr, bitf) { } 466 #define PAS_CO2_REG_MAP_HEX(map, length, addr) { } 468 #define PAS_CO2_APP_LOG_MSG(str) { } 469 #define PAS_CO2_APP_LOG_VAR(str, var) { } 470 #define PAS_CO2_APP_LOG_RETURN(ret) { } Logger cotwo_log
Library logger.
void print(const char *format,...)
Definition: pas-co2-logger.cpp:49
Definition: pas-co2-pal-logger.hpp:28
Definition: pas-co2-i2c.hpp:21
~Logger()
Definition: pas-co2-logger.cpp:28
Logger()
Definition: pas-co2-logger.cpp:23
Definition: pas-co2-logger.hpp:23
void printModuleHex(const uint8_t *array, uint32_t length, const char *module, const char *color)
Definition: pas-co2-logger.cpp:99
PAS CO2 Logger Platform Abstraction Layer.
void printfModule(const char *format, const char *module, const char *color,...)
Definition: pas-co2-logger.cpp:68
PAS CO2 Library Configuration.
void init()
Definition: pas-co2-logger.cpp:39
void deinit()
Definition: pas-co2-logger.cpp:44