spdlog/example/example.cpp

36 lines
1.1 KiB
C++
Raw Normal View History

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