Hello everyone!
I'm currently trying to add microlog as a library to my STM32H7 MCU project and want to, sort of as a proof of concept, configure it to write the logs as "custom" output to the device's USART1. I later on want to write logs to both USART and maybe some flash memory for different types of debug purposes.
I've created a small .c/h. module for the overall logging configuration and initialisation that contains:
typedef int32_t (*output_writer_func)(void* device, uint8_t* buffer, size_t buffer_length);
void* output_handle = NULL;
void plat_logging_init(void* handle, output_writer_func func) {
output_handle = handle;
writer_func = func;
ulog_output_add(ulog_write_sink, (void*)"Output msg count", ULOG_LEVEL_TRACE);
ulog_output_level_set_all(ULOG_LEVEL_TRACE);
}
void ulog_write_sink(ulog_event* ev, void* arg) {
static char buffer[256];
ulog_event_to_cstr(ev, buffer, sizeof(buffer));
(*writer_func)(output_handle, (uint8_t*)buffer, strlen(buffer));
(*writer_func)(output_handle, (uint8_t*)"\n", 1);
}
The function pointer writer_func hides my concrete USART write function so that I can replace it with whatever I need later in my project.
Now, I noticed, that whatever I set in my ulog_config.h file, which I confirmed is being included and used by the build has no impact on the log output produced by ulog_write_sink().
My ulog_config.h file currently contains:
#pragma once
#pragma message("ulog_config.h included ?")
// Define all build options in one place
#define ULOG_BUILD_COLOR 1
#define ULOG_BUILD_PREFIX_SIZE 64
#define ULOG_BUILD_EXTRA_OUTPUTS 4
#define ULOG_BUILD_SOURCE_LOCATION 0
#define ULOG_BUILD_LEVEL_SHORT 1
#define ULOG_BUILD_TIME 0
#define ULOG_BUILD_TOPICS_MODE ULOG_BUILD_TOPICS_MODE_STATIC
#define ULOG_BUILD_TOPICS_STATIC_NUM 10
#define ULOG_BUILD_DYNAMIC_CONFIG 0
#define ULOG_BUILD_WARN_NOT_ENABLED 1
From what I can tell looking only briefly at how ulog_event_to_cstr() formats and copies over the event into the provided buffer, it ignores most configuration points and falls back to default settings, including the full event's source filepath and line, thus ignoring what I set before.
Is this desired behaviour, am I missing a different public API function I could use to use the configured formatting that currently seems to be reserved to print outputs over stdout, or is it not possible to use the same formatting options as the default stdout output at all?
Best regards,
Saph
Hello everyone!
I'm currently trying to add microlog as a library to my STM32H7 MCU project and want to, sort of as a proof of concept, configure it to write the logs as "custom" output to the device's USART1. I later on want to write logs to both USART and maybe some flash memory for different types of debug purposes.
I've created a small .c/h. module for the overall logging configuration and initialisation that contains:
The function pointer writer_func hides my concrete USART write function so that I can replace it with whatever I need later in my project.
Now, I noticed, that whatever I set in my ulog_config.h file, which I confirmed is being included and used by the build has no impact on the log output produced by ulog_write_sink().
My
ulog_config.hfile currently contains:From what I can tell looking only briefly at how ulog_event_to_cstr() formats and copies over the event into the provided buffer, it ignores most configuration points and falls back to default settings, including the full event's source filepath and line, thus ignoring what I set before.
Is this desired behaviour, am I missing a different public API function I could use to use the configured formatting that currently seems to be reserved to print outputs over stdout, or is it not possible to use the same formatting options as the default stdout output at all?
Best regards,
Saph