Refactored message counter a little
This commit is contained in:
		@@ -87,6 +87,9 @@ inline void spdlog::async_logger::_sink_it(details::log_msg& msg)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    try
 | 
					    try
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
 | 
				
			||||||
 | 
							msg.msg_id = _msg_counter.fetch_add(1, std::memory_order_relaxed);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
        _async_log_helper->log(msg);
 | 
					        _async_log_helper->log(msg);
 | 
				
			||||||
        if (_should_flush_on(msg))
 | 
					        if (_should_flush_on(msg))
 | 
				
			||||||
            _async_log_helper->flush(false); // do async flush
 | 
					            _async_log_helper->flush(false); // do async flush
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -68,11 +68,6 @@ inline void spdlog::logger::log(level::level_enum lvl, const char* fmt, const Ar
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        details::log_msg log_msg(&_name, lvl);
 | 
					        details::log_msg log_msg(&_name, lvl);
 | 
				
			||||||
        log_msg.raw.write(fmt, args...);
 | 
					        log_msg.raw.write(fmt, args...);
 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
 | 
					 | 
				
			||||||
        log_msg.msg_id = _msg_counter.fetch_add(1, std::memory_order_relaxed);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        _sink_it(log_msg);
 | 
					        _sink_it(log_msg);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    catch (const std::exception &ex)
 | 
					    catch (const std::exception &ex)
 | 
				
			||||||
@@ -93,11 +88,6 @@ inline void spdlog::logger::log(level::level_enum lvl, const char* msg)
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        details::log_msg log_msg(&_name, lvl);
 | 
					        details::log_msg log_msg(&_name, lvl);
 | 
				
			||||||
        log_msg.raw << msg;
 | 
					        log_msg.raw << msg;
 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
 | 
					 | 
				
			||||||
        log_msg.msg_id = _msg_counter.fetch_add(1, std::memory_order_relaxed);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        _sink_it(log_msg);
 | 
					        _sink_it(log_msg);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    catch (const std::exception &ex)
 | 
					    catch (const std::exception &ex)
 | 
				
			||||||
@@ -119,9 +109,6 @@ inline void spdlog::logger::log(level::level_enum lvl, const T& msg)
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        details::log_msg log_msg(&_name, lvl);
 | 
					        details::log_msg log_msg(&_name, lvl);
 | 
				
			||||||
        log_msg.raw << msg;
 | 
					        log_msg.raw << msg;
 | 
				
			||||||
#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
 | 
					 | 
				
			||||||
        log_msg.msg_id = _msg_counter.fetch_add(1, std::memory_order_relaxed);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
        _sink_it(log_msg);
 | 
					        _sink_it(log_msg);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    catch (const std::exception &ex)
 | 
					    catch (const std::exception &ex)
 | 
				
			||||||
@@ -313,6 +300,9 @@ inline bool spdlog::logger::should_log(spdlog::level::level_enum msg_level) cons
 | 
				
			|||||||
//
 | 
					//
 | 
				
			||||||
inline void spdlog::logger::_sink_it(details::log_msg& msg)
 | 
					inline void spdlog::logger::_sink_it(details::log_msg& msg)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
 | 
				
			||||||
 | 
						msg.msg_id = _msg_counter.fetch_add(1, std::memory_order_relaxed);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
    _formatter->format(msg);
 | 
					    _formatter->format(msg);
 | 
				
			||||||
    for (auto &sink : _sinks)
 | 
					    for (auto &sink : _sinks)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user