Commit 3a1ac8b4 authored by gabime's avatar gabime

async_sink fixes

parent 7cbf6dcb
...@@ -25,7 +25,7 @@ int main(int argc, char* argv[]) ...@@ -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[]) ...@@ -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();
......
...@@ -68,8 +68,8 @@ inline c11log::sinks::async_sink::~async_sink() ...@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment