Midnight Sun Firmware
Loading...
Searching...
No Matches
Logger

Logging library. More...

Macros

#define MAX_LOG_SIZE   (size_t)200
 
#define LOG_TIMEOUT_MS   10
 
#define UARTPORT   UART_PORT_1
 
#define TX_PIN   6
 
#define RX_PIN   7
 
#define IN_ORDER_LOGS   1
 
#define LOG_DEBUG(fmt, ...)   LOG(LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
 
#define LOG_WARN(fmt, ...)   LOG(LOG_LEVEL_WARN, fmt, ##__VA_ARGS__)
 
#define LOG_CRITICAL(fmt, ...)   LOG(LOG_LEVEL_CRITICAL, fmt, ##__VA_ARGS__)
 
#define log_init()    { uart_init(UART_PORT_1, &log_uart_settings); }
 
#define LOG(level, fmt, ...)
 

Enumerations

enum  LogLevel { LOG_LEVEL_DEBUG = 0 , LOG_LEVEL_WARN , LOG_LEVEL_CRITICAL , NUM_LOG_LEVELS }
 

Variables

char g_log_buffer [MAX_LOG_SIZE]
 
Mutex s_log_mutex
 
UartSettings log_uart_settings
 

Detailed Description

Logging library.

Macro Definition Documentation

◆ LOG

#define LOG (   level,
  fmt,
  ... 
)
Value:
do { \
if (xTaskGetSchedulerState() == taskSCHEDULER_RUNNING) { \
size_t msg_size = (size_t)snprintf(g_log_buffer, MAX_LOG_SIZE, "\r[%u] %s:%u: " fmt, (level), __FILE__, __LINE__, ##__VA_ARGS__); \
uart_tx(UART_PORT_1, (uint8_t *)g_log_buffer, msg_size); \
} \
} while (0)

Enumeration Type Documentation

◆ LogLevel

enum LogLevel
Enumerator
LOG_LEVEL_DEBUG 

Debug level

LOG_LEVEL_WARN 

Warning level

LOG_LEVEL_CRITICAL 

Critical level

NUM_LOG_LEVELS 

Number of Log levels