mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-27 07:14:12 +08:00
example update
This commit is contained in:
parent
db01c6b64d
commit
70d0e87328
10
README.md
10
README.md
@ -92,15 +92,15 @@ int main(int, char* [])
|
||||
//
|
||||
// Create a basic multithreaded file logger (use "file_logger_st" for the single threaded version)
|
||||
//
|
||||
auto simple_logger = spd::file_logger_mt("basic_logger", "logs/simple.txt");
|
||||
simple_logger->info("Some log message");
|
||||
auto my_logger = spd::file_logger_mt("basic_logger", "logs/basic.txt");
|
||||
my_logger->info("Some log message");
|
||||
|
||||
//
|
||||
// Create a file rotating logger with 5mb size max and 3 rotated files
|
||||
//
|
||||
auto file_logger = spd::rotating_logger_mt("file_logger", "logs/mylogfile", 1048576 * 5, 3);
|
||||
auto rotating_logger = spd::rotating_logger_mt("some_logger_name", "logs/mylogfile", 1048576 * 5, 3);
|
||||
for(int i = 0; i < 10; ++i)
|
||||
file_logger->info("{} * {} equals {:>10}", i, i, i*i);
|
||||
rotating_logger->info("{} * {} equals {:>10}", i, i, i*i);
|
||||
|
||||
//
|
||||
// Create a daily logger - a new file is created every day on 2:30am
|
||||
@ -111,7 +111,7 @@ int main(int, char* [])
|
||||
// Customize msg format for all messages
|
||||
//
|
||||
spd::set_pattern("*** [%H:%M:%S %z] [thread %t] %v ***");
|
||||
file_logger->info("This is another message with custom format");
|
||||
rotating_logger->info("This is another message with custom format");
|
||||
|
||||
spd::get("console")->info("loggers can be retrieved from a global registry using the spdlog::get(logger_name) function");
|
||||
|
||||
|
@ -44,21 +44,21 @@ int main(int, char*[])
|
||||
console->debug("This message shold be displayed..");
|
||||
|
||||
// Create basic file logger (not rotated)
|
||||
auto simple_logger = spd::basic_logger_mt("basic_logger", "logs/simple.txt");
|
||||
simple_logger->info("Some log message");
|
||||
auto my_logger = spd::basic_logger_mt("basic_logger", "logs/basic.txt");
|
||||
my_logger->info("Some log message");
|
||||
|
||||
|
||||
// Create a file rotating logger with 5mb size max and 3 rotated files
|
||||
auto file_logger = spd::rotating_logger_mt("file_logger", "logs/mylogfile", 1048576 * 5, 3);
|
||||
auto rotating_logger = spd::rotating_logger_mt("some_logger_name", "logs/mylogfile", 1048576 * 5, 3);
|
||||
for (int i = 0; i < 10; ++i)
|
||||
file_logger->info("{} * {} equals {:>10}", i, i, i*i);
|
||||
rotating_logger->info("{} * {} equals {:>10}", i, i, i*i);
|
||||
|
||||
// Create a daily logger - a new file is created every day on 2:30am
|
||||
auto daily_logger = spd::daily_logger_mt("daily_logger", "logs/daily", 2, 30);
|
||||
|
||||
// Customize msg format for all messages
|
||||
spd::set_pattern("*** [%H:%M:%S %z] [thread %t] %v ***");
|
||||
file_logger->info("This is another message with custom format");
|
||||
rotating_logger->info("This is another message with custom format");
|
||||
|
||||
|
||||
// Compile time debug or trace macros.
|
||||
|
Loading…
Reference in New Issue
Block a user