Skip to content

[Possible] Bug fix: Using instance level and mtx wait #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: future
Choose a base branch
from

Conversation

GitProdEnv
Copy link

Calling only static member methods will not take into account the class instance defined log level, which will lead to times where specific log levels via log.info, log.error, log.warning should not be logged, but they do.

We define the log level for the created instance LOGGING::Logging log{ESP_LOG_WARN}; but this logic is currently unused.

Code before:

static esp_err_t log(const esp_log_level_t level,
                         const std::string_view &msg,
                         const source_location &location = source_location::current())
    {
      if (default_level < level)
        return ESP_ERR_INVALID_STATE;

If we initialize two logging instances:

LOGGING::Logging log{ESP_LOG_INFO};
LOGGING::Logging log2{ESP_LOG_WARN}; // this instance has instance log level of warn
log2.info("Info log");

By calling the log2 instance it should return ESP_ERR_INVALID_STATE.

Before commit: It logs, because of default_level < level, where default_level is a static variable, that is ESP_LOG_INFO.

After commit: ESP_ERR_INVALID_STATE since we now use the instance_level < level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant