diff --git a/include/spdlog/logger-inl.h b/include/spdlog/logger-inl.h index 9f125dcc..4eb8b820 100644 --- a/include/spdlog/logger-inl.h +++ b/include/spdlog/logger-inl.h @@ -205,7 +205,6 @@ SPDLOG_INLINE bool logger::should_flush_(const details::log_msg &msg) return (msg.level >= flush_level) && (msg.level != level::off); } - SPDLOG_INLINE void logger::err_handler_(const std::string &msg) { @@ -222,7 +221,7 @@ SPDLOG_INLINE void logger::err_handler_(const std::string &msg) std::lock_guard lk{mutex}; auto now = system_clock::now(); err_counter++; - if(now - last_report_time < std::chrono::seconds(1)) + if (now - last_report_time < std::chrono::seconds(1)) { return; } diff --git a/include/spdlog/logger.h b/include/spdlog/logger.h index af121b76..8d991e58 100644 --- a/include/spdlog/logger.h +++ b/include/spdlog/logger.h @@ -24,9 +24,15 @@ #include -#define SPDLOG_LOGGER_CATCH() \ -catch (const std::exception &ex) { err_handler_(ex.what());} \ -catch (...) {err_handler_("Unknown exception in logger");} +#define SPDLOG_LOGGER_CATCH() \ + catch (const std::exception &ex) \ + { \ + err_handler_(ex.what()); \ + } \ + catch (...) \ + { \ + err_handler_("Unknown exception in logger"); \ + } namespace spdlog { class logger diff --git a/include/spdlog/sinks/stdout_sinks.h b/include/spdlog/sinks/stdout_sinks.h index 0a93146c..04d2fa42 100644 --- a/include/spdlog/sinks/stdout_sinks.h +++ b/include/spdlog/sinks/stdout_sinks.h @@ -71,8 +71,6 @@ std::shared_ptr stderr_logger_st(const std::string &logger_name); } // namespace spdlog - - #ifdef SPDLOG_HEADER_ONLY #include "stdout_sinks-inl.h" #endif diff --git a/include/spdlog/sinks/wincolor_sink-inl.h b/include/spdlog/sinks/wincolor_sink-inl.h index bfaf54ee..84cd1754 100644 --- a/include/spdlog/sinks/wincolor_sink-inl.h +++ b/include/spdlog/sinks/wincolor_sink-inl.h @@ -68,8 +68,8 @@ void SPDLOG_INLINE wincolor_sink::log(const details::log_msg &msg) // in color range auto orig_attribs = set_foreground_color_(colors_[msg.level]); print_range_(formatted, msg.color_range_start, msg.color_range_end); - // reset to orig colors - ::SetConsoleTextAttribute(out_handle_, orig_attribs); + // reset to orig colors + ::SetConsoleTextAttribute(out_handle_, orig_attribs); print_range_(formatted, msg.color_range_end, formatted.size()); } else // print without colors if color range is invalid (or color is disabled) @@ -149,12 +149,12 @@ void SPDLOG_INLINE wincolor_sink::write_to_file_(const fmt::memory DWORD total_written = 0; do { - DWORD bytes_written = 0; - bool ok = ::WriteFile(out_handle_, formatted.data()+total_written, size-total_written, &bytes_written, nullptr) != 0; + DWORD bytes_written = 0; + bool ok = ::WriteFile(out_handle_, formatted.data() + total_written, size - total_written, &bytes_written, nullptr) != 0; if (!ok || bytes_written == 0) { throw spdlog_ex("wincolor_sink: write_to_file_ failed. GetLastError(): " + std::to_string(::GetLastError())); - } + } total_written += bytes_written; } while (total_written < size); } diff --git a/src/spdlog.cpp b/src/spdlog.cpp index fe16f1cc..be91412d 100644 --- a/src/spdlog.cpp +++ b/src/spdlog.cpp @@ -80,8 +80,6 @@ template std::shared_ptr spdlog::stdout_color_st spdlog::stderr_color_mt(const std::string &logger_name, color_mode mode); template std::shared_ptr spdlog::stderr_color_st(const std::string &logger_name, color_mode mode); - - #include "spdlog/sinks/stdout_sinks-inl.h" template class spdlog::sinks::stdout_sink_base; @@ -101,7 +99,6 @@ template std::shared_ptr spdlog::stdout_logger_st spdlog::stderr_logger_mt(const std::string &logger_name); template std::shared_ptr spdlog::stderr_logger_st(const std::string &logger_name); - // Slightly modified version of fmt lib's format.cc source file. // Copyright (c) 2012 - 2016, Victor Zverovich // All rights reserved.