Skip to content

Adjust global logger default level to align with config.logging_level when no context is created. #5551

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

Merged
merged 2 commits into from
Jun 23, 2025

Conversation

kounelisagis
Copy link
Member

@kounelisagis kounelisagis commented Jun 20, 2025

This PR updates the default logging level of global_logger based on the TILEDB_VERBOSE flag. This ensures that the global logger's default logging level aligns with config.logging_level, even before a Context is created. Previously, the level was unconditionally set to Logger::Level::ERR, regardless of the flag.

If a Context was created before the global logger, the logging level was correctly set:

global_logger().set_level(static_cast<Logger::Level>(level));

However, if global_logger was used before any Context was created, the logging level was incorrectly set. This behavior was noticed in context-free C APIs that use api_entry_error. When these APIs were called before a Context was created, log messages appeared after calling LOG_ERROR(const std::string& msg), even if the TILEDB_VERBOSE flag was not set.

Closes CORE-269


Reproduction

One such C API is tiledb_config_load_from_file. When the filename argument is set to NULL, it throws a CAPIStatusException. Below is a script demonstrating this behavior: when the line that allocated the context is included, nothing appears on the user's screen using the default config.logging_level value. However, if that line is commented out, a log message appears like the following: [2025-06-20 20:04:08.442] [Process: 85057] [error] [1750439048442019000-Global] C API: Cannot load from file; null filename

#include <tiledb/tiledb.h>

int main() {
  tiledb_ctx_t* ctx;
  tiledb_ctx_alloc(NULL, &ctx); // Comment this line to see the differt behavior

  tiledb_config_t* config;
  tiledb_error_t* error = NULL;
  tiledb_config_alloc(&config, &error);
  tiledb_config_load_from_file(config, NULL, &error);

  return 0;
}

TYPE: IMPROVEMENT
DESC: Adjust global logger default level to align with config.logging_level when no context is created.

@ypatia ypatia self-requested a review June 23, 2025 11:25
@kounelisagis kounelisagis merged commit 5c6fc79 into main Jun 23, 2025
56 checks passed
@kounelisagis kounelisagis deleted the agis/change-global-logger-default-level branch June 23, 2025 17:47
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.

3 participants