spdlog/example/example.cpp

36 lines
1.1 KiB
C++
Raw Normal View History

2014-02-21 15:51:54 -05:00
// example.cpp : Simple logger example
2014-01-25 08:52:10 -05:00
//
2014-10-11 21:40:11 -04:00
#define FFLOG_ENABLE_TRACE
#include <iostream>
2014-01-26 14:23:26 -05:00
#include "c11log/logger.h"
2014-10-11 21:40:11 -04:00
#include "c11log/factory.h"
2014-10-09 19:46:03 -04:00
#include "c11log/sinks/stdout_sinks.h"
2014-10-11 21:40:11 -04:00
#include "c11log/sinks/file_sinks.h"
using namespace std;
2014-10-09 19:46:03 -04:00
2014-10-18 09:05:41 -04:00
int main(int, char* [])
{
2014-05-06 10:38:11 -04:00
2014-10-11 21:40:11 -04: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 09:40:47 -05:00
2014-03-30 19:16:03 -04:00
2014-10-11 21:40:11 -04:00
//console->info() << "This is variadic ", " func, ", 123 << " YES";
FFLOG_TRACE(console, "This is ", 1);
2014-03-03 18:23:38 -05:00
2014-10-09 20:36:50 -04:00
2014-10-11 21:40:11 -04:00
file->info("Hello file log");
rotating->info("Hello rotating log");
daily->info("Hello daily log");
2014-03-28 18:37:29 -04:00
2014-10-11 21:40:11 -04: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 08:52:10 -05:00