spdlog/example/example.cpp

36 lines
1.1 KiB
C++
Raw Normal View History

2014-02-21 22:51:54 +02:00
// example.cpp : Simple logger example
2014-01-25 15:52:10 +02:00
//
2014-10-12 04:40:11 +03:00
#define FFLOG_ENABLE_TRACE
#include <iostream>
2014-01-26 21:23:26 +02:00
#include "c11log/logger.h"
2014-10-12 04:40:11 +03:00
#include "c11log/factory.h"
2014-10-10 02:46:03 +03:00
#include "c11log/sinks/stdout_sinks.h"
2014-10-12 04:40:11 +03:00
#include "c11log/sinks/file_sinks.h"
using namespace std;
2014-10-10 02:46:03 +03:00
int main2(int argc, char* argv[])
{
2014-05-06 17:38:11 +03:00
2014-10-12 04:40:11 +03:00
auto console = c11log::factory::stdout_logger();
auto file = c11log::factory::simple_file_logger("log.txt");
auto rotating= c11log::factory::rotating_file_logger("myrotating", "txt", 1024*1024*5, 5, 1);
auto daily = c11log::factory::daily_file_logger("dailylog", "txt", 1, "daily_logger");
2014-03-08 16:40:47 +02:00
2014-03-31 02:16:03 +03:00
2014-10-12 04:40:11 +03:00
//console->info() << "This is variadic ", " func, ", 123 << " YES";
FFLOG_TRACE(console, "This is ", 1);
2014-03-04 01:23:38 +02:00
2014-10-10 03:36:50 +03:00
2014-10-12 04:40:11 +03:00
file->info("Hello file log");
rotating->info("Hello rotating log");
daily->info("Hello daily log");
2014-03-29 01:37:29 +03:00
2014-10-12 04:40:11 +03:00
//multi sink logger: file + console
auto sink1= std::make_shared<c11log::sinks::stdout_sink_mt>();
auto sink2 = std::make_shared<c11log::sinks::daily_file_sink_mt>("rotating", "txt");
c11log::logger combined("combined", { sink1, sink2 });
return 0;
}
2014-01-25 15:52:10 +02:00