diff --git a/include/spdlog/common.h b/include/spdlog/common.h index 630f3fab..6b494efe 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -44,6 +44,10 @@ //#define SPDLOG_CLOCK_COARSE //#endif + +// uncomment if thread id logging is needed - to gain few nanos +// #define SPDLOG_NO_THREAD_ID +// namespace spdlog { diff --git a/include/spdlog/details/line_logger.h b/include/spdlog/details/line_logger.h index 37c7786a..d037554f 100644 --- a/include/spdlog/details/line_logger.h +++ b/include/spdlog/details/line_logger.h @@ -65,8 +65,6 @@ public: _log_msg.logger_name = _callback_logger->name(); _log_msg.time = os::now(); _log_msg.thread_id = os::thread_id(); - - _callback_logger->_log_msg(_log_msg); } } diff --git a/include/spdlog/details/os.h b/include/spdlog/details/os.h index 5de99085..8b073cd4 100644 --- a/include/spdlog/details/os.h +++ b/include/spdlog/details/os.h @@ -175,6 +175,10 @@ inline int utc_minutes_offset(const std::tm& tm = details::os::localtime()) inline size_t thread_id() { +#ifdef SPDLOG_NO_THREAD_ID + return 0; +#else + #ifdef _WIN32 return ::GetCurrentThreadId(); #elif __linux__ @@ -182,7 +186,7 @@ inline size_t thread_id() #else return (uint64_t) pthread_self(); #endif - +#endif //SPDLOG_NO_THREAD_ID } } //os