diff --git a/CMakeLists.txt b/CMakeLists.txt index 18363a22..b2f6b61c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -342,7 +342,8 @@ if(SPDLOG_INSTALL) # --------------------------------------------------------------------------------------- # Install CMake config files # --------------------------------------------------------------------------------------- - export(TARGETS spdlog spdlog_header_only NAMESPACE spdlog:: FILE "${CMAKE_CURRENT_BINARY_DIR}/${config_targets_file}") + export(TARGETS spdlog spdlog_header_only NAMESPACE spdlog:: + FILE "${CMAKE_CURRENT_BINARY_DIR}/${config_targets_file}") install(EXPORT spdlog DESTINATION ${export_dest_dir} NAMESPACE spdlog:: FILE ${config_targets_file}) include(CMakePackageConfigHelpers) diff --git a/example/example.cpp b/example/example.cpp index d6609ed5..ba6a1fc3 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -31,7 +31,6 @@ void replace_default_logger_example(); #include "spdlog/cfg/env.h" // support for loading levels from the environment variable #include "spdlog/fmt/ostr.h" // support for user defined types - int main(int, char *[]) { // Log levels can be loaded from argv/env using "SPDLOG_LEVEL" @@ -185,7 +184,7 @@ void async_example() // {:n} - don't split the output to lines. #if !defined SPDLOG_USE_STD_FORMAT || defined(_MSC_VER) -#include "spdlog/fmt/bin_to_hex.h" +# include "spdlog/fmt/bin_to_hex.h" void binary_example() { std::vector buf(80); @@ -203,7 +202,8 @@ void binary_example() // logger->info("hexdump style, 20 chars per line {:a}", spdlog::to_hex(buf, 20)); } #else -void binary_example() { +void binary_example() +{ // not supported with std::format yet } #endif diff --git a/include/spdlog/sinks/qt_sinks.h b/include/spdlog/sinks/qt_sinks.h index b128d656..4931039b 100644 --- a/include/spdlog/sinks/qt_sinks.h +++ b/include/spdlog/sinks/qt_sinks.h @@ -71,7 +71,7 @@ template class qt_color_sink : public base_sink { public: - qt_color_sink(QTextEdit *qt_text_edit, int max_lines, bool dark_colors=false, bool is_utf8=false) + qt_color_sink(QTextEdit *qt_text_edit, int max_lines, bool dark_colors = false, bool is_utf8 = false) : qt_text_edit_(qt_text_edit) , max_lines_(max_lines) , is_utf8_(is_utf8) @@ -167,24 +167,28 @@ protected: int color_range_start, color_range_end; color_range_start = static_cast(msg.color_range_start); color_range_end = static_cast(msg.color_range_end); - if (is_utf8_) { + if (is_utf8_) + { payload = QString::fromUtf8(str.data(), static_cast(str.size())); // convert color ranges from byte index to character index. - if (msg.color_range_start < msg.color_range_end) { + if (msg.color_range_start < msg.color_range_end) + { color_range_start = QString::fromUtf8(str.data(), msg.color_range_start).size(); color_range_end = QString::fromUtf8(str.data(), msg.color_range_end).size(); } - } else { + } + else + { payload = QString::fromLatin1(str.data(), static_cast(str.size())); } - invoke_params params{max_lines_, // max lines - qt_text_edit_, // text edit to append to - std::move(payload), // text to append - default_color_, // default color - colors_.at(msg.level), // color to apply - color_range_start, // color range start - color_range_end}; // color range end + invoke_params params{max_lines_, // max lines + qt_text_edit_, // text edit to append to + std::move(payload), // text to append + default_color_, // default color + colors_.at(msg.level), // color to apply + color_range_start, // color range start + color_range_end}; // color range end QMetaObject::invokeMethod( qt_text_edit_, [params]() { invoke_method_(params); }, Qt::AutoConnection); @@ -293,13 +297,15 @@ inline std::shared_ptr qt_logger_st(const std::string &logger_name, QObj // log to QTextEdit with colorize output template -inline std::shared_ptr qt_color_logger_mt(const std::string &logger_name, QTextEdit *qt_text_edit, int max_lines, bool is_utf8 = false) +inline std::shared_ptr qt_color_logger_mt( + const std::string &logger_name, QTextEdit *qt_text_edit, int max_lines, bool is_utf8 = false) { return Factory::template create(logger_name, qt_text_edit, max_lines, false, is_utf8); } template -inline std::shared_ptr qt_color_logger_st(const std::string &logger_name, QTextEdit *qt_text_edit, int max_lines, bool is_utf8 = false) +inline std::shared_ptr qt_color_logger_st( + const std::string &logger_name, QTextEdit *qt_text_edit, int max_lines, bool is_utf8 = false) { return Factory::template create(logger_name, qt_text_edit, max_lines, false, is_utf8); } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f5dec032..63cced49 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -45,8 +45,7 @@ set(SPDLOG_UTESTS_SOURCES test_cfg.cpp test_time_point.cpp test_stopwatch.cpp - test_circular_q.cpp -) + test_circular_q.cpp) if(NOT SPDLOG_NO_EXCEPTIONS) list(APPEND SPDLOG_UTESTS_SOURCES test_errors.cpp)