Suppress [comm.protocol] log messages?

Hello. I’m using Log.info to show debugging messages to a serial window. However, when wifi cloud is connected, I get constant messages from [comm.protocol] INFO.

I begin my code with this:

SerialLogHandler logHandler(LOG_LEVEL_INFO);

Is there an easy way to suppress just the [comm.protocol] messages, or alternately, is there a different LOG_LEVEL I should use, and together with that, what would be the correct way to call the function at the new level?

Log.info("My Message");

This is what I presently call.

I don’t mind what “level” it is, I just want a configuration that will log messages I intentionally send, without any extra background reporting.

Thank you.

The docs do show how that would be done :wink:

https://docs.particle.io/reference/device-os/firmware/photon/#logging-categories

It is not clear how to do this by reading the docs. That is why I asked here.

The particle docs are written in fragments, often requiring hours or days of trial and error to make them actually work. The docs talk about a topic and talk around a topic or describe a class, but rarely show an actual complete example. There are often a few extra lines of code that are assumed to be known by the user. This is fine for C++ experts like those that wrote the docs, but makes it difficult for people who learn and understand by seeing actual examples.

The only way I have found to accomplish what I’m looking for is this:

SerialLogHandler logHandler(LOG_LEVEL_WARN);

Then using this to write to the logs:

Log.warn("My log message");

This gets the job done as WARN level suppresses all INFO and TRACE, but all the logs say warn. This is the only way I have found to eliminate the extra INFO calls.

I want to issue INFO calls or even TRACE calls, but that causes all the extra superfluous info to be logged also.

I see nothing in the docs that clearly shows the line of code to call to eliminate certain types of INFO or TRACE logs.

This should set the default level to INFO and set comm.protocol to ERROR.

SerialLogHandler logHandler(LOG_LEVEL_INFO, {
    { "comm.protocol", LOG_LEVEL_ERROR }
});
1 Like

Outstanding! Thank you sir. Very helpful.