esp_log_level_set() for a tag is not effective if tag has already logged
Posted: Tue Jan 16, 2018 7:00 am
If you try to set a different log level for a tag that has already emitted some log messages, the change won't take effect unless the tag string in the call is exactly the same const char* pointer as is used in the log messages.
The problem is that the code only does a fast search of the cache, meaning that is looks for the tag string address rather than doing a strcmp to accept a match of a different instance of the same string.
So this function would be effective in a very limited case, but if an application implements a command to change log levels for a collection of components within the application it is likely that the tag string will be collected in a buffer of the command parser, it won't be the exact const char* string defined within the component that will be logging with that tag.
For my own fork of v2.1 I modified log.c so that esp_log_level_set() would do the slow search of the cache. I could not merge that code directly to master because of commit cfd95b62c that implemented the fast search of the cache. If I modify the code again on master and issue a PR, might you accept it?
The problem is that the code only does a fast search of the cache, meaning that is looks for the tag string address rather than doing a strcmp to accept a match of a different instance of the same string.
So this function would be effective in a very limited case, but if an application implements a command to change log levels for a collection of components within the application it is likely that the tag string will be collected in a buffer of the command parser, it won't be the exact const char* string defined within the component that will be logging with that tag.
For my own fork of v2.1 I modified log.c so that esp_log_level_set() would do the slow search of the cache. I could not merge that code directly to master because of commit cfd95b62c that implemented the fast search of the cache. If I modify the code again on master and issue a PR, might you accept it?