-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Closed
Description
In my main method I create a custom logger with two sinks:
std::vector<spdlog::sink_ptr> sinks;
sinks.push_back(std::make_shared<spdlog::sinks::stdout_color_sink_mt>());
sinks.push_back(std::make_shared<my_sink<std::mutex>>(...));
auto combined_logger = std::make_shared<spdlog::logger>("main", begin(sinks), end(sinks));
spdlog::set_default_logger(combined_logger);
spdlog::set_level(spdlog::level::debug);
spdlog::cfg::load_env_levels();
Then in my classes I create loggers with names for the corresponding classes like so:
EventQueue::EventQueue()
: logger(spdlog::default_logger()->clone("EventQueue"))
{
}
My expectation was when I set the env var SPDLOG_LEVEL="debug,EventQueue=info
I expected that my EventQueue
logger would have the info
level, but the level is debug.
Must I call spdlog::apply_logger_env_levels(logger);
every time for every logger I create? This seems wrong. How should I create the loggers so that the level from the env applies?
Metadata
Metadata
Assignees
Labels
No labels