From 418381623e4d664d712fda46fb469e64adc559d4 Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Sun, 16 Nov 2014 20:43:30 +0200 Subject: [PATCH 01/16] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c0970e24..cb6c0c4e 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,9 @@ Just copy the files to your build tree and use a C++11 compiler * Rotating log files * Daily log files * Console logging +* Linux syslog * Optional async logging +* Add your own custom logging targets easily (just implement the single function in the sink interface) * Logging levels * Custom formatting with user defined patterns From f8063b4c5794808a632c1ab91bcaf8811f89ffe5 Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Sun, 16 Nov 2014 21:00:01 +0200 Subject: [PATCH 02/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cb6c0c4e..d21d7138 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Just copy the files to your build tree and use a C++11 compiler * Console logging * Linux syslog * Optional async logging -* Add your own custom logging targets easily (just implement the single function in the sink interface) +* Add custom log targets easily (just implement the single function in the [sink](include/spdlog/sinks/sink.h) interface) * Logging levels * Custom formatting with user defined patterns From 28c5134857fd0781cee8fac5f084c5d545f39cf5 Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Sun, 16 Nov 2014 21:01:25 +0200 Subject: [PATCH 03/16] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d21d7138..01265645 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Just copy the files to your build tree and use a C++11 compiler * Very fast - performance is the primary goal (see becnhmarks below) * Headers only * No dependencies +* Simple to use, simple to understand, simple to hack or extend * Cross platform - Linux / Windows on 32/64 bits * Multi/Single threaded loggers * Rotating log files @@ -24,7 +25,7 @@ Just copy the files to your build tree and use a C++11 compiler * Console logging * Linux syslog * Optional async logging -* Add custom log targets easily (just implement the single function in the [sink](include/spdlog/sinks/sink.h) interface) +* Add custom log targets easily (just implement a single function in the [sink](include/spdlog/sinks/sink.h) interface) * Logging levels * Custom formatting with user defined patterns From 7d30a72b9a363fbc63bacc0220210f90fe64c1ca Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Sun, 16 Nov 2014 21:04:26 +0200 Subject: [PATCH 04/16] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 01265645..8a9be79e 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,6 @@ Just copy the files to your build tree and use a C++11 compiler * Very fast - performance is the primary goal (see becnhmarks below) * Headers only * No dependencies -* Simple to use, simple to understand, simple to hack or extend * Cross platform - Linux / Windows on 32/64 bits * Multi/Single threaded loggers * Rotating log files @@ -25,7 +24,7 @@ Just copy the files to your build tree and use a C++11 compiler * Console logging * Linux syslog * Optional async logging -* Add custom log targets easily (just implement a single function in the [sink](include/spdlog/sinks/sink.h) interface) +* Extend with custom log targets easily (just implement a single function in the [sink](include/spdlog/sinks/sink.h) interface) * Logging levels * Custom formatting with user defined patterns From ac5568db63555e05e132dfd1bcdab6f8dcbcbe05 Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Sun, 16 Nov 2014 21:07:01 +0200 Subject: [PATCH 05/16] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8a9be79e..ebf74b08 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,11 @@ Just copy the files to your build tree and use a C++11 compiler * Console logging * Linux syslog * Optional async logging +* Custom formatting +* Runtime logging levels * Extend with custom log targets easily (just implement a single function in the [sink](include/spdlog/sinks/sink.h) interface) -* Logging levels -* Custom formatting with user defined patterns + + ## Benchmarks From 1f4de31c4c5de1191580e61c3fe4bafe03549c79 Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Sun, 16 Nov 2014 22:55:13 +0200 Subject: [PATCH 06/16] Update file_helper.h Removed unneeded include --- include/spdlog/details/file_helper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/spdlog/details/file_helper.h b/include/spdlog/details/file_helper.h index f6aa5a3e..c98e4390 100644 --- a/include/spdlog/details/file_helper.h +++ b/include/spdlog/details/file_helper.h @@ -32,7 +32,7 @@ #include #include #include -#include + #include "os.h" From d8396e1f838afa312532cbb5cdf247c44c9facf9 Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Sun, 16 Nov 2014 22:56:29 +0200 Subject: [PATCH 07/16] Update file_helper.h --- include/spdlog/details/file_helper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/spdlog/details/file_helper.h b/include/spdlog/details/file_helper.h index c98e4390..f6aa5a3e 100644 --- a/include/spdlog/details/file_helper.h +++ b/include/spdlog/details/file_helper.h @@ -32,7 +32,7 @@ #include #include #include - +#include #include "os.h" From 59013b3504ddf5bdaa065b63e5eb9937dedfec38 Mon Sep 17 00:00:00 2001 From: gabime Date: Mon, 17 Nov 2014 01:07:45 +0200 Subject: [PATCH 08/16] async_sink to use queue of pointers of log_msgs - faster than moving.. --- include/spdlog/sinks/async_sink.h | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/include/spdlog/sinks/async_sink.h b/include/spdlog/sinks/async_sink.h index 89b4696a..f3b170d7 100644 --- a/include/spdlog/sinks/async_sink.h +++ b/include/spdlog/sinks/async_sink.h @@ -53,7 +53,7 @@ namespace sinks class async_sink : public base_sink < details::null_mutex > { public: - using q_type = details::blocking_queue < details::log_msg > ; + using q_type = details::blocking_queue < std::unique_ptr > ; explicit async_sink(const q_type::size_type max_queue_size); @@ -64,15 +64,19 @@ public: q_type& q(); //Wait to remaining items (if any) in the queue to be written and shutdown void shutdown(const std::chrono::milliseconds& timeout); + void set_formatter(formatter_ptr formatter) { _formatter = formatter; } + protected: void _sink_it(const details::log_msg& msg) override; - void _thread_loop(); + + private: - std::vector> _sinks; + void _thread_loop(); + std::vector> _sinks; std::atomic _active; q_type _q; std::thread _back_thread; @@ -80,7 +84,8 @@ private: //Last exception thrown from the back thread std::shared_ptr _last_backthread_ex; - + //formatter + formatter_ptr _formatter; //will throw last back thread exception or if backthread no active void _push_sentry(); @@ -108,8 +113,11 @@ inline spdlog::sinks::async_sink::~async_sink() inline void spdlog::sinks::async_sink::_sink_it(const details::log_msg& msg) { - _push_sentry(); - _q.push(msg); + using namespace spdlog::details; + _push_sentry(); + //_q.push(std::move(msg)); + auto msg_p = std::unique_ptr(new log_msg(msg)); + _q.push(std::move(msg_p)); } @@ -123,12 +131,13 @@ inline void spdlog::sinks::async_sink::_thread_loop() if (_q.pop(msg, pop_timeout)) { if (!_active) - return; + return; + _formatter->format(*msg); for (auto &s : _sinks) { try { - s->log(msg); + s->log(*msg); } catch (const std::exception& ex) From 91fae223cc905bb7ad9c9917601584cfb956b925 Mon Sep 17 00:00:00 2001 From: gabime Date: Mon, 17 Nov 2014 01:12:50 +0200 Subject: [PATCH 09/16] async_sink to use queue of pointers of log_msgs - faster than moving.. --- include/spdlog/sinks/async_sink.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/spdlog/sinks/async_sink.h b/include/spdlog/sinks/async_sink.h index f3b170d7..5ec6b2b8 100644 --- a/include/spdlog/sinks/async_sink.h +++ b/include/spdlog/sinks/async_sink.h @@ -115,9 +115,7 @@ inline void spdlog::sinks::async_sink::_sink_it(const details::log_msg& msg) { using namespace spdlog::details; _push_sentry(); - //_q.push(std::move(msg)); - auto msg_p = std::unique_ptr(new log_msg(msg)); - _q.push(std::move(msg_p)); + _q.push(std::unique_ptr(new log_msg(msg))); } From 61b471e2ba4ee07ab6389770e305dfa3fdc23495 Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Mon, 17 Nov 2014 18:43:28 +0200 Subject: [PATCH 10/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ebf74b08..0fde11eb 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Just copy the files to your build tree and use a C++11 compiler * Console logging * Linux syslog * Optional async logging -* Custom formatting +* [Custom](wiki/Custom-formatting) formatting * Runtime logging levels * Extend with custom log targets easily (just implement a single function in the [sink](include/spdlog/sinks/sink.h) interface) From 8a0118bd40a446fd8fad9b3e3b7ff701a8db6831 Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Mon, 17 Nov 2014 18:45:09 +0200 Subject: [PATCH 11/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0fde11eb..1e9a702b 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Just copy the files to your build tree and use a C++11 compiler * Console logging * Linux syslog * Optional async logging -* [Custom](wiki/Custom-formatting) formatting +* [Custom](https://github.com/gabime/spdlog/wiki/Custom-formatting) formatting * Runtime logging levels * Extend with custom log targets easily (just implement a single function in the [sink](include/spdlog/sinks/sink.h) interface) From 00f35e1aba47589000e514cc405524a513c705d9 Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Tue, 18 Nov 2014 16:35:53 +0200 Subject: [PATCH 12/16] Update README.md --- README.md | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 1e9a702b..3ddfd670 100644 --- a/README.md +++ b/README.md @@ -14,19 +14,21 @@ Just copy the files to your build tree and use a C++11 compiler * mingw with g++ 4.9.x ##Features -* Very fast - performance is the primary goal (see becnhmarks below) -* Headers only -* No dependencies -* Cross platform - Linux / Windows on 32/64 bits -* Multi/Single threaded loggers -* Rotating log files -* Daily log files -* Console logging -* Linux syslog -* Optional async logging -* [Custom](https://github.com/gabime/spdlog/wiki/Custom-formatting) formatting -* Runtime logging levels -* Extend with custom log targets easily (just implement a single function in the [sink](include/spdlog/sinks/sink.h) interface) +* Very fast - performance is the primary goal (see becnhmarks below). +* Headers only. +* No dependencies. +* Cross platform - Linux / Windows on 32/64 bits. +* Multi/Single threaded loggers. +* Various log targets: + * Rotating log files. + * Daily log files. + * Console logging. + * Linux syslog. + * Easily extendable with custom log targets (just implement a single function in the [sink](include/spdlog/sinks/sink.h) interface). +* Optional async logging . +* [Custom](https://github.com/gabime/spdlog/wiki/Custom-formatting) formatting. +* Log levels. + From 12ce505794e7a0e31f5d4d8b9e92cfc4b352b3eb Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Tue, 18 Nov 2014 16:36:42 +0200 Subject: [PATCH 13/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ddfd670..cddc506d 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Just copy the files to your build tree and use a C++11 compiler * Headers only. * No dependencies. * Cross platform - Linux / Windows on 32/64 bits. +* [Custom](https://github.com/gabime/spdlog/wiki/Custom-formatting) formatting. * Multi/Single threaded loggers. * Various log targets: * Rotating log files. @@ -26,7 +27,6 @@ Just copy the files to your build tree and use a C++11 compiler * Linux syslog. * Easily extendable with custom log targets (just implement a single function in the [sink](include/spdlog/sinks/sink.h) interface). * Optional async logging . -* [Custom](https://github.com/gabime/spdlog/wiki/Custom-formatting) formatting. * Log levels. From 2a8b03d839cbb42b7b23bb662c45db2e8ae8f19f Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Thu, 20 Nov 2014 11:28:51 +0200 Subject: [PATCH 14/16] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index cddc506d..d964ab97 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Just copy the files to your build tree and use a C++11 compiler * Headers only. * No dependencies. * Cross platform - Linux / Windows on 32/64 bits. +* Variadic-template/stream call styles: ```logger.info("variadic", x, y, z) << " Or stream" << x << y << z;``` * [Custom](https://github.com/gabime/spdlog/wiki/Custom-formatting) formatting. * Multi/Single threaded loggers. * Various log targets: From c77e20296aabdc176121858359440ae70a6a3dc2 Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Thu, 20 Nov 2014 22:07:24 +0200 Subject: [PATCH 15/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d964ab97..73ee2bf6 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Just copy the files to your build tree and use a C++11 compiler * Headers only. * No dependencies. * Cross platform - Linux / Windows on 32/64 bits. -* Variadic-template/stream call styles: ```logger.info("variadic", x, y, z) << " Or stream" << x << y << z;``` +* Variadic-template/stream call styles: ```logger.info("variadic", x, y) << " Or stream" << x << y;``` * [Custom](https://github.com/gabime/spdlog/wiki/Custom-formatting) formatting. * Multi/Single threaded loggers. * Various log targets: From 3f5f26441b101bbb833c3fd59f9f917df72b1b73 Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Thu, 20 Nov 2014 22:08:14 +0200 Subject: [PATCH 16/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 73ee2bf6..ebcf93ba 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Just copy the files to your build tree and use a C++11 compiler * Headers only. * No dependencies. * Cross platform - Linux / Windows on 32/64 bits. -* Variadic-template/stream call styles: ```logger.info("variadic", x, y) << " Or stream" << x << y;``` +* Variadic-template/stream call styles: ```logger.info("variadic", x, y) << "or stream" << x << y;``` * [Custom](https://github.com/gabime/spdlog/wiki/Custom-formatting) formatting. * Multi/Single threaded loggers. * Various log targets: