global contextual logger support

pull/2687/head
Bailey Chittle 3 years ago
parent a272bc0516
commit b800164d11

@ -394,11 +394,9 @@ void replace_default_logger_example()
}
void attribute_example() {
auto custom_logger = spdlog::stdout_color_mt("custom_logger");
custom_logger->push_context(spdlog::attribute_list{{"attribute_key", "attribute value"}});
custom_logger->warn("EXPERIMENTAL: log with attributes");
custom_logger->clear_context();
spdlog::push_context(spdlog::attribute_list{{"attribute_key", "attribute value"}});
spdlog::warn("EXPERIMENTAL: log with attributes");
spdlog::clear_context();
// structured logging using attributes

@ -140,6 +140,18 @@ SPDLOG_API void set_default_logger(std::shared_ptr<spdlog::logger> default_logge
// spdlog::apply_logger_env_levels(mylogger);
SPDLOG_API void apply_logger_env_levels(std::shared_ptr<logger> logger);
inline void push_context(attribute_list attrs) {
default_logger_raw()->push_context(std::move(attrs));
}
inline void pop_context() {
default_logger_raw()->pop_context();
}
inline void clear_context() {
default_logger_raw()->clear_context();
}
template<typename... Args>
inline void log(source_loc source, level::level_enum lvl, format_string_t<Args...> fmt, Args &&... args)
{

Loading…
Cancel
Save