If your platform is not supported. You can create a µlogger port for your platform.
- Add "ulogger.h" and "ulogger.c" to your project
include "ulogger.h"- Create log handlers:
HandlerReturnType log_handler(void *handler_data, LogLevel level, EventType event_type, timestamp time, void * log_data, size_t data_length) {
printf("Received event at %d\n", time);
return HANDLER_SUCCESS;
}- Create a timestamp function (varies by platform):
#include <sys/time.h>
void get_timestamp(timestamp *data) {
struct timeval tv;
gettimeofday(&tv,NULL);
*data = (timestamp) tv.tv_sec;
}- Declare a µlogger struct, such as
uLogger logger - Initialize it with any number of handlers - "print to uart" handlers, "send to network" handlers, the sky is the limit!
handler_func log_handlers[0];
void* handler_data[NUM_HANDLERS];
log_handlers[0] = (handler_func) &log_handler;
handler_data[0] = NULL;
ulogger_init(logger, log_handlers, handler_data, (size_t) 1);- You can now start logging!