Memfault logging with timestamps

Hello support,

For our project we have an integration with Memfault for metrics, coredumps and log files.

We are currently developing in NRF 2.7.0 on a nrf9160 chip.

Transmitting log files works with the function memfault_log_trigger_collection() and memfault_zephyr_port_post_data().

I have the following logging configuration:

CONFIG_MEMFAULT=y

CONFIG_MEMFAULT_LOGGING_ENABLE=y
CONFIG_MEMFAULT_LOGGING_RAM_SIZE=4096
CONFIG_MEMFAULT_COMPACT_LOG=y

The received log file in memfault has the following layout:

E <err> bme680: Bad BME680 chip id: 0x0I<inf> BH1749: BH1749 initialized

E <err> ADXL372: failed to read id (0x0:0x0)I<inf> LSM6DSO: Initialize device lsm6dso@2

I <inf> LSM6DSO: chip id 0x6c

The output on my serial monitor is with a timestamp before each log line. Is there an option to transmit these timestamps also to memfault?
I have already tried with CONFIG_MEMFAULT_COMPACT_LOG disabled and also with CONFIG_MEMFAULT_PLATFORM_LOG_FALLBACK_TO_PRINTK enabled but both actions wont change anything.

I have also tried to overwrite the timing function with the config CONFIG_MEMFAULT_SYSTEM_TIME_SOURCE_CUSTOM

I am using the normal zephyr LOG_INF and other functions in my application.

Is there an alternative way to add the timestamps to the memfault log?

Thank you in advance!

Best regards,

Parents
  • Hi,

    Did you ever manage to get timestamps to appear for logs in the Memfault Cloud?. If so could you please share how its configured?

    Thanks,

  • Hi Dhivin,

    Yes, but to accomplish this, I have build my own quick and dirty log layer over the default log:

    static void get_uptime_string(char* buf, size_t size)
    {
    uint64_t uptime = k_uptime_get();
    snprintf((char *)buf, size, "[%lld.%03lld]", (uptime / 1000), (uptime % 1000));
    }
    void LOG_ERR_STAMPED(const char *fmt, ...){
    char buf[256];
    char now[20];
    get_uptime_string(now, sizeof(now));
    va_list args;
    va_start(args, fmt);
    vsnprintf(buf, sizeof(buf), fmt, args);
    va_end(args);

    LOG_ERR("%s %s", now, buf);
    }
    For us this works, we only use this where the timestamp is critical for example errors and change state machine states.
    best regards,
    René
Reply
  • Hi Dhivin,

    Yes, but to accomplish this, I have build my own quick and dirty log layer over the default log:

    static void get_uptime_string(char* buf, size_t size)
    {
    uint64_t uptime = k_uptime_get();
    snprintf((char *)buf, size, "[%lld.%03lld]", (uptime / 1000), (uptime % 1000));
    }
    void LOG_ERR_STAMPED(const char *fmt, ...){
    char buf[256];
    char now[20];
    get_uptime_string(now, sizeof(now));
    va_list args;
    va_start(args, fmt);
    vsnprintf(buf, sizeof(buf), fmt, args);
    va_end(args);

    LOG_ERR("%s %s", now, buf);
    }
    For us this works, we only use this where the timestamp is critical for example errors and change state machine states.
    best regards,
    René
Children
Related