clang format

This commit is contained in:
gabime 2023-09-09 12:56:47 +03:00
parent 8014d6c31a
commit a98d3ab0c7
4 changed files with 25 additions and 19 deletions

View File

@ -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)

View File

@ -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<char> 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

View File

@ -71,7 +71,7 @@ template<typename Mutex>
class qt_color_sink : public base_sink<Mutex>
{
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<int>(msg.color_range_start);
color_range_end = static_cast<int>(msg.color_range_end);
if (is_utf8_) {
if (is_utf8_)
{
payload = QString::fromUtf8(str.data(), static_cast<int>(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<int>(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<logger> qt_logger_st(const std::string &logger_name, QObj
// log to QTextEdit with colorize output
template<typename Factory = spdlog::synchronous_factory>
inline std::shared_ptr<logger> qt_color_logger_mt(const std::string &logger_name, QTextEdit *qt_text_edit, int max_lines, bool is_utf8 = false)
inline std::shared_ptr<logger> qt_color_logger_mt(
const std::string &logger_name, QTextEdit *qt_text_edit, int max_lines, bool is_utf8 = false)
{
return Factory::template create<sinks::qt_color_sink_mt>(logger_name, qt_text_edit, max_lines, false, is_utf8);
}
template<typename Factory = spdlog::synchronous_factory>
inline std::shared_ptr<logger> qt_color_logger_st(const std::string &logger_name, QTextEdit *qt_text_edit, int max_lines, bool is_utf8 = false)
inline std::shared_ptr<logger> qt_color_logger_st(
const std::string &logger_name, QTextEdit *qt_text_edit, int max_lines, bool is_utf8 = false)
{
return Factory::template create<sinks::qt_color_sink_st>(logger_name, qt_text_edit, max_lines, false, is_utf8);
}

View File

@ -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)