diff --git a/c11logtest/c11logtest/c11logtest.vcxproj b/c11logtest/c11logtest/c11logtest.vcxproj index c827e71e..eb84e605 100644 --- a/c11logtest/c11logtest/c11logtest.vcxproj +++ b/c11logtest/c11logtest/c11logtest.vcxproj @@ -86,7 +86,6 @@ - @@ -94,6 +93,7 @@ + @@ -107,6 +107,7 @@ + diff --git a/c11logtest/c11logtest/c11logtest.vcxproj.filters b/c11logtest/c11logtest/c11logtest.vcxproj.filters index 4b803831..5110b219 100644 --- a/c11logtest/c11logtest/c11logtest.vcxproj.filters +++ b/c11logtest/c11logtest/c11logtest.vcxproj.filters @@ -69,12 +69,6 @@ Header Files\c11log\sinks - - Header Files\c11log\details - - - Header Files - Header Files\c11log\details @@ -90,6 +84,12 @@ Header Files\c11log + + Header Files\c11log\sinks + + + Header Files\c11log + @@ -98,5 +98,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/example/bench.cpp b/example/bench.cpp index 043f9bb1..615968f6 100644 --- a/example/bench.cpp +++ b/example/bench.cpp @@ -15,26 +15,26 @@ using namespace c11log; using namespace utils; -int main(int argc, char* argv[]) +int main2(int argc, char* argv[]) { - const unsigned int howmany = argc <= 1 ? 10000 : atoi(argv[1]); + const unsigned int howmany = argc <= 1 ? 1000000 : atoi(argv[1]); logger cout_logger("example", std::make_shared()); cout_logger.info() << "Hello logger"; - //auto nullsink = std::make_shared>(); auto nullsink = std::make_shared>(); - auto fsink = std::make_shared("log", "txt", 1024 * 1024 * 50, 5, 10); - auto as = std::make_shared(1000); - logger my_logger("my_logger", fsink); + + + logger my_logger("my_logger", nullsink); auto start = system_clock::now(); for (unsigned int i = 1; i <= howmany; ++i) - my_logger.info() << "Hello logger: msg #" << i; + my_logger.info() << "Hello logger: msg #" << i << 1<<2<<3<<4<<5<<6<<7<<8<<9<<10<<11<<12<<13<<14<<15<<16<<17<<18<<19; + //my_logger.info("Hello logger: msg #",i,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19); auto delta = system_clock::now() - start; diff --git a/example/example.cpp b/example/example.cpp index b17e4873..23b385b1 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -1,49 +1,35 @@ // example.cpp : Simple logger example // -#include +#define FFLOG_ENABLE_TRACE + +#include #include "c11log/logger.h" -#include "c11log/sinks/async_sink.h" -#include "c11log/sinks/file_sinks.h" +#include "c11log/factory.h" #include "c11log/sinks/stdout_sinks.h" -#include "c11log/sinks/null_sink.h" -#include "utils.h" - -using std::cout; -using std::endl; -using namespace std::chrono; -using namespace c11log; -using namespace utils; - +#include "c11log/sinks/file_sinks.h" +using namespace std; int main(int argc, char* argv[]) { - const unsigned int howmany = argc <= 1 ? 10000 : atoi(argv[1]); - - logger cout_logger("example", std::make_shared()); - cout_logger.info() << "Hello logger"; - - //auto nullsink = std::make_shared>(); - auto nullsink = std::make_shared>(); - auto fsink = std::make_shared("log", "txt", 1024*1024*50 , 5, 10); - auto as = std::make_shared(1000); + 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"); - logger my_logger("my_logger", fsink); + //console->info() << "This is variadic ", " func, ", 123 << " YES"; + FFLOG_TRACE(console, "This is ", 1); - auto start = system_clock::now(); - for (unsigned int i = 1; i <= howmany; ++i) - my_logger.info() << "Hello logger: msg #" << i; + file->info("Hello file log"); + rotating->info("Hello rotating log"); + daily->info("Hello daily log"); + //multi sink logger: file + console + auto sink1= std::make_shared(); + auto sink2 = std::make_shared("rotating", "txt"); + c11log::logger combined("combined", { sink1, sink2 }); - auto delta = system_clock::now() - start; - auto delta_d = duration_cast> (delta).count(); - - cout << "Total:" << format(howmany) << endl; - cout << "Delta:" << format(delta_d) << endl; - cout << "Rate:" << format(howmany / delta_d) << "/sec" << endl; - - return 0; }