diff --git a/example/bench.cpp b/example/bench.cpp index 3a4f438e..94ca7dc3 100644 --- a/example/bench.cpp +++ b/example/bench.cpp @@ -37,9 +37,9 @@ int main(int argc, char* argv[]) 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; + cout_logger.info("Total:") << format(howmany); + cout_logger.info("Delta:") << format(delta_d); + cout_logger.info("Rate:") << format(howmany / delta_d) << "/sec"; return 0; } diff --git a/example/example.cpp b/example/example.cpp index 465dd630..c00f868e 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -9,7 +9,7 @@ #include "c11log/sinks/file_sinks.h" using namespace std; -int main2(int, char* []) +int main(int, char* []) { auto console = c11log::factory::stdout_logger(); diff --git a/include/c11log/details/fast_oss.h b/include/c11log/details/fast_oss.h index 4dd21030..448a82ad 100644 --- a/include/c11log/details/fast_oss.h +++ b/include/c11log/details/fast_oss.h @@ -89,9 +89,9 @@ public: std::string str() { - auto buf = _dev.buf(); - const char*data = buf.data(); - return std::string(data, data+buf.size()); + auto buffer = _dev.buf(); + const char*data = buffer.data(); + return std::string(data, data+buffer.size()); } const stack_devicebuf::stackbuf_t& buf() const @@ -133,11 +133,11 @@ public: void write_fast_oss(const fast_oss& oss) { - auto buf = oss.buf(); - _dev.sputn(buf.data(), buf.size()); + auto buffer = oss.buf(); + _dev.sputn(buffer.data(), buffer.size()); } - - + + private: stack_devicebuf _dev; }; diff --git a/include/c11log/details/stack_buf.h b/include/c11log/details/stack_buf.h index 0629daee..d0f01dc5 100644 --- a/include/c11log/details/stack_buf.h +++ b/include/c11log/details/stack_buf.h @@ -3,6 +3,7 @@ #include #include #include +#include // Fast memory storage on the stack when possible or in std::vector diff --git a/include/c11log/logger.h b/include/c11log/logger.h index 69a22b88..194f670b 100644 --- a/include/c11log/logger.h +++ b/include/c11log/logger.h @@ -29,7 +29,7 @@ class logger { public: using sink_ptr = std::shared_ptr; - using formatter_ptr = std::shared_ptr; + using formatter_ptr = std::shared_ptr; logger(const std::string& name, std::initializer_list, formatter_ptr formatter = nullptr); template @@ -93,12 +93,12 @@ private: #include "details/line_logger.h" -inline c11log::logger::logger(const std::string& logger_name, std::initializer_list sinks_list, formatter_ptr formatter) : +inline c11log::logger::logger(const std::string& logger_name, std::initializer_list sinks_list, formatter_ptr msg_formatter) : _name(logger_name), - _formatter(formatter), + _formatter(msg_formatter), _sinks(sinks_list) { - if (!formatter) //default formatter + if (!msg_formatter) //default formatter _formatter = std::make_shared(_default_pattern); // no support under vs2013 for member initialization for std::atomic @@ -169,10 +169,9 @@ inline bool c11log::logger::should_log(c11log::level::level_enum msg_level) cons return msg_level >= _level.load(); } - -inline void c11log::logger::formatter(formatter_ptr formatter) +inline void c11log::logger::formatter(formatter_ptr msg_formatter) { - _formatter = formatter; + _formatter = msg_formatter; } inline c11log::logger::formatter_ptr c11log::logger::formatter() const