diff --git a/include/spdlog/async_logger.h b/include/spdlog/async_logger.h index c6a69f48..7ddcca25 100644 --- a/include/spdlog/async_logger.h +++ b/include/spdlog/async_logger.h @@ -39,7 +39,7 @@ public: const It& begin, const It& end, size_t queue_size, - const async_overflow_policy overflow_policy = async_overflow_policy::block_retry, + const async_overflow_policy overflow_policy = async_overflow_policy::block_retry, const std::function& worker_warmup_cb = nullptr, const std::chrono::milliseconds& flush_interval_ms = std::chrono::milliseconds::zero(), const std::function& worker_teardown_cb = nullptr); @@ -55,7 +55,7 @@ public: async_logger(const std::string& name, sink_ptr single_sink, size_t queue_size, - const async_overflow_policy overflow_policy = async_overflow_policy::block_retry, + const async_overflow_policy overflow_policy = async_overflow_policy::block_retry, const std::function& worker_warmup_cb = nullptr, const std::chrono::milliseconds& flush_interval_ms = std::chrono::milliseconds::zero(), const std::function& worker_teardown_cb = nullptr); @@ -78,5 +78,4 @@ private: }; } - #include "details/async_logger_impl.h" diff --git a/include/spdlog/common.h b/include/spdlog/common.h index 3a691b34..cbdf5f56 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -87,7 +87,7 @@ enum level_enum }; #if !defined(SPDLOG_LEVEL_NAMES) -#define SPDLOG_LEVEL_NAMES { "trace", "debug", "info", "warning", "error", "critical", "off" } +#define SPDLOG_LEVEL_NAMES { "trace", "debug", "info", "warning", "error", "critical", "off" } #endif static const char* level_names[] SPDLOG_LEVEL_NAMES; diff --git a/include/spdlog/details/async_log_helper.h b/include/spdlog/details/async_log_helper.h index d63eebfd..b39b2c10 100644 --- a/include/spdlog/details/async_log_helper.h +++ b/include/spdlog/details/async_log_helper.h @@ -136,6 +136,9 @@ public: // stop logging and join the back thread ~async_log_helper(); + async_log_helper(const async_log_helper&) = delete; + async_log_helper& operator=(const async_log_helper&) = delete; + void set_formatter(formatter_ptr); void flush(bool wait_for_q); @@ -155,7 +158,6 @@ private: bool _terminate_requested; - // overflow policy const async_overflow_policy _overflow_policy; diff --git a/include/spdlog/details/async_logger_impl.h b/include/spdlog/details/async_logger_impl.h index dabc729b..9f2b2283 100644 --- a/include/spdlog/details/async_logger_impl.h +++ b/include/spdlog/details/async_logger_impl.h @@ -21,7 +21,7 @@ inline spdlog::async_logger::async_logger(const std::string& name, const It& begin, const It& end, size_t queue_size, - const async_overflow_policy overflow_policy, + const async_overflow_policy overflow_policy, const std::function& worker_warmup_cb, const std::chrono::milliseconds& flush_interval_ms, const std::function& worker_teardown_cb) : @@ -33,7 +33,7 @@ inline spdlog::async_logger::async_logger(const std::string& name, inline spdlog::async_logger::async_logger(const std::string& name, sinks_init_list sinks, size_t queue_size, - const async_overflow_policy overflow_policy, + const async_overflow_policy overflow_policy, const std::function& worker_warmup_cb, const std::chrono::milliseconds& flush_interval_ms, const std::function& worker_teardown_cb) : @@ -42,7 +42,7 @@ inline spdlog::async_logger::async_logger(const std::string& name, inline spdlog::async_logger::async_logger(const std::string& name, sink_ptr single_sink, size_t queue_size, - const async_overflow_policy overflow_policy, + const async_overflow_policy overflow_policy, const std::function& worker_warmup_cb, const std::chrono::milliseconds& flush_interval_ms, const std::function& worker_teardown_cb) : diff --git a/include/spdlog/details/log_msg.h b/include/spdlog/details/log_msg.h index 8d39a010..8b441cab 100644 --- a/include/spdlog/details/log_msg.h +++ b/include/spdlog/details/log_msg.h @@ -31,7 +31,7 @@ struct log_msg #endif } - log_msg(const log_msg& other) = delete; + log_msg(const log_msg& other) = delete; log_msg& operator=(log_msg&& other) = delete; log_msg(log_msg&& other) = delete; diff --git a/include/spdlog/details/logger_impl.h b/include/spdlog/details/logger_impl.h index ff62417d..0ff1773b 100644 --- a/include/spdlog/details/logger_impl.h +++ b/include/spdlog/details/logger_impl.h @@ -21,7 +21,7 @@ inline spdlog::logger::logger(std::string name, const It& begin, const It& end): _level(level::info), _flush_level(level::off), _last_err_time(0), - _msg_counter(1) // message counter will start from 1. 0-message id will be reserved for controll messages + _msg_counter(1) // message counter will start from 1. 0-message id will be reserved for controll messages { _err_handler = [this](const std::string &msg) { @@ -349,7 +349,7 @@ inline void spdlog::logger::_default_err_handler(const std::string &msg) auto tm_time = details::os::localtime(now); char date_buf[100]; std::strftime(date_buf, sizeof(date_buf), "%Y-%m-%d %H:%M:%S", &tm_time); - details::log_msg err_msg; + details::log_msg err_msg; err_msg.formatted.write("[*** LOG ERROR ***] [{}] [{}] [{}]{}", name(), msg, date_buf, details::os::default_eol); sinks::stderr_sink_mt::instance()->log(err_msg); _last_err_time = now; diff --git a/include/spdlog/details/os.h b/include/spdlog/details/os.h index 6cc42d45..7f8d524f 100644 --- a/include/spdlog/details/os.h +++ b/include/spdlog/details/os.h @@ -331,12 +331,12 @@ inline int utc_minutes_offset(const std::tm& tm = details::os::localtime()) inline size_t _thread_id() { #ifdef _WIN32 - return static_cast(::GetCurrentThreadId()); + return static_cast(::GetCurrentThreadId()); #elif __linux__ # if defined(__ANDROID__) && defined(__ANDROID_API__) && (__ANDROID_API__ < 21) # define SYS_gettid __NR_gettid # endif - return static_cast(syscall(SYS_gettid)); + return static_cast(syscall(SYS_gettid)); #elif __FreeBSD__ long tid; thr_self(&tid); diff --git a/include/spdlog/details/pattern_formatter_impl.h b/include/spdlog/details/pattern_formatter_impl.h index dbe07f42..32e7d60d 100644 --- a/include/spdlog/details/pattern_formatter_impl.h +++ b/include/spdlog/details/pattern_formatter_impl.h @@ -36,7 +36,7 @@ public: /////////////////////////////////////////////////////////////////////// namespace { -class name_formatter:public flag_formatter +class name_formatter : public flag_formatter { void format(details::log_msg& msg, const std::tm&) override { @@ -46,7 +46,7 @@ class name_formatter:public flag_formatter } // log level appender -class level_formatter:public flag_formatter +class level_formatter : public flag_formatter { void format(details::log_msg& msg, const std::tm&) override { @@ -55,7 +55,7 @@ class level_formatter:public flag_formatter }; // short log level appender -class short_level_formatter:public flag_formatter +class short_level_formatter : public flag_formatter { void format(details::log_msg& msg, const std::tm&) override { @@ -79,7 +79,7 @@ static int to12h(const tm& t) //Abbreviated weekday name static const std::string days[] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; -class a_formatter:public flag_formatter +class a_formatter : public flag_formatter { void format(details::log_msg& msg, const std::tm& tm_time) override { @@ -89,7 +89,7 @@ class a_formatter:public flag_formatter //Full weekday name static const std::string full_days[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; -class A_formatter:public flag_formatter +class A_formatter : public flag_formatter { void format(details::log_msg& msg, const std::tm& tm_time) override { @@ -98,8 +98,8 @@ class A_formatter:public flag_formatter }; //Abbreviated month -static const std::string months[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" }; -class b_formatter:public flag_formatter +static const std::string months[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec" }; +class b_formatter : public flag_formatter { void format(details::log_msg& msg, const std::tm& tm_time) override { @@ -109,7 +109,7 @@ class b_formatter:public flag_formatter //Full month name static const std::string full_months[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; -class B_formatter:public flag_formatter +class B_formatter : public flag_formatter { void format(details::log_msg& msg, const std::tm& tm_time) override { @@ -186,7 +186,7 @@ class d_formatter SPDLOG_FINAL : public flag_formatter } }; -// hours in 24 format 0-23 +// hours in 24 format 0-23 class H_formatter SPDLOG_FINAL : public flag_formatter { void format(details::log_msg& msg, const std::tm& tm_time) override @@ -195,7 +195,7 @@ class H_formatter SPDLOG_FINAL : public flag_formatter } }; -// hours in 12 format 1-12 +// hours in 12 format 1-12 class I_formatter SPDLOG_FINAL : public flag_formatter { void format(details::log_msg& msg, const std::tm& tm_time) override diff --git a/include/spdlog/details/registry.h b/include/spdlog/details/registry.h index 07881ae0..6bd8bb2d 100644 --- a/include/spdlog/details/registry.h +++ b/include/spdlog/details/registry.h @@ -214,9 +214,9 @@ private: bool _async_mode = false; size_t _async_q_size = 0; async_overflow_policy _overflow_policy = async_overflow_policy::block_retry; - std::function _worker_warmup_cb = nullptr; - std::chrono::milliseconds _flush_interval_ms{ 0 }; - std::function _worker_teardown_cb = nullptr; + std::function _worker_warmup_cb; + std::chrono::milliseconds _flush_interval_ms; + std::function _worker_teardown_cb; }; #ifdef SPDLOG_NO_REGISTRY_MUTEX diff --git a/include/spdlog/sinks/base_sink.h b/include/spdlog/sinks/base_sink.h index 63d67445..1d975892 100644 --- a/include/spdlog/sinks/base_sink.h +++ b/include/spdlog/sinks/base_sink.h @@ -25,7 +25,7 @@ template class base_sink : public sink { public: - base_sink():_mutex() {} + base_sink() = default; base_sink(const base_sink&) = delete; base_sink& operator=(const base_sink&) = delete; diff --git a/include/spdlog/sinks/sink.h b/include/spdlog/sinks/sink.h index 770a2d30..ff7a144e 100644 --- a/include/spdlog/sinks/sink.h +++ b/include/spdlog/sinks/sink.h @@ -15,6 +15,7 @@ class sink { public: virtual ~sink() = default; + virtual void log(const details::log_msg& msg) = 0; virtual void flush() = 0; diff --git a/include/spdlog/sinks/wincolor_sink.h b/include/spdlog/sinks/wincolor_sink.h index 0ceb172a..3b4495b0 100644 --- a/include/spdlog/sinks/wincolor_sink.h +++ b/include/spdlog/sinks/wincolor_sink.h @@ -22,7 +22,7 @@ namespace sinks * Windows color console sink. Uses WriteConsoleA to write to the console with colors */ template -class wincolor_sink : public base_sink +class wincolor_sink : public base_sink { public: const WORD BOLD = FOREGROUND_INTENSITY; @@ -50,7 +50,7 @@ public: wincolor_sink(const wincolor_sink& other) = delete; wincolor_sink& operator=(const wincolor_sink& other) = delete; - // change the color for the given level + // change the color for the given level void set_color(level::level_enum level, WORD color) { std::lock_guard lock(base_sink::_mutex); diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h index 8bfffd01..076833d0 100644 --- a/include/spdlog/spdlog.h +++ b/include/spdlog/spdlog.h @@ -56,7 +56,7 @@ void set_error_handler(log_err_handler); // // async_overflow_policy (optional, block_retry by default): // async_overflow_policy::block_retry - if queue is full, block until queue has room for the new log entry. -// async_overflow_policy::discard_log_msg - never block and discard any new messages when queue overflows. +// async_overflow_policy::discard_log_msg - never block and discard any new messages when queue overflows. // // worker_warmup_cb (optional): // callback function that will be called in worker thread upon start (can be used to init stuff like thread affinity) @@ -84,7 +84,7 @@ std::shared_ptr rotating_logger_mt(const std::string& logger_name, const std::shared_ptr rotating_logger_st(const std::string& logger_name, const filename_t& filename, size_t max_file_size, size_t max_files); // -// Create file logger which creates new file on the given time (default in midnight): +// Create file logger which creates new file on the given time (default in midnight): // std::shared_ptr daily_logger_mt(const std::string& logger_name, const filename_t& filename, int hour=0, int minute=0); std::shared_ptr daily_logger_st(const std::string& logger_name, const filename_t& filename, int hour=0, int minute=0); diff --git a/include/spdlog/tweakme.h b/include/spdlog/tweakme.h index ad01a09c..c5509622 100644 --- a/include/spdlog/tweakme.h +++ b/include/spdlog/tweakme.h @@ -54,7 +54,7 @@ /////////////////////////////////////////////////////////////////////////////// // Uncomment if logger name logging is not needed. -// This will prevent spdlog from copying the logger name on each log call. +// This will prevent spdlog from copying the logger name on each log call. // // #define SPDLOG_NO_NAME /////////////////////////////////////////////////////////////////////////////// @@ -156,5 +156,5 @@ /////////////////////////////////////////////////////////////////////////////// // Uncomment to customize level names (e.g. "MT TRACE") // -// #define SPDLOG_LEVEL_NAMES { "MY TRACE", "MY DEBUG", "MY INFO", "MY WARNING", "MY ERROR", "MY CRITICAL", "OFF" } +// #define SPDLOG_LEVEL_NAMES { "MY TRACE", "MY DEBUG", "MY INFO", "MY WARNING", "MY ERROR", "MY CRITICAL", "OFF" } ///////////////////////////////////////////////////////////////////////////////