Commit 15916566 authored by gabime's avatar gabime

fixed example

parent 76436d07
......@@ -4,7 +4,7 @@ CXX_RELEASE_FLAGS = -O3 -flto
CXX_DEBUG_FLAGS= -g
all: bench
all: example bench
debug: example-debug bench-debug
example: example.cpp
......
......@@ -26,8 +26,8 @@
// spdlog usage example
//
#include <iostream>
#include "spdlog/spdlog.h"
#include "spdlog/details/format.h"
#include "spdlog/spdlog.h"ls
int main(int, char* [])
{
......@@ -36,8 +36,6 @@ int main(int, char* [])
try
{
fmt::print("Hello man {} {:1f}\n", 1, 2.2);
return 0;
std::string filename = "logs/spdlog_example";
// Set log level to all loggers to DEBUG and above
spd::set_level(spd::level::DEBUG);
......@@ -46,9 +44,19 @@ int main(int, char* [])
//Create console, multithreaded logger
auto console = spd::stdout_logger_mt("console");
console->info("Welcome to spdlog!") ;
console->info("An info message example", "...", 1, 2, 3.5);
console->info("An info message example {}..", 1);
console->info() << "Streams are supported too " << 1;
console->info("Easy padding in numbers like {:08d}", 12);
console->info("Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42);
console->info("Support for floats {:03.2f}", 1.23456);
console->info("Positional args are {1} {0}..", "too", "supported");
console->info("{:<30}", "left aligned");
console->info("{:>30}", "right aligned");
console->info("{:^30}", "centered");
//Create a file rotating logger with 5mb size max and 3 rotated files
auto file_logger = spd::rotating_logger_mt("file_logger", filename, 1024 * 1024 * 5, 3);
file_logger->info("Log file message number", 1);
......@@ -65,7 +73,7 @@ int main(int, char* [])
// Asynchronous logging is easy..
// Just call spdlog::set_async_mode(max_q_size) and all created loggers from now on will be asynchronous..
//
size_t max_q_size = 100000;
size_t max_q_size = 1048576;
spdlog::set_async_mode(max_q_size);
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!";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment