48 lines
1.0 KiB
C
Executable File
48 lines
1.0 KiB
C
Executable File
#ifndef LOGGER_H_
|
|
#define LOGGER_H_
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <stdarg.h>
|
|
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/event_groups.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
#define LOGGER_SERIAL_BIT BIT0
|
|
|
|
extern EventGroupHandle_t logger_event_group;
|
|
|
|
void logger_init(void);
|
|
|
|
void logger_print(const char *str);
|
|
|
|
int logger_vprintf(const char *fmt, va_list args);
|
|
|
|
uint16_t logger_count(void);
|
|
|
|
// opcional: quantas mensagens foram dropadas por contenção de mutex
|
|
uint32_t logger_dropped_count(void);
|
|
|
|
/**
|
|
* ⚠️ API antiga (não recomendada): devolve ponteiro interno.
|
|
* Pode ficar inválido se houver novas escritas/rotação.
|
|
*/
|
|
bool logger_read(uint16_t *index, char **str, uint16_t *len);
|
|
|
|
/**
|
|
* ✅ API recomendada: copia a entrada para buffer do caller (safe).
|
|
* out é sempre terminado com '\0' (se out_sz > 0).
|
|
*/
|
|
bool logger_read_copy(uint16_t *index, char *out, uint16_t out_sz, uint16_t *out_len);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* LOGGER_H_ */
|