mirror of
https://github.com/gabime/spdlog.git
synced 2025-04-30 12:23:53 +00:00
clang format
This commit is contained in:
parent
8014d6c31a
commit
a98d3ab0c7
@ -342,7 +342,8 @@ if(SPDLOG_INSTALL)
|
|||||||
# ---------------------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------------------
|
||||||
# Install CMake config files
|
# 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})
|
install(EXPORT spdlog DESTINATION ${export_dest_dir} NAMESPACE spdlog:: FILE ${config_targets_file})
|
||||||
|
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
|
@ -31,7 +31,6 @@ void replace_default_logger_example();
|
|||||||
#include "spdlog/cfg/env.h" // support for loading levels from the environment variable
|
#include "spdlog/cfg/env.h" // support for loading levels from the environment variable
|
||||||
#include "spdlog/fmt/ostr.h" // support for user defined types
|
#include "spdlog/fmt/ostr.h" // support for user defined types
|
||||||
|
|
||||||
|
|
||||||
int main(int, char *[])
|
int main(int, char *[])
|
||||||
{
|
{
|
||||||
// Log levels can be loaded from argv/env using "SPDLOG_LEVEL"
|
// 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.
|
// {:n} - don't split the output to lines.
|
||||||
|
|
||||||
#if !defined SPDLOG_USE_STD_FORMAT || defined(_MSC_VER)
|
#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()
|
void binary_example()
|
||||||
{
|
{
|
||||||
std::vector<char> buf(80);
|
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));
|
// logger->info("hexdump style, 20 chars per line {:a}", spdlog::to_hex(buf, 20));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void binary_example() {
|
void binary_example()
|
||||||
|
{
|
||||||
// not supported with std::format yet
|
// not supported with std::format yet
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -71,7 +71,7 @@ template<typename Mutex>
|
|||||||
class qt_color_sink : public base_sink<Mutex>
|
class qt_color_sink : public base_sink<Mutex>
|
||||||
{
|
{
|
||||||
public:
|
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)
|
: qt_text_edit_(qt_text_edit)
|
||||||
, max_lines_(max_lines)
|
, max_lines_(max_lines)
|
||||||
, is_utf8_(is_utf8)
|
, is_utf8_(is_utf8)
|
||||||
@ -167,24 +167,28 @@ protected:
|
|||||||
int color_range_start, color_range_end;
|
int color_range_start, color_range_end;
|
||||||
color_range_start = static_cast<int>(msg.color_range_start);
|
color_range_start = static_cast<int>(msg.color_range_start);
|
||||||
color_range_end = static_cast<int>(msg.color_range_end);
|
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()));
|
payload = QString::fromUtf8(str.data(), static_cast<int>(str.size()));
|
||||||
// convert color ranges from byte index to character index.
|
// 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_start = QString::fromUtf8(str.data(), msg.color_range_start).size();
|
||||||
color_range_end = QString::fromUtf8(str.data(), msg.color_range_end).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()));
|
payload = QString::fromLatin1(str.data(), static_cast<int>(str.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
invoke_params params{max_lines_, // max lines
|
invoke_params params{max_lines_, // max lines
|
||||||
qt_text_edit_, // text edit to append to
|
qt_text_edit_, // text edit to append to
|
||||||
std::move(payload), // text to append
|
std::move(payload), // text to append
|
||||||
default_color_, // default color
|
default_color_, // default color
|
||||||
colors_.at(msg.level), // color to apply
|
colors_.at(msg.level), // color to apply
|
||||||
color_range_start, // color range start
|
color_range_start, // color range start
|
||||||
color_range_end}; // color range end
|
color_range_end}; // color range end
|
||||||
|
|
||||||
QMetaObject::invokeMethod(
|
QMetaObject::invokeMethod(
|
||||||
qt_text_edit_, [params]() { invoke_method_(params); }, Qt::AutoConnection);
|
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
|
// log to QTextEdit with colorize output
|
||||||
template<typename Factory = spdlog::synchronous_factory>
|
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);
|
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>
|
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);
|
return Factory::template create<sinks::qt_color_sink_st>(logger_name, qt_text_edit, max_lines, false, is_utf8);
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,7 @@ set(SPDLOG_UTESTS_SOURCES
|
|||||||
test_cfg.cpp
|
test_cfg.cpp
|
||||||
test_time_point.cpp
|
test_time_point.cpp
|
||||||
test_stopwatch.cpp
|
test_stopwatch.cpp
|
||||||
test_circular_q.cpp
|
test_circular_q.cpp)
|
||||||
)
|
|
||||||
|
|
||||||
if(NOT SPDLOG_NO_EXCEPTIONS)
|
if(NOT SPDLOG_NO_EXCEPTIONS)
|
||||||
list(APPEND SPDLOG_UTESTS_SOURCES test_errors.cpp)
|
list(APPEND SPDLOG_UTESTS_SOURCES test_errors.cpp)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user