log_msg refactoring and raw message support

This commit is contained in:
gabi
2014-05-09 15:27:06 +03:00
parent bafea6a6b2
commit 497d511746
9 changed files with 106 additions and 102 deletions

View File

@@ -69,8 +69,8 @@ inline c11log::sinks::async_sink::~async_sink()
inline void c11log::sinks::async_sink::_sink_it(const details::log_msg& msg)
{
if(!_active || msg.str.empty())
{
if(!_active || msg.formatted.empty())
return;
_q.push(msg);
}

View File

@@ -23,7 +23,7 @@ protected:
virtual void _sink_it(const details::log_msg& msg) override
{
std::lock_guard<std::mutex> lock(_mutex);
_ostream << msg.str;
_ostream << msg.formatted;
}
std::ostream& _ostream;

View File

@@ -8,6 +8,7 @@
#include "../details/flush_helper.h"
#include "../details/blocking_queue.h"
namespace c11log
{
namespace sinks
@@ -31,7 +32,7 @@ protected:
void _sink_it(const details::log_msg& msg) override
{
std::lock_guard<std::mutex> lock(_mutex);
_flush_helper.write(msg.str, _ofstream);
_flush_helper.write(msg.formatted, _ofstream);
}
private:
std::mutex _mutex;
@@ -65,13 +66,13 @@ protected:
{
std::lock_guard<std::mutex> lock(_mutex);
_current_size += msg.str.size();
_current_size += msg.formatted.size();
if (_current_size > _max_size)
{
_rotate();
_current_size = msg.str.size();
_current_size = msg.formatted.size();
}
_flush_helper.write(msg.str, _ofstream);
_flush_helper.write(msg.formatted, _ofstream);
}
@@ -104,7 +105,7 @@ private:
std::remove(target.c_str());
std::rename(src.c_str(), target.c_str());
}
_ofstream.open(_calc_filename(_base_filename, 0, _extension));
_ofstream.open(_calc_filename(_base_filename, 0, _extension), std::ofstream::binary);
}
std::string _base_filename;
std::string _extension;
@@ -144,7 +145,7 @@ protected:
_ofstream.open(_calc_filename(_base_filename, _extension));
_midnight_tp = _calc_midnight_tp();
}
_flush_helper.write(msg.str, _ofstream);
_flush_helper.write(msg.formatted, _ofstream);
}
private: