mirror of
https://github.com/gabime/spdlog.git
synced 2025-04-29 20:13:52 +00:00
clang format
This commit is contained in:
parent
31cefdce79
commit
1f61f5e019
@ -185,7 +185,8 @@ target_include_directories(spdlog ${SPDLOG_INCLUDES_LEVEL} PUBLIC "$<BUILD_INTER
|
|||||||
target_link_libraries(spdlog PUBLIC Threads::Threads)
|
target_link_libraries(spdlog PUBLIC Threads::Threads)
|
||||||
spdlog_enable_warnings(spdlog)
|
spdlog_enable_warnings(spdlog)
|
||||||
|
|
||||||
set_target_properties(spdlog PROPERTIES VERSION ${SPDLOG_VERSION} SOVERSION ${SPDLOG_VERSION_MAJOR}.${SPDLOG_VERSION_MINOR})
|
set_target_properties(spdlog PROPERTIES VERSION ${SPDLOG_VERSION} SOVERSION
|
||||||
|
${SPDLOG_VERSION_MAJOR}.${SPDLOG_VERSION_MINOR})
|
||||||
set_target_properties(spdlog PROPERTIES DEBUG_POSTFIX d)
|
set_target_properties(spdlog PROPERTIES DEBUG_POSTFIX d)
|
||||||
|
|
||||||
if(COMMAND target_precompile_headers AND SPDLOG_ENABLE_PCH)
|
if(COMMAND target_precompile_headers AND SPDLOG_ENABLE_PCH)
|
||||||
@ -199,7 +200,8 @@ endif()
|
|||||||
add_library(spdlog_header_only INTERFACE)
|
add_library(spdlog_header_only INTERFACE)
|
||||||
add_library(spdlog::spdlog_header_only ALIAS spdlog_header_only)
|
add_library(spdlog::spdlog_header_only ALIAS spdlog_header_only)
|
||||||
|
|
||||||
target_include_directories(spdlog_header_only ${SPDLOG_INCLUDES_LEVEL} INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
|
target_include_directories(
|
||||||
|
spdlog_header_only ${SPDLOG_INCLUDES_LEVEL} INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
|
||||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||||
target_link_libraries(spdlog_header_only INTERFACE Threads::Threads)
|
target_link_libraries(spdlog_header_only INTERFACE Threads::Threads)
|
||||||
|
|
||||||
@ -342,15 +344,11 @@ if(SPDLOG_INSTALL)
|
|||||||
# ---------------------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------------------
|
||||||
# Install CMake config files
|
# Install CMake config files
|
||||||
# ---------------------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------------------
|
||||||
export(
|
export(TARGETS spdlog NAMESPACE spdlog:: FILE "${CMAKE_CURRENT_BINARY_DIR}/${config_targets_file}")
|
||||||
TARGETS spdlog
|
|
||||||
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)
|
||||||
configure_package_config_file("${project_config_in}" "${project_config_out}"
|
configure_package_config_file("${project_config_in}" "${project_config_out}" INSTALL_DESTINATION ${export_dest_dir})
|
||||||
INSTALL_DESTINATION ${export_dest_dir})
|
|
||||||
|
|
||||||
write_basic_package_version_file("${version_config_file}" COMPATIBILITY SameMajorVersion)
|
write_basic_package_version_file("${version_config_file}" COMPATIBILITY SameMajorVersion)
|
||||||
install(FILES "${project_config_out}" "${version_config_file}" DESTINATION "${export_dest_dir}")
|
install(FILES "${project_config_out}" "${version_config_file}" DESTINATION "${export_dest_dir}")
|
||||||
|
@ -116,9 +116,6 @@ int main(int argc, char *argv[])
|
|||||||
tracing_null_logger_st->enable_backtrace(64);
|
tracing_null_logger_st->enable_backtrace(64);
|
||||||
benchmark::RegisterBenchmark("null_sink_st/backtrace", bench_logger, tracing_null_logger_st);
|
benchmark::RegisterBenchmark("null_sink_st/backtrace", bench_logger, tracing_null_logger_st);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __linux
|
#ifdef __linux
|
||||||
bench_dev_null();
|
bench_dev_null();
|
||||||
#endif // __linux__
|
#endif // __linux__
|
||||||
|
@ -24,13 +24,8 @@ SPDLOG_INLINE spdlog::async_logger::async_logger(
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
// send the log message to the thread pool
|
// send the log message to the thread pool
|
||||||
SPDLOG_INLINE void spdlog::async_logger::sink_it_(const details::log_msg &msg)
|
SPDLOG_INLINE void spdlog::async_logger::sink_it_(const details::log_msg &msg){
|
||||||
{
|
SPDLOG_TRY{if (auto pool_ptr = thread_pool_.lock()){pool_ptr->post_log(shared_from_this(), msg, overflow_policy_);
|
||||||
SPDLOG_TRY
|
|
||||||
{
|
|
||||||
if (auto pool_ptr = thread_pool_.lock())
|
|
||||||
{
|
|
||||||
pool_ptr->post_log(shared_from_this(), msg, overflow_policy_);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -41,13 +36,8 @@ SPDLOG_INLINE void spdlog::async_logger::sink_it_(const details::log_msg &msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// send flush request to the thread pool
|
// send flush request to the thread pool
|
||||||
SPDLOG_INLINE void spdlog::async_logger::flush_()
|
SPDLOG_INLINE void spdlog::async_logger::flush_(){
|
||||||
{
|
SPDLOG_TRY{if (auto pool_ptr = thread_pool_.lock()){pool_ptr->post_flush(shared_from_this(), overflow_policy_);
|
||||||
SPDLOG_TRY
|
|
||||||
{
|
|
||||||
if (auto pool_ptr = thread_pool_.lock())
|
|
||||||
{
|
|
||||||
pool_ptr->post_flush(shared_from_this(), overflow_policy_);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -107,7 +107,8 @@
|
|||||||
# define SPDLOG_TRY try
|
# define SPDLOG_TRY try
|
||||||
# define SPDLOG_THROW(ex) throw(ex)
|
# define SPDLOG_THROW(ex) throw(ex)
|
||||||
# define SPDLOG_CATCH_STD \
|
# define SPDLOG_CATCH_STD \
|
||||||
catch (const std::exception &) {}
|
catch (const std::exception &) \
|
||||||
|
{}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace spdlog {
|
namespace spdlog {
|
||||||
|
@ -292,7 +292,8 @@ SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm)
|
|||||||
return offset;
|
return offset;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
# if defined(sun) || defined(__sun) || defined(_AIX) || (defined(__NEWLIB__) && !defined(__TM_GMTOFF)) || (!defined(_BSD_SOURCE) && !defined(_GNU_SOURCE))
|
# if defined(sun) || defined(__sun) || defined(_AIX) || (defined(__NEWLIB__) && !defined(__TM_GMTOFF)) || \
|
||||||
|
(!defined(_BSD_SOURCE) && !defined(_GNU_SOURCE))
|
||||||
// 'tm_gmtoff' field is BSD extension and it's missing on SunOS/Solaris
|
// 'tm_gmtoff' field is BSD extension and it's missing on SunOS/Solaris
|
||||||
struct helper
|
struct helper
|
||||||
{
|
{
|
||||||
@ -364,9 +365,12 @@ SPDLOG_INLINE size_t _thread_id() SPDLOG_NOEXCEPT
|
|||||||
# if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060) || defined(__POWERPC__)
|
# if (MAC_OS_X_VERSION_MAX_ALLOWED < 1060) || defined(__POWERPC__)
|
||||||
tid = pthread_mach_thread_np(pthread_self());
|
tid = pthread_mach_thread_np(pthread_self());
|
||||||
# elif MAC_OS_X_VERSION_MIN_REQUIRED < 1060
|
# elif MAC_OS_X_VERSION_MIN_REQUIRED < 1060
|
||||||
if (&pthread_threadid_np) {
|
if (&pthread_threadid_np)
|
||||||
|
{
|
||||||
pthread_threadid_np(nullptr, &tid);
|
pthread_threadid_np(nullptr, &tid);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
tid = pthread_mach_thread_np(pthread_self());
|
tid = pthread_mach_thread_np(pthread_self());
|
||||||
}
|
}
|
||||||
# else
|
# else
|
||||||
|
@ -394,8 +394,7 @@ protected:
|
|||||||
{
|
{
|
||||||
// format to wmemory_buffer and convert to utf8
|
// format to wmemory_buffer and convert to utf8
|
||||||
wmemory_buf_t wbuf;
|
wmemory_buf_t wbuf;
|
||||||
fmt_lib::vformat_to(
|
fmt_lib::vformat_to(std::back_inserter(wbuf), fmt, fmt_lib::make_format_args<fmt_lib::wformat_context>(args...));
|
||||||
std::back_inserter(wbuf), fmt, fmt_lib::make_format_args<fmt_lib::wformat_context>(args...));
|
|
||||||
|
|
||||||
memory_buf_t buf;
|
memory_buf_t buf;
|
||||||
details::os::wstr_to_utf8buf(wstring_view_t(wbuf.data(), wbuf.size()), buf);
|
details::os::wstr_to_utf8buf(wstring_view_t(wbuf.data(), wbuf.size()), buf);
|
||||||
|
@ -52,7 +52,7 @@ SPDLOG_INLINE void ansicolor_sink<ConsoleMutex>::log(const details::log_msg &msg
|
|||||||
// before color range
|
// before color range
|
||||||
print_range_(formatted, 0, msg.color_range_start);
|
print_range_(formatted, 0, msg.color_range_start);
|
||||||
// in color range
|
// in color range
|
||||||
print_ccode_(colors_[static_cast<size_t>(msg.level)]);
|
print_ccode_(colors_.at(static_cast<size_t>(msg.level)));
|
||||||
print_range_(formatted, msg.color_range_start, msg.color_range_end);
|
print_range_(formatted, msg.color_range_start, msg.color_range_end);
|
||||||
print_ccode_(reset);
|
print_ccode_(reset);
|
||||||
// after color range
|
// after color range
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
|
||||||
# include <spdlog/details/null_mutex.h>
|
# include <spdlog/details/null_mutex.h>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
// auto edit = new QTextEdit();
|
// auto edit = new QTextEdit();
|
||||||
// setCentralWidget(edit);
|
// setCentralWidget(edit);
|
||||||
// auto logger = spdlog::qt_color_logger_mt("my_logger", my_edit_widget);
|
// auto logger = spdlog::qt_color_logger_mt("my_logger", my_edit_widget);
|
||||||
|
//
|
||||||
// Warning: those sinks won't be notified if the target widget is destroyed.
|
// Warning: those sinks won't be notified if the target widget is destroyed.
|
||||||
// If the widget's lifetime can be shorter than the logger's one, you should provide some permanent QObject,
|
// If the widget's lifetime can be shorter than the logger's one, you should provide some permanent QObject,
|
||||||
// and then use a standard signal/slot.
|
// and then use a standard signal/slot.
|
||||||
@ -72,7 +72,6 @@ private:
|
|||||||
QMetaMethod meta_method_;
|
QMetaMethod meta_method_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// QT color sink to QTextEdit.
|
// QT color sink to QTextEdit.
|
||||||
// Color location is determined by the sink log pattern like in the rest of spdlog sinks.
|
// Color location is determined by the sink log pattern like in the rest of spdlog sinks.
|
||||||
// Colors can be modified if needed using sink->set_color(level, qtTextCharFormat).
|
// Colors can be modified if needed using sink->set_color(level, qtTextCharFormat).
|
||||||
@ -81,7 +80,8 @@ 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) : qt_text_edit_(qt_text_edit)
|
qt_color_sink(QTextEdit *qt_text_edit)
|
||||||
|
: qt_text_edit_(qt_text_edit)
|
||||||
{
|
{
|
||||||
if (!qt_text_edit_)
|
if (!qt_text_edit_)
|
||||||
{
|
{
|
||||||
@ -177,7 +177,6 @@ protected:
|
|||||||
QTextEdit *qt_text_edit_;
|
QTextEdit *qt_text_edit_;
|
||||||
QTextCharFormat default_color_;
|
QTextCharFormat default_color_;
|
||||||
std::array<QTextCharFormat, level::n_levels> colors_;
|
std::array<QTextCharFormat, level::n_levels> colors_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "spdlog/details/null_mutex.h"
|
#include "spdlog/details/null_mutex.h"
|
||||||
@ -194,13 +193,15 @@ using qt_color_sink_st = qt_color_sink<spdlog::details::null_mutex>;
|
|||||||
|
|
||||||
// create logger using QTextEdit object
|
// create logger using QTextEdit object
|
||||||
template<typename Factory = spdlog::synchronous_factory>
|
template<typename Factory = spdlog::synchronous_factory>
|
||||||
inline std::shared_ptr<logger> qt_logger_mt(const std::string &logger_name, QTextEdit *qt_object, const std::string &meta_method = "append(QString)")
|
inline std::shared_ptr<logger> qt_logger_mt(
|
||||||
|
const std::string &logger_name, QTextEdit *qt_object, const std::string &meta_method = "append(QString)")
|
||||||
{
|
{
|
||||||
return Factory::template create<sinks::qt_sink_mt>(logger_name, qt_object, meta_method);
|
return Factory::template create<sinks::qt_sink_mt>(logger_name, qt_object, meta_method);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Factory = spdlog::synchronous_factory>
|
template<typename Factory = spdlog::synchronous_factory>
|
||||||
inline std::shared_ptr<logger> qt_logger_st(const std::string &logger_name, QTextEdit *qt_object, const std::string &meta_method = "append(QString)")
|
inline std::shared_ptr<logger> qt_logger_st(
|
||||||
|
const std::string &logger_name, QTextEdit *qt_object, const std::string &meta_method = "append(QString)")
|
||||||
{
|
{
|
||||||
return Factory::template create<sinks::qt_sink_st>(logger_name, qt_object, meta_method);
|
return Factory::template create<sinks::qt_sink_st>(logger_name, qt_object, meta_method);
|
||||||
}
|
}
|
||||||
|
@ -241,12 +241,12 @@ protected:
|
|||||||
details::os::utf8_to_wstrbuf(string_view_t(formatted.data(), formatted.size()), buf);
|
details::os::utf8_to_wstrbuf(string_view_t(formatted.data(), formatted.size()), buf);
|
||||||
|
|
||||||
LPCWSTR lp_wstr = buf.data();
|
LPCWSTR lp_wstr = buf.data();
|
||||||
succeeded = static_cast<bool>(::ReportEventW(event_log_handle(), eventlog::get_event_type(msg), eventlog::get_event_category(msg), event_id_,
|
succeeded = static_cast<bool>(::ReportEventW(event_log_handle(), eventlog::get_event_type(msg), eventlog::get_event_category(msg),
|
||||||
current_user_sid_.as_sid(), 1, 0, &lp_wstr, nullptr));
|
event_id_, current_user_sid_.as_sid(), 1, 0, &lp_wstr, nullptr));
|
||||||
#else
|
#else
|
||||||
LPCSTR lp_str = formatted.data();
|
LPCSTR lp_str = formatted.data();
|
||||||
succeeded = static_cast<bool>(::ReportEventA(event_log_handle(), eventlog::get_event_type(msg), eventlog::get_event_category(msg), event_id_,
|
succeeded = static_cast<bool>(::ReportEventA(event_log_handle(), eventlog::get_event_type(msg), eventlog::get_event_category(msg),
|
||||||
current_user_sid_.as_sid(), 1, 0, &lp_str, nullptr));
|
event_id_, current_user_sid_.as_sid(), 1, 0, &lp_str, nullptr));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!succeeded)
|
if (!succeeded)
|
||||||
|
@ -19,11 +19,7 @@ if (Catch2_FOUND)
|
|||||||
else()
|
else()
|
||||||
message(STATUS "Bundled version of Catch will be downloaded and used.")
|
message(STATUS "Bundled version of Catch will be downloaded and used.")
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(Catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_TAG v3.3.2)
|
||||||
Catch2
|
|
||||||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
|
||||||
GIT_TAG v3.3.2
|
|
||||||
)
|
|
||||||
FetchContent_MakeAvailable(Catch2)
|
FetchContent_MakeAvailable(Catch2)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -21,7 +21,8 @@ protected:
|
|||||||
throw std::runtime_error("some error happened during flush");
|
throw std::runtime_error("some error happened during flush");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct custom_ex {};
|
struct custom_ex
|
||||||
|
{};
|
||||||
|
|
||||||
#if !defined(SPDLOG_USE_STD_FORMAT) // std formt doesn't fully support tuntime strings
|
#if !defined(SPDLOG_USE_STD_FORMAT) // std formt doesn't fully support tuntime strings
|
||||||
TEST_CASE("default_error_handler", "[errors]")
|
TEST_CASE("default_error_handler", "[errors]")
|
||||||
@ -39,7 +40,6 @@ TEST_CASE("default_error_handler", "[errors]")
|
|||||||
REQUIRE(count_lines(SIMPLE_LOG) == 1);
|
REQUIRE(count_lines(SIMPLE_LOG) == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST_CASE("custom_error_handler", "[errors]")
|
TEST_CASE("custom_error_handler", "[errors]")
|
||||||
{
|
{
|
||||||
prepare_logdir();
|
prepare_logdir();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user