From e5f4790407c62b6eb12052b7e62b382ea2d6dabe Mon Sep 17 00:00:00 2001 From: gabi Date: Sun, 26 Oct 2014 01:52:37 +0200 Subject: [PATCH] Bug fixes --- example/bench.cpp | 8 ++++---- include/c11log/details/logger_impl.h | 3 ++- include/c11log/details/os.h | 2 +- include/c11log/details/pattern_formatter_impl.h | 6 +----- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/example/bench.cpp b/example/bench.cpp index b0c401bd..7bbaeb06 100644 --- a/example/bench.cpp +++ b/example/bench.cpp @@ -24,14 +24,14 @@ int main(int argc, char* argv[]) console->set_level(c11log::level::INFO); console->info("Starting bench with", howmany, "iterations.."); - //auto bench = c11log::create("bench", "myrotating", "txt", 1024 * 1024 * 5, 3, 0); - auto bench = c11log::create("bench", "sdfsfddaily", "txt", 0); + auto bench = c11log::create("bench", "myrotating", "txt", 1024 * 1024 * 5, 3, 0); + //auto bench = c11log::create("bench", "simplelog.txt", 1); //auto bench = c11log::create("bench"); auto start = system_clock::now(); - for (unsigned int i = 1; i <= howmany; ++i) + for (unsigned int i = 0; i < howmany; ++i) { - c11log::get("bench")->info("Hello logger: msg number", i); + bench->info("Hello logger: msg number") << i; } auto delta = system_clock::now() - start; diff --git a/include/c11log/details/logger_impl.h b/include/c11log/details/logger_impl.h index 03474c5d..156b0872 100644 --- a/include/c11log/details/logger_impl.h +++ b/include/c11log/details/logger_impl.h @@ -115,8 +115,9 @@ void c11log::logger::_variadic_log(c11log::details::line_logger& l, const First& inline void c11log::logger::_log_msg(details::log_msg& msg) { + //Use default formatter if not set if (!_formatter) - _formatter = std::make_shared("%+ %t"); + _formatter = std::make_shared("%+"); _formatter->format(msg); for (auto &sink : _sinks) sink->log(msg); diff --git a/include/c11log/details/os.h b/include/c11log/details/os.h index 5bf38faa..a9067a07 100644 --- a/include/c11log/details/os.h +++ b/include/c11log/details/os.h @@ -93,7 +93,7 @@ constexpr inline unsigned short eol_size() #endif //fopen_s on non windows for writing -inline bool fopen_s(FILE** fp, const std::string& filename, const char* mode) +inline int fopen_s(FILE** fp, const std::string& filename, const char* mode) { #ifdef _WIN32 return ::fopen_s(fp, filename.c_str(), mode); diff --git a/include/c11log/details/pattern_formatter_impl.h b/include/c11log/details/pattern_formatter_impl.h index cdcf9401..7c74e485 100644 --- a/include/c11log/details/pattern_formatter_impl.h +++ b/include/c11log/details/pattern_formatter_impl.h @@ -366,11 +366,7 @@ class full_formatter :public flag_formatter auto millis = std::chrono::duration_cast(duration).count() % 1000; msg.formatted.put_int(static_cast(millis), 3); msg.formatted.putc(']'); - msg.formatted << " ["; - msg.formatted << msg.logger_name; - msg.formatted << "] ["; - msg.formatted << level::to_str(msg.level); - msg.formatted << "] "; + msg.formatted << " [" << msg.logger_name << "] [" << level::to_str(msg.level) << "] "; msg.formatted.put_fast_oss(msg.raw); }