Runtime log level selection for linux platform#140
Conversation
lib/platform/linux/logger.c
Outdated
| } | ||
| } | ||
|
|
||
| int Platform_set_log_level(const int level) |
There was a problem hiding this comment.
I don't know what was the spec for this modification. But I'd like that this dynamic log level could target one file only. Increasing the level to Debug for all modules will generate too much unwanted logs.
And this level should also be saved, so that on reset, it restarts with the requested log level. Init phase logs are very important.
There was a problem hiding this comment.
It would be a much bigger change as log system do not really have semantic for module id for now. Each file select its own log prefix.
But for sure it would be nice, even if at run time it could be hard to use.
There was a problem hiding this comment.
This was mainly for the linux gateway to help with testing. In linux gateway sink service the log level can be set in the beginning of the main function based on an environment variable. I agree there are too many logs when debug is selected. I was thinking about adding a new "trace" level and move some of the logs to use that.
I think module level granularity becomes difficult because of the configuration part. Would we need some configuration file to define all the levels for each module? There's the zlog library that looks like it has module("category") specific level selection out of the box, but I don't know if it would be worth taking something like that into use?
319c005 to
53ccf10
Compare
This change introduces runtime log level selection globally or per logging module. Applications can use Platform_set_log_level or Platform_set_module_log_level functions to set log levels during runtime. Each logging module uses a pointer to the log level managed by the platform implementation to minimize runtime checks. It is possible to define the NO_BUILD_ALL_LOG_LEVELS parameter to prevent building of logging functions with higher levels than the MAX_LOG_LEVEL parameter, like before.
b2292b6 to
fc3f87b
Compare
No description provided.