How-to see system logging messages at boot-up?

I’m compiling deviceOS and would like to see the various LOG(...) messages from the time it starts up. Is there a trick to do this? Right now I use the USB serial but by the time that allows me to connect the firmware is already booted up and ready to run the app.

I am using this this to see my app logging from setup onwards

SerialLogHandler logHandler(LOG_LEVEL_WARN, // Logging level for non-application messages
{ 
    { "app", LOG_LEVEL_INFO} // Logging level for application messages
});

//------------------------------------------------------------------
void setup()
//------------------------------------------------------------------
{
    Serial.begin(115200);
..
    
    waitFor(Serial.isConnected, 30000);
    Log.info("Startup...");
    

// the rest …
}

IIRC the system LOG macro requirey the -DEBUG flag to be set at compile time (except on Electron for older versions).
In Workbench you can achieve that with a debug build (device OS and application).

1 Like

Thanks for the replies. Maybe I wasn’t clear enough in my post, but I have no problem seeing the LOG(...) messages once setup starts and I call Serial.begin(). The question I asked is how to see what happens before that…
Although, I’m discovering that with SYSTEM_MODE(SEMI_AUTOMATIC) there doesn’t seem all that much network related that happens before setup…

I’m pretty sure you wouldn’t need Serial.begin() at all when you have a SerialLogHandler instantiated.
I don’t know how things are with the more recent device OS versions but in older versions it wasn’t need at all since the device OS itself did initiate a USBSerial object.

I haven’t tried it, but I imagine you could even use a STARTUP() macro to get ontop of the code flow. Adding some delay there and using an autoconnecting monitor (e.g. particel serial monitor --follow) should give you as much output as you possibly can get.
If you want more you may need to go down the route of hardware debugging.

@ScruffR, I wonder if the delay is caused by the terminal program needing time to connect. In that case, it may be better to use Serial1 with a USB-to-Serial adapter which will allow a terminal program to be connected all the time, even when the device reboots.

2 Likes

That’s another option :+1: