2020-10-28 19:40:08 +01:00
|
|
|
#ifndef _LOGGER_H_
|
|
|
|
#define _LOGGER_H_
|
|
|
|
|
2020-11-10 16:30:26 +01:00
|
|
|
#include <main.h>
|
2020-10-29 20:50:50 +01:00
|
|
|
|
2020-11-17 12:01:15 +01:00
|
|
|
#include <stdbool.h>
|
2020-11-03 17:57:03 +01:00
|
|
|
|
2020-11-17 15:15:28 +01:00
|
|
|
|
2020-11-17 15:38:11 +01:00
|
|
|
// Disabling this option is preferred. However, when debugging system hangs
|
|
|
|
// this option needs to be enabled.
|
2020-11-17 15:17:46 +01:00
|
|
|
// #define LOGGER_OUTPUT_BY_INTERRUPT
|
2020-11-17 15:15:28 +01:00
|
|
|
|
2020-11-03 17:57:03 +01:00
|
|
|
typedef enum {
|
2020-11-17 12:01:15 +01:00
|
|
|
LOG_NORMAL,
|
2020-11-03 17:57:03 +01:00
|
|
|
LOG_HIGH,
|
|
|
|
LOG_RED,
|
|
|
|
LOG_GREEN,
|
2020-11-03 18:02:36 +01:00
|
|
|
LOG_BLUE,
|
|
|
|
LOG_YELLOW
|
2020-11-03 17:57:03 +01:00
|
|
|
} t_logColor;
|
|
|
|
|
2020-10-29 14:30:55 +01:00
|
|
|
// initialize the logger, creates a ringbuffer
|
|
|
|
void logInit();
|
|
|
|
|
|
|
|
// de-initialize the logger, free the ringbuffer
|
|
|
|
void logFree();
|
|
|
|
|
|
|
|
// log a message, make sure it is a null-terminated string
|
|
|
|
// return value can be ignored, it is only used in test
|
2020-10-29 20:50:50 +01:00
|
|
|
int logMsg(const char *format, ...);
|
2020-11-03 17:57:03 +01:00
|
|
|
|
2020-11-17 12:01:15 +01:00
|
|
|
int coloredMsg(const t_logColor color, bool syslogToo, const char *format, ...);
|
2020-11-03 17:57:03 +01:00
|
|
|
|
2020-11-17 15:15:28 +01:00
|
|
|
#ifdef LOGGER_OUTPUT_BY_INTERRUPT
|
2020-11-10 22:18:51 +01:00
|
|
|
void debugTxCpltCallback(UART_HandleTypeDef *huart);
|
2020-11-17 15:15:28 +01:00
|
|
|
#endif
|
2020-11-10 16:30:26 +01:00
|
|
|
|
2020-11-17 15:15:28 +01:00
|
|
|
#ifndef LOGGER_OUTPUT_BY_INTERRUPT
|
2020-11-17 15:17:46 +01:00
|
|
|
int logExec();
|
2020-11-17 15:15:28 +01:00
|
|
|
#endif
|
2020-11-10 16:30:26 +01:00
|
|
|
|
2020-10-28 19:40:08 +01:00
|
|
|
#endif // _LOGGER_H_
|