diff --git a/example/example.cpp b/example/example.cpp index 1ee4c003..c848141d 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -131,22 +131,22 @@ void async_example() } } -// create logger with 2 targets with different log levels and formats +// create logger with 2 targets with different log levels and formats +// the console will show only warnings or errors, while the file will log all void multi_sink_example() { - - auto console_sink = std::make_shared(); + auto console_sink = std::make_shared(); console_sink->set_level(spdlog::level::warn); console_sink->set_pattern("[multi_sink_example] [%^%l%$] %v"); - auto file_sink = std::make_shared("logs/multisink.txt", true); - file_sink->set_level(spdlog::level::info); + auto file_sink = std::make_shared("logs/multisink.txt", true); + file_sink->set_level(spdlog::level::trace); spdlog::logger logger("multi_sink", {console_sink, file_sink}); + logger.set_level(spdlog::level::debug); logger.warn("this should appear in both console and file"); logger.info("this message should not appear in the console, only in the file"); - } // user defined types logging by implementing operator<< #include "spdlog/fmt/ostr.h" // must be included