clang format

This commit is contained in:
gabime 2023-10-01 18:01:02 +03:00
parent 754838c558
commit 57868277db
7 changed files with 31 additions and 30 deletions

View File

@ -147,10 +147,16 @@ message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
# ---------------------------------------------------------------------------------------
# Static/Shared library
# ---------------------------------------------------------------------------------------
file(GLOB SPDLOG_HEADERS "include/spdlog/*.h" "include/spdlog/sinks/*.h" "include/spdlog/details/*.h" "include/spdlog/fmt/*.h" "include/spdlog/cfg/*.h" )
file(
GLOB
SPDLOG_HEADERS
"include/spdlog/*.h"
"include/spdlog/sinks/*.h"
"include/spdlog/details/*.h"
"include/spdlog/fmt/*.h"
"include/spdlog/cfg/*.h")
file(GLOB SPDLOG_SRCS "src/*.cpp" "src/details/*.cpp" "src/sinks/*.cpp" "src/cfg/*.cpp")
# add {fmt} lib sources is not using external fmt
if(NOT SPDLOG_USE_STD_FORMAT AND NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTERNAL_HO)
file(GLOB BUNDLED_FMT_HEADERS "include/spdlog/fmt/bundled/*.h")
@ -158,7 +164,6 @@ if(NOT SPDLOG_USE_STD_FORMAT AND NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTE
list(APPEND SPDLOG_SRCS src/fmt/bundled_fmtlib_format.cpp)
endif()
if(SPDLOG_BUILD_SHARED OR BUILD_SHARED_LIBS)
if(WIN32)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY)

View File

@ -36,8 +36,8 @@ target_link_libraries(latency PRIVATE benchmark::benchmark spdlog::spdlog)
add_executable(formatter-bench formatter-bench.cpp)
target_link_libraries(formatter-bench PRIVATE benchmark::benchmark spdlog::spdlog)
# copy dll to the executable folder for msvc
if(MSVC AND (SPDLOG_BUILD_SHARED OR BUILD_SHARED_LIBS))
add_custom_command(TARGET latency POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:spdlog> $<TARGET_FILE_DIR:latency>)
add_custom_command(TARGET latency POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:spdlog>
$<TARGET_FILE_DIR:latency>)
endif()

View File

@ -8,14 +8,11 @@ if(NOT TARGET spdlog)
find_package(spdlog REQUIRED)
endif()
add_executable(example example.cpp)
target_link_libraries(example PRIVATE spdlog::spdlog $<$<BOOL:${MINGW}>:ws2_32>)
# copy dll to the executable folder for msvc
if(MSVC AND (SPDLOG_BUILD_SHARED OR BUILD_SHARED_LIBS))
add_custom_command(TARGET example POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:spdlog> $<TARGET_FILE_DIR:example>)
add_custom_command(TARGET example POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:spdlog>
$<TARGET_FILE_DIR:example>)
endif()

View File

@ -2,20 +2,22 @@
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#ifdef _WIN32
// clang-format off
// clang-format off
#include "spdlog/details/windows_include.h"
#include "spdlog/sinks/wincolor_sink.h"
#include "spdlog/common.h"
#include <wincon.h>
// clang-format on
#include <mutex>
#include <spdlog/details/null_mutex.h>
#include <spdlog/details/null_mutex.h>
#include <mutex>
namespace spdlog {
namespace sinks {
template <typename Mutex>
wincolor_sink<Mutex>::wincolor_sink(void *out_handle, color_mode mode) : out_handle_(out_handle) {
wincolor_sink<Mutex>::wincolor_sink(void *out_handle, color_mode mode)
: out_handle_(out_handle) {
set_color_mode_impl(mode);
// set level colors
colors_.at(level_to_number(level::trace)) =
@ -74,7 +76,6 @@ void wincolor_sink<Mutex>::flush_() {
// windows console always flushed?
}
template <typename Mutex>
void wincolor_sink<Mutex>::set_color_mode(color_mode mode) {
std::lock_guard<Mutex> lock(base_sink<Mutex>::mutex_);
@ -112,9 +113,7 @@ std::uint16_t wincolor_sink<Mutex>::set_foreground_color_(std::uint16_t attribs)
// print a range of formatted message to console
template <typename Mutex>
void wincolor_sink<Mutex>::print_range_(const memory_buf_t &formatted,
size_t start,
size_t end) {
void wincolor_sink<Mutex>::print_range_(const memory_buf_t &formatted, size_t start, size_t end) {
if (end > start) {
auto size = static_cast<DWORD>(end - start);
auto ignored = ::WriteConsoleA(static_cast<HANDLE>(out_handle_), formatted.data() + start,

View File

@ -25,8 +25,7 @@ void set_formatter(std::unique_ptr<spdlog::formatter> formatter) {
}
void set_pattern(std::string pattern, pattern_time_type time_type) {
set_formatter(
std::make_unique<spdlog::pattern_formatter>(std::move(pattern), time_type));
set_formatter(std::make_unique<spdlog::pattern_formatter>(std::move(pattern), time_type));
}
level get_level() { return default_logger_raw()->log_level(); }

View File

@ -87,8 +87,9 @@ if(SPDLOG_BUILD_TESTS OR SPDLOG_BUILD_ALL)
# copy dll to the executable folder for msvc
if(MSVC AND (SPDLOG_BUILD_SHARED OR BUILD_SHARED_LIBS))
add_custom_command(TARGET spdlog-utests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:spdlog> $<TARGET_FILE_DIR:spdlog-utests>)
add_custom_command(
TARGET spdlog-utests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:spdlog>
$<TARGET_FILE_DIR:spdlog-utests>)
endif()
endif()