fixed gcc bugs and warnings

This commit is contained in:
gabime 2014-10-14 04:56:10 +03:00
parent ef330729cb
commit 391bd396ef
5 changed files with 27 additions and 27 deletions

View File

@ -2,7 +2,6 @@
//
#include <mutex>
#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<formatter>(new pattern_formatter(pattern));
auto formatter1 = std::unique_ptr<formatter>(new details::pattern_formatter(pattern));
logger cout_logger("bench", std::make_shared<sinks::stderr_sink_mt>() , std::move(formatter1));
cout_logger.info() << "Hello logger";
@ -30,7 +29,7 @@ int main(int argc, char* argv[])
auto rotating = std::make_shared<sinks::rotating_file_sink_mt>("myrotating", "txt", 1024 * 1024 * 5, 5, 100);
auto formatter2 = std::unique_ptr<formatter>(new pattern_formatter(pattern));
auto formatter2 = std::unique_ptr<formatter>(new details::pattern_formatter(pattern));
logger my_logger("my_logger", rotating, std::move(formatter2));
auto start = system_clock::now();

View File

@ -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());
}

View File

@ -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();
}
}

View File

@ -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<pattern_formatter>("%t");
_formatter = formatter_ptr(new details::pattern_formatter("%t"));
}
template<class It>
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 <typename... Args>
@ -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<c11log::level::level_enum>(_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 <typename First, typename... Rest>
void c11log::logger::_variadic_log(c11log::details::line_logger& l, const First& first, const Rest&... rest)

View File

@ -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<std::mutex> 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<std::mutex> guard(_mutex);
_sinks.erase(std::remove(_sinks.begin(), _sinks.end(), sink), _sinks.end());
_sinks.erase(std::remove(_sinks.begin(), _sinks.end(), s), _sinks.end());
}