mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 01:51:38 +08:00
Minor example fix
This commit is contained in:
parent
06ffde6333
commit
74b0268713
@ -93,8 +93,9 @@ int main(int, char*[])
|
|||||||
size_t q_size = 1048576; //queue size must be power of 2
|
size_t q_size = 1048576; //queue size must be power of 2
|
||||||
spdlog::set_async_mode(q_size);
|
spdlog::set_async_mode(q_size);
|
||||||
auto async_file = spd::daily_logger_st("async_file_logger", "logs/async_log.txt");
|
auto async_file = spd::daily_logger_st("async_file_logger", "logs/async_log.txt");
|
||||||
async_file->info() << "This is async log.." << "Should be very fast!";
|
for (int i = 0; i < 100; ++i)
|
||||||
spdlog::drop_all(); //Close all loggers
|
async_file->info("Async message #{}", i);
|
||||||
|
|
||||||
//
|
//
|
||||||
// syslog example. linux only..
|
// syslog example. linux only..
|
||||||
//
|
//
|
||||||
@ -103,7 +104,13 @@ int main(int, char*[])
|
|||||||
auto syslog_logger = spd::syslog_logger("syslog", ident, LOG_PID);
|
auto syslog_logger = spd::syslog_logger("syslog", ident, LOG_PID);
|
||||||
syslog_logger->warn("This is warning that will end up in syslog. This is Linux only!");
|
syslog_logger->warn("This is warning that will end up in syslog. This is Linux only!");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
|
//Release and close all loggers
|
||||||
|
//
|
||||||
|
spdlog::drop_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (const spd::spdlog_ex& ex)
|
catch (const spd::spdlog_ex& ex)
|
||||||
{
|
{
|
||||||
std::cout << "Log failed: " << ex.what() << std::endl;
|
std::cout << "Log failed: " << ex.what() << std::endl;
|
||||||
|
@ -52,7 +52,7 @@ TEST_CASE("simple_file_logger", "[simple_logger]]")
|
|||||||
auto logger = spdlog::create<spdlog::sinks::simple_file_sink_mt>("logger", filename);
|
auto logger = spdlog::create<spdlog::sinks::simple_file_sink_mt>("logger", filename);
|
||||||
logger->set_pattern("%v");
|
logger->set_pattern("%v");
|
||||||
|
|
||||||
|
|
||||||
logger->info("Test message {}", 1);
|
logger->info("Test message {}", 1);
|
||||||
logger->info("Test message {}", 2);
|
logger->info("Test message {}", 2);
|
||||||
logger->flush();
|
logger->flush();
|
||||||
|
Loading…
Reference in New Issue
Block a user