diff --git a/include/spdlog/details/line_logger.h b/include/spdlog/details/line_logger.h index 7cb2d1d1..3343a164 100644 --- a/include/spdlog/details/line_logger.h +++ b/include/spdlog/details/line_logger.h @@ -23,7 +23,7 @@ /*************************************************************************/ #pragma once - +#include #include "../common.h" #include "../logger.h" #ifdef SPDLOG_CLOCK_COARSE @@ -70,11 +70,11 @@ public: #ifndef SPDLOG_CLOCK_COARSE _log_msg.time = log_clock::now(); #else - timespec ts; - ::clock_gettime(CLOCK_REALTIME_COARSE, &ts); - _log_msg.time = std::chrono::time_point( - std::chrono::duration_cast( - std::chrono::seconds(ts.tv_sec) + std::chrono::nanoseconds(ts.tv_nsec))); + timespec ts; + ::clock_gettime(CLOCK_REALTIME_COARSE, &ts); + _log_msg.time = std::chrono::time_point( + std::chrono::duration_cast( + std::chrono::seconds(ts.tv_sec) + std::chrono::nanoseconds(ts.tv_nsec))); #endif _callback_logger->_log_msg(_log_msg); } @@ -96,18 +96,85 @@ public: } } - void write(const char* what) { if (_enabled) _log_msg.raw << what; } + void write(const std::string& what) + { + if (_enabled) + _log_msg.raw << what; + } + + void write(int what) + { + if (_enabled) + _log_msg.raw << what; + } + + void write(unsigned int what) + { + if (_enabled) + _log_msg.raw << what; + } + + + void write(long what) + { + if (_enabled) + _log_msg.raw << what; + } + + void write(unsigned long what) + { + if (_enabled) + _log_msg.raw << what; + } + + void write(long long what) + { + if (_enabled) + _log_msg.raw << what; + } + + void write(unsigned long long what) + { + if (_enabled) + _log_msg.raw << what; + } + + void write(double what) + { + if (_enabled) + _log_msg.raw << what; + } + + void write(long double what) + { + if (_enabled) + _log_msg.raw << what; + } + + void write(float what) + { + if (_enabled) + _log_msg.raw << what; + } + + void write(char what) + { + if (_enabled) + _log_msg.raw << what; + } + + template line_logger& operator<<(const T& what) { if (_enabled) - _log_msg.raw << what; + _log_msg.raw.write("{}", what); return *this; }