async_sink fixes

This commit is contained in:
gabime 2014-03-29 13:28:50 +03:00
parent 7cbf6dcbf7
commit 3a1ac8b4d6
2 changed files with 4 additions and 4 deletions

View File

@ -25,7 +25,7 @@ int main(int argc, char* argv[])
//auto fsink = std::make_shared<sinks::rotating_file_sink>("log", "txt", 1024*1024*50 , 5, 0); //auto fsink = std::make_shared<sinks::rotating_file_sink>("log", "txt", 1024*1024*50 , 5, 0);
auto as = std::make_shared<sinks::async_sink>(howmany); auto as = std::make_shared<sinks::async_sink>(1000);
as->add_sink(sinks::null_sink::get()); as->add_sink(sinks::null_sink::get());
logger my_logger ("my_logger", as); logger my_logger ("my_logger", as);
@ -33,7 +33,7 @@ int main(int argc, char* argv[])
for(unsigned int i = 0; i < howmany ; i++) for(unsigned int i = 0; i < howmany ; i++)
my_logger.info() << "Hello logger"; my_logger.info() << "Hello logger";
as->shutdown(milliseconds(5000));
auto delta = system_clock::now() - start; auto delta = system_clock::now() - start;
auto delta_d = duration_cast<duration<double>> (delta).count(); auto delta_d = duration_cast<duration<double>> (delta).count();

View File

@ -68,8 +68,8 @@ inline c11log::sinks::async_sink::~async_sink()
} }
inline void c11log::sinks::async_sink::_sink_it(const details::log_msg& msg) inline void c11log::sinks::async_sink::_sink_it(const details::log_msg& msg)
{ {
auto msg_size = msg.msg_buf.second; auto msg_size = msg.msg_buf.second;
if(!msg_size) if(!_active || !msg_size)
return; return;
//re allocate on the heap the (stack based) message //re allocate on the heap the (stack based) message
auto new_msg = new details::log_msg(); auto new_msg = new details::log_msg();