mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 10:01:33 +08:00
Update example
This commit is contained in:
parent
006124d816
commit
c8bd53509c
@ -31,13 +31,7 @@ int main(int, char *[])
|
|||||||
spdlog::info("Positional args are {1} {0}..", "too", "supported");
|
spdlog::info("Positional args are {1} {0}..", "too", "supported");
|
||||||
spdlog::info("{:>8} aligned, {:<8} aligned", "right", "left");
|
spdlog::info("{:>8} aligned, {:<8} aligned", "right", "left");
|
||||||
|
|
||||||
// Runtime log levels
|
// Log levels can also loaded from argv/env using "SPDLOG_LEVEL"
|
||||||
spdlog::set_level(spdlog::level::info); // Set global log level to info
|
|
||||||
spdlog::debug("This message should not be displayed!");
|
|
||||||
spdlog::set_level(spdlog::level::trace); // Set specific logger's log level
|
|
||||||
spdlog::debug("This message should be displayed..");
|
|
||||||
|
|
||||||
// Optionally load log levels from argv/env using the SPDLOG_LEVEL var
|
|
||||||
// For example: set the global level to info and mylogger to to trace:
|
// For example: set the global level to info and mylogger to to trace:
|
||||||
// SPDLOG_LEVEL=info,mylogger=trace && ./example
|
// SPDLOG_LEVEL=info,mylogger=trace && ./example
|
||||||
spdlog::cfg::load_env_levels();
|
spdlog::cfg::load_env_levels();
|
||||||
@ -46,6 +40,12 @@ int main(int, char *[])
|
|||||||
// #include "spdlog/cfg/argv.h" // for loading levels from argv
|
// #include "spdlog/cfg/argv.h" // for loading levels from argv
|
||||||
// spdlog::cfg::load_argv_levels(args, argv);
|
// spdlog::cfg::load_argv_levels(args, argv);
|
||||||
|
|
||||||
|
// Runtime log levels
|
||||||
|
spdlog::set_level(spdlog::level::info); // Set global log level to info
|
||||||
|
spdlog::debug("This message should not be displayed!");
|
||||||
|
spdlog::set_level(spdlog::level::trace); // Set specific logger's log level
|
||||||
|
spdlog::debug("This message should be displayed..");
|
||||||
|
|
||||||
// Customize msg format for all loggers
|
// Customize msg format for all loggers
|
||||||
spdlog::set_pattern("[%H:%M:%S %z] [%^%L%$] [thread %t] %v");
|
spdlog::set_pattern("[%H:%M:%S %z] [%^%L%$] [thread %t] %v");
|
||||||
spdlog::info("This an info message with custom format");
|
spdlog::info("This an info message with custom format");
|
||||||
|
Loading…
Reference in New Issue
Block a user