From 98476e229ab683cc4f0d9cbddbc9224b78a6a1b5 Mon Sep 17 00:00:00 2001 From: gabime Date: Mon, 31 Mar 2014 01:12:49 +0300 Subject: [PATCH] line_logger fixes --- include/c11log/details/line_logger.h | 3 ++- include/c11log/logger.h | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/c11log/details/line_logger.h b/include/c11log/details/line_logger.h index f4c7ca9c..8344c4dc 100644 --- a/include/c11log/details/line_logger.h +++ b/include/c11log/details/line_logger.h @@ -48,7 +48,8 @@ public: _enabled(other._enabled) {} ~line_logger() - { + { + //only if enabled and not empty if (!_empty) { _oss << os::eol(); diff --git a/include/c11log/logger.h b/include/c11log/logger.h index fa75aa49..9a3b8876 100644 --- a/include/c11log/logger.h +++ b/include/c11log/logger.h @@ -65,7 +65,7 @@ private: std::string _logger_name; formatter_ptr _formatter; sinks_vector_t _sinks; - std::atomic_int _logger_level; + std::atomic_int _level_threshold; void _log_it(const details::log_msg& msg); @@ -87,7 +87,7 @@ inline c11log::logger::logger(const std::string& name, sinks_init_list sinks_lis _sinks(sinks_list) { //Seems that vs2013 doesnt support std::atomic member initialization, so its done here - _logger_level = level::INFO; + _level_threshold = level::INFO; if(!_formatter) _formatter = std::make_shared(); } @@ -99,7 +99,7 @@ inline c11log::logger::logger(const std::string& name, sink_ptr sink, formatter_ inline c11log::details::line_logger c11log::logger::log(c11log::level::level_enum msg_level) { - return details::line_logger(this, msg_level, msg_level >= _logger_level); + return details::line_logger(this, msg_level, msg_level >= _level_threshold); } inline c11log::details::line_logger c11log::logger::debug() @@ -137,17 +137,17 @@ inline const std::string& c11log::logger::get_name() const inline void c11log::logger::set_level(c11log::level::level_enum level) { - _logger_level.store(level); + _level_threshold.store(level); } inline c11log::level::level_enum c11log::logger::get_level() const { - return static_cast(_logger_level.load()); + return static_cast(_level_threshold.load()); } inline bool c11log::logger::should_log(c11log::level::level_enum level) const { - return level >= _logger_level.load(); + return level >= _level_threshold.load(); } inline void c11log::logger::_log_it(const details::log_msg& msg)