From 391bd396ef4a45a3ad271a658de38611b38ddda5 Mon Sep 17 00:00:00 2001 From: gabime Date: Tue, 14 Oct 2014 04:56:10 +0300 Subject: [PATCH] fixed gcc bugs and warnings --- example/bench.cpp | 5 ++-- include/c11log/details/fast_oss.h | 4 ++-- include/c11log/details/pattern_formatter.h | 6 ++--- include/c11log/logger.h | 27 +++++++++++----------- include/c11log/sinks/async_sink.h | 12 +++++----- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/example/bench.cpp b/example/bench.cpp index 9ae162ea..f3e19d7e 100644 --- a/example/bench.cpp +++ b/example/bench.cpp @@ -2,7 +2,6 @@ // #include #include "c11log/logger.h" -#include "c11log/pattern_formatter.h" #include "c11log/sinks/async_sink.h" #include "c11log/sinks/file_sinks.h" #include "c11log/sinks/stdout_sinks.h" @@ -21,7 +20,7 @@ int main(int argc, char* argv[]) const unsigned int howmany = argc <= 1 ? 500000 : atoi(argv[1]); std::string pattern = "%Y:%m:%d %H:%M:%S.%e [%n:%l] %t"; - auto formatter1 = std::unique_ptr(new pattern_formatter(pattern)); + auto formatter1 = std::unique_ptr(new details::pattern_formatter(pattern)); logger cout_logger("bench", std::make_shared() , std::move(formatter1)); cout_logger.info() << "Hello logger"; @@ -30,7 +29,7 @@ int main(int argc, char* argv[]) auto rotating = std::make_shared("myrotating", "txt", 1024 * 1024 * 5, 5, 100); - auto formatter2 = std::unique_ptr(new pattern_formatter(pattern)); + auto formatter2 = std::unique_ptr(new details::pattern_formatter(pattern)); logger my_logger("my_logger", rotating, std::move(formatter2)); auto start = system_clock::now(); diff --git a/include/c11log/details/fast_oss.h b/include/c11log/details/fast_oss.h index 2b67159e..121f0310 100644 --- a/include/c11log/details/fast_oss.h +++ b/include/c11log/details/fast_oss.h @@ -122,9 +122,9 @@ public: //_dev.sputn(buf, width); } - void put_str(const std::string& str) + void put_str(const std::string& s) { - _dev.sputn(str.data(), str.size()); + _dev.sputn(s.data(), s.size()); } diff --git a/include/c11log/details/pattern_formatter.h b/include/c11log/details/pattern_formatter.h index cc7d43c1..22041d80 100644 --- a/include/c11log/details/pattern_formatter.h +++ b/include/c11log/details/pattern_formatter.h @@ -138,7 +138,7 @@ class ch_appender :public pattern_appender public: explicit ch_appender(char ch) : _ch(ch) {} - void append(const details::log_msg& msg, details::fast_oss& oss) override + void append(const details::log_msg&, details::fast_oss& oss) override { oss.putc(_ch); } @@ -156,7 +156,7 @@ public: { _str += ch; } - void append(const details::log_msg& msg, details::fast_oss& oss) override + void append(const details::log_msg&, details::fast_oss& oss) override { oss << _str; } @@ -280,4 +280,4 @@ inline void c11log::details::pattern_formatter::format(details::log_msg& msg) } oss.write(details::os::eol(), details::os::eol_size()); msg.formatted = oss.str(); -} \ No newline at end of file +} diff --git a/include/c11log/logger.h b/include/c11log/logger.h index 0059fd67..abf523f8 100644 --- a/include/c11log/logger.h +++ b/include/c11log/logger.h @@ -14,7 +14,8 @@ #include "sinks/base_sink.h" #include "common.h" -#include "pattern_formatter.h" +#include "formatter.h" +#include "details/pattern_formatter.h" namespace c11log { @@ -97,29 +98,29 @@ private: #include "details/line_logger.h" -inline c11log::logger::logger(const std::string& name, sinks_init_list sinks_list, formatter_ptr f) : - _name(name), +inline c11log::logger::logger(const std::string& logger_name, sinks_init_list sinks_list, formatter_ptr f) : + _name(logger_name), _formatter(std::move(f)), _sinks(sinks_list) { //Seems that vs2013 doesn't support std::atomic member initialization yet _level = level::INFO; if(!_formatter) - _formatter = std::make_unique("%t"); + _formatter = formatter_ptr(new details::pattern_formatter("%t")); } template -inline c11log::logger::logger(const std::string& name, It begin, It end, formatter_ptr f): - _name(name), +inline c11log::logger::logger(const std::string& logger_name, It begin, It end, formatter_ptr f): + _name(logger_name), _formatter(std::move(f)), _sinks(begin, end) { } -inline c11log::logger::logger(const std::string& name, sink_ptr sink, formatter_ptr f) : - logger(name, {sink}, std::move(f)) {} +inline c11log::logger::logger(const std::string& logger_name, sink_ptr sink, formatter_ptr f) : + logger(logger_name, {sink}, std::move(f)) {} template @@ -163,9 +164,9 @@ inline const std::string& c11log::logger::name() const return _name; } -inline void c11log::logger::level(c11log::level::level_enum level) +inline void c11log::logger::level(c11log::level::level_enum log_level) { - _level.store(level); + _level.store(log_level); } inline c11log::level::level_enum c11log::logger::level() const @@ -173,13 +174,13 @@ inline c11log::level::level_enum c11log::logger::level() const return static_cast(_level.load()); } -inline bool c11log::logger::should_log(c11log::level::level_enum level) const +inline bool c11log::logger::should_log(c11log::level::level_enum msg_level) const { - return level >= _level.load(); + return msg_level >= _level.load(); } -inline void c11log::logger::_variadic_log(c11log::details::line_logger& l) {} +inline void c11log::logger::_variadic_log(c11log::details::line_logger&) {} template void c11log::logger::_variadic_log(c11log::details::line_logger& l, const First& first, const Rest&... rest) diff --git a/include/c11log/sinks/async_sink.h b/include/c11log/sinks/async_sink.h index 9648fc0d..8860f88d 100644 --- a/include/c11log/sinks/async_sink.h +++ b/include/c11log/sinks/async_sink.h @@ -80,9 +80,9 @@ inline void c11log::sinks::async_sink::_thread_loop() q_type::item_type msg; if (_q.pop(msg, pop_timeout)) { - for (auto &sink : _sinks) + for (auto &s : _sinks) { - sink->log(msg); + s->log(msg); if(!_active) break; } @@ -90,17 +90,17 @@ inline void c11log::sinks::async_sink::_thread_loop() } } -inline void c11log::sinks::async_sink::add_sink(logger::sink_ptr sink) +inline void c11log::sinks::async_sink::add_sink(logger::sink_ptr s) { std::lock_guard guard(_mutex); - _sinks.push_back(sink); + _sinks.push_back(s); } -inline void c11log::sinks::async_sink::remove_sink(logger::sink_ptr sink) +inline void c11log::sinks::async_sink::remove_sink(logger::sink_ptr s) { std::lock_guard guard(_mutex); - _sinks.erase(std::remove(_sinks.begin(), _sinks.end(), sink), _sinks.end()); + _sinks.erase(std::remove(_sinks.begin(), _sinks.end(), s), _sinks.end()); }