Disabling debug logging from the Golioth SDK

Description

I’m trying to figure out how to turn off all the log messages from the Golioth SDK without changing the logging for my app.

CONFIG_GOLIOTH_DEBUG_LOG=n will disable GLTH_LOGX log statements, which appears to be what I want, but it looks like there are a bunch of places in the SDK that use the Zephyr LOG_XXX macros instead of the GLTH_LOGX equivalents (e.g. golioth-firmware-sdk/src/coap_client_zephyr.c at 7c5e894faf58acc3f08cfc3ae008e40ba43a3de7 · golioth/golioth-firmware-sdk · GitHub). These log messages print regardless of whether CONFIG_GOLIOTH_DEBUG_LOG=n is set or not.

Is there a reason why GLTH_LOGX isn’t used exclusively in the SDK given that golioth-firmware-sdk/port/zephyr/include/golioth_port_config.h at main · golioth/golioth-firmware-sdk · GitHub exists for the Zephyr port? My assumption is that replacing LOG_XXX with the GLTH_LOGX equivalents would result in CONFIG_GOLIOTH_DEBUG_LOG=n actually disabling the SDK debug logs.

Environment

SDK v0.18.1

Hey @cdwilson,

we’re aware of this issue and have been thinking about short-, medium-, and long-term solutions. There are a few goals we want to align with the GLTH_LOGX macros across the SDK, so we need to plan accordingly. Thanks for bumping this, it’s on our radar and we’ll work on a near-term fix.

1 Like

Hiya @cdwilson, nice to see you building more projects with Golioth!

Thanks for reporting the issues with the logging macros. I just merged a change that replaces the Zephyr-style logs with the cross platform ones. This should give you the control you’re looking for in turning those SDK logs on or off.

Thanks @mike! (and sorry for the delay getting back to you on this…I finally got some time today to look at this project again)

I noticed that v0.19.0 was just released so I updated my app’s manifest to try out this new release.

Couple things I found after upgrading to v0.19.0 from v0.18.1:

  1. When I tried to build my app with CONFIG_GOLIOTH_DEBUG_LOG=n (i.e. disable GLTH_LOGX), it failed with some warnings/errors like error: 'TAG' undeclared (first use in this function). I created a draft PR with the minimal set of changes I had to make to resolve the warnings/errors.
  2. I’m seeing errors in the serial console like the following on boot now:
[00:00:10.895,874] <err> net_coap: 166 is > sizeof(coap_option->value)(39)!

Here’s a screenshot showing it in the boot-up sequence:

I haven’t had time to look into this one, but I’m hoping you might know what is causing this.

My current config is just copied from the Thingy:91 Example App (TBH, I’m not really sure what these do):

CONFIG_COAP_EXTENDED_OPTIONS_LEN=y
CONFIG_COAP_EXTENDED_OPTIONS_LEN_VALUE=39

EDIT: ignore original comment below, this is actually happening randomly whether or not CONFIG_LOG_BACKEND_GOLIOTH is y or n. After rebooting a bunch of times, it shows up randomly (but not always) with either setting.

I forgot to mention that I’m only seeing these errors when the golioth logging backend is disabled in prj.conf:

CONFIG_LOG_BACKEND_GOLIOTH=n

When I enable this config, I don’t see these errors.