It seems very inconsistent. Most of the time “log_filter_set(NULL, 0,” filters both the console and Golioth but sometimes it doesn’t.
What should NULL filter out? It’s not clear but all the examples show NULL in the first parameter.
If I want to filter it out in both the console and to Golioth do I need to call log_filter_set twice?
@john.stuewe, using NULL will filter out all logging backends, in this case, the serial console and Golioth. A caveat to this statement is that the log backend instance must be active. The filtering won’t affect the Golioth log backend instance if it is not active (before the connection to the Cloud is established or if the log backend is disabled altogether).
Example:
calling log_filter_set(NULL, 0, log_source_id_get("ds28e18"), LOG_LEVEL_ERR); when the Golioth log instance isn’t active will filter the serial console messages but not the Golioth ones. In the serial console you would see only ERR messages, but in the Golioth Cloud you would see ERR, WRN, INF and DBG messages.
Can you check if you are applying the filter for ds28e18 module when the Golioth log instance isn’t active? This would explain the inconsistencies you’re experiencing.
I start Golioth before filtering the logs but it may not be completely connected so this may be it. Is it safe to filter all the logs in the on_client_event() function? Are all log backends guaranteed to be active on GOLIOTH_CLIENT_EVENT_CONNECTED?
Yes, it is safe to filter all logs in the on_client_event() function because we guarantee that the golioth_log_backend is active on the GOLIOTH_CLIENT_EVENT_CONNECTED event.