diff --git a/example/example.cpp b/example/example.cpp index df72c907..e9e57f83 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -25,7 +25,7 @@ int main(int argc, char* argv[]) //auto fsink = std::make_shared("log", "txt", 1024*1024*50 , 5, 0); - auto as = std::make_shared(howmany); + auto as = std::make_shared(1000); as->add_sink(sinks::null_sink::get()); logger my_logger ("my_logger", as); @@ -33,7 +33,7 @@ int main(int argc, char* argv[]) for(unsigned int i = 0; i < howmany ; i++) my_logger.info() << "Hello logger"; - + as->shutdown(milliseconds(5000)); auto delta = system_clock::now() - start; auto delta_d = duration_cast> (delta).count(); diff --git a/include/c11log/sinks/async_sink.h b/include/c11log/sinks/async_sink.h index f84e845e..61f932d0 100644 --- a/include/c11log/sinks/async_sink.h +++ b/include/c11log/sinks/async_sink.h @@ -68,8 +68,8 @@ inline c11log::sinks::async_sink::~async_sink() } inline void c11log::sinks::async_sink::_sink_it(const details::log_msg& msg) { - auto msg_size = msg.msg_buf.second; - if(!msg_size) + auto msg_size = msg.msg_buf.second; + if(!_active || !msg_size) return; //re allocate on the heap the (stack based) message auto new_msg = new details::log_msg();