Browse Source

clang-format

pull/2010/head
gabime 11 months ago
parent
commit
e7e8b75a4c
  1. 186
      CMakeLists.txt
  2. 10
      bench/CMakeLists.txt
  3. 47
      cmake/utils.cmake
  4. 4
      example/example.cpp
  5. 2
      include/spdlog/async_logger-inl.h
  6. 2
      include/spdlog/async_logger.h
  7. 2
      include/spdlog/cfg/helpers-inl.h
  8. 2
      include/spdlog/cfg/helpers.h
  9. 4
      include/spdlog/common-inl.h
  10. 2
      include/spdlog/details/backtracer-inl.h
  11. 3
      include/spdlog/details/backtracer.h
  12. 2
      include/spdlog/details/file_helper-inl.h
  13. 2
      include/spdlog/details/file_helper.h
  14. 2
      include/spdlog/details/log_msg-inl.h
  15. 2
      include/spdlog/details/log_msg.h
  16. 6
      include/spdlog/details/log_msg_buffer-inl.h
  17. 2
      include/spdlog/details/log_msg_buffer.h
  18. 130
      include/spdlog/details/os-inl.h
  19. 22
      include/spdlog/details/os.h
  20. 2
      include/spdlog/details/periodic_worker-inl.h
  21. 2
      include/spdlog/details/periodic_worker.h
  22. 18
      include/spdlog/details/registry-inl.h
  23. 2
      include/spdlog/details/registry.h
  24. 1
      include/spdlog/details/synchronous_factory.h
  25. 4
      include/spdlog/details/tcp_client.h
  26. 2
      include/spdlog/details/thread_pool-inl.h
  27. 2
      include/spdlog/details/thread_pool.h
  28. 4
      include/spdlog/details/windows_include.h
  29. 14
      include/spdlog/fmt/chrono.h
  30. 14
      include/spdlog/fmt/compile.h
  31. 23
      include/spdlog/fmt/fmt.h
  32. 14
      include/spdlog/fmt/ostr.h
  33. 14
      include/spdlog/fmt/xchar.h
  34. 2
      include/spdlog/logger-inl.h
  35. 14
      include/spdlog/pattern_formatter-inl.h
  36. 4
      include/spdlog/pattern_formatter.h
  37. 30
      include/spdlog/sinks/android_sink.h
  38. 2
      include/spdlog/sinks/ansicolor_sink-inl.h
  39. 2
      include/spdlog/sinks/ansicolor_sink.h
  40. 2
      include/spdlog/sinks/base_sink-inl.h
  41. 2
      include/spdlog/sinks/base_sink.h
  42. 2
      include/spdlog/sinks/basic_file_sink-inl.h
  43. 3
      include/spdlog/sinks/basic_file_sink.h
  44. 4
      include/spdlog/sinks/hourly_file_sink.h
  45. 98
      include/spdlog/sinks/mongo_sink.h
  46. 9
      include/spdlog/sinks/msvc_sink.h
  47. 387
      include/spdlog/sinks/qt_sinks.h
  48. 2
      include/spdlog/sinks/rotating_file_sink-inl.h
  49. 2
      include/spdlog/sinks/rotating_file_sink.h
  50. 2
      include/spdlog/sinks/sink-inl.h
  51. 2
      include/spdlog/sinks/sink.h
  52. 3
      include/spdlog/sinks/stdout_color_sinks-inl.h
  53. 6
      include/spdlog/sinks/stdout_color_sinks.h
  54. 26
      include/spdlog/sinks/stdout_sinks-inl.h
  55. 6
      include/spdlog/sinks/stdout_sinks.h
  56. 2
      include/spdlog/sinks/systemd_sink.h
  57. 4
      include/spdlog/sinks/tcp_sink.h
  58. 4
      include/spdlog/sinks/win_eventlog_sink.h
  59. 8
      include/spdlog/sinks/wincolor_sink-inl.h
  60. 6
      include/spdlog/sinks/wincolor_sink.h
  61. 2
      include/spdlog/spdlog-inl.h
  62. 66
      include/spdlog/spdlog.h
  63. 3
      src/async.cpp
  64. 3
      src/cfg.cpp
  65. 7
      src/color_sinks.cpp
  66. 3
      src/file_sinks.cpp
  67. 3
      src/spdlog.cpp
  68. 3
      src/stdout_sinks.cpp
  69. 3
      tests/test_create_dir.cpp
  70. 18
      tests/test_daily_logger.cpp
  71. 1
      tests/test_dup_filter.cpp
  72. 10
      tests/test_eventlog.cpp
  73. 3
      tests/test_file_helper.cpp
  74. 2
      tests/test_macros.cpp
  75. 6
      tests/utils.cpp

186
CMakeLists.txt

@ -18,47 +18,47 @@ include(GNUInstallDirs)
# ---------------------------------------------------------------------------------------
# Set CMake policies to support later version behaviour
# ---------------------------------------------------------------------------------------
if (POLICY CMP0077)
if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW) # option() honors variables already set
endif ()
endif()
# ---------------------------------------------------------------------------------------
# Set default build to release
# ---------------------------------------------------------------------------------------
if (NOT CMAKE_BUILD_TYPE)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose Release or Debug" FORCE)
endif ()
endif()
# ---------------------------------------------------------------------------------------
# Compiler config
# ---------------------------------------------------------------------------------------
if (NOT CMAKE_CXX_STANDARD)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif ()
endif()
# make sure __cplusplus is defined when using msvc
if (MSVC)
if(MSVC)
string(APPEND CMAKE_CXX_FLAGS " /Zc:__cplusplus")
endif ()
endif()
set(CMAKE_CXX_EXTENSIONS OFF)
if (CMAKE_SYSTEM_NAME MATCHES "CYGWIN" OR CMAKE_SYSTEM_NAME MATCHES "MSYS")
if(CMAKE_SYSTEM_NAME MATCHES "CYGWIN" OR CMAKE_SYSTEM_NAME MATCHES "MSYS")
set(CMAKE_CXX_EXTENSIONS ON)
endif ()
endif()
# ---------------------------------------------------------------------------------------
# Set SPDLOG_MASTER_PROJECT to ON if we are building spdlog
# ---------------------------------------------------------------------------------------
# Check if spdlog is being used directly or via add_subdirectory, but allow overriding
if (NOT DEFINED SPDLOG_MASTER_PROJECT)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
if(NOT DEFINED SPDLOG_MASTER_PROJECT)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(SPDLOG_MASTER_PROJECT ON)
else ()
else()
set(SPDLOG_MASTER_PROJECT OFF)
endif ()
endif ()
endif()
endif()
option(SPDLOG_BUILD_ALL "Build all artifacts" OFF)
@ -91,44 +91,44 @@ option(SPDLOG_FMT_EXTERNAL "Use external fmt library instead of bundled" OFF)
option(SPDLOG_FMT_EXTERNAL_HO "Use external fmt header-only library instead of bundled" OFF)
option(SPDLOG_NO_EXCEPTIONS "Compile with -fno-exceptions. Call abort() on any spdlog exceptions" OFF)
if (SPDLOG_FMT_EXTERNAL AND SPDLOG_FMT_EXTERNAL_HO)
if(SPDLOG_FMT_EXTERNAL AND SPDLOG_FMT_EXTERNAL_HO)
message(FATAL_ERROR "SPDLOG_FMT_EXTERNAL and SPDLOG_FMT_EXTERNAL_HO are mutually exclusive")
endif ()
endif()
# misc tweakme options
if (WIN32)
if(WIN32)
option(SPDLOG_WCHAR_SUPPORT "Support wchar api" OFF)
option(SPDLOG_WCHAR_FILENAMES "Support wchar filenames" OFF)
else ()
SET(SPDLOG_WCHAR_SUPPORT OFF CACHE BOOL "non supported option" FORCE)
SET(SPDLOG_WCHAR_FILENAMES OFF CACHE BOOL "non supported option" FORCE)
endif ()
else()
set(SPDLOG_WCHAR_SUPPORT OFF CACHE BOOL "non supported option" FORCE)
set(SPDLOG_WCHAR_FILENAMES OFF CACHE BOOL "non supported option" FORCE)
endif()
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
option(SPDLOG_CLOCK_COARSE "Use CLOCK_REALTIME_COARSE instead of the regular clock," OFF)
else ()
SET(SPDLOG_CLOCK_COARSE OFF CACHE BOOL "non supported option" FORCE)
endif ()
else()
set(SPDLOG_CLOCK_COARSE OFF CACHE BOOL "non supported option" FORCE)
endif()
option(SPDLOG_PREVENT_CHILD_FD "Prevent from child processes to inherit log file descriptors" OFF)
option(SPDLOG_NO_THREAD_ID "prevent spdlog from querying the thread id on each log call if thread id is not needed" OFF)
option(SPDLOG_NO_TLS "prevent spdlog from using thread local storage" OFF)
option(
SPDLOG_NO_ATOMIC_LEVELS
"prevent spdlog from using of std::atomic log levels (use only if your code never modifies log levels concurrently"
OFF)
SPDLOG_NO_ATOMIC_LEVELS
"prevent spdlog from using of std::atomic log levels (use only if your code never modifies log levels concurrently"
OFF)
option(SPDLOG_DISABLE_DEFAULT_LOGGER "Disable default logger creation" OFF)
# clang-tidy
if (${CMAKE_VERSION} VERSION_GREATER "3.5")
if(${CMAKE_VERSION} VERSION_GREATER "3.5")
option(SPDLOG_TIDY "run clang-tidy" OFF)
endif ()
endif()
if (SPDLOG_TIDY)
if(SPDLOG_TIDY)
set(CMAKE_CXX_CLANG_TIDY "clang-tidy")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
message(STATUS "Enabled clang-tidy")
endif ()
endif()
find_package(Threads REQUIRED)
message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
@ -137,43 +137,43 @@ message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
# ---------------------------------------------------------------------------------------
set(SPDLOG_SRCS src/spdlog.cpp src/stdout_sinks.cpp src/color_sinks.cpp src/file_sinks.cpp src/async.cpp src/cfg.cpp)
if (NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTERNAL_HO)
if(NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTERNAL_HO)
list(APPEND SPDLOG_SRCS src/fmt.cpp)
endif ()
endif()
if (SPDLOG_BUILD_SHARED OR BUILD_SHARED_LIBS)
if (WIN32)
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)
list(APPEND SPDLOG_SRCS ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
endif ()
endif()
add_library(spdlog SHARED ${SPDLOG_SRCS} ${SPDLOG_ALL_HEADERS})
target_compile_definitions(spdlog PUBLIC SPDLOG_SHARED_LIB)
if (MSVC)
target_compile_options(spdlog PUBLIC
$<$<AND:$<CXX_COMPILER_ID:MSVC>,$<NOT:$<COMPILE_LANGUAGE:CUDA>>>:/wd4251 /wd4275>)
endif ()
if (NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTERNAL_HO)
if(MSVC)
target_compile_options(spdlog PUBLIC $<$<AND:$<CXX_COMPILER_ID:MSVC>,$<NOT:$<COMPILE_LANGUAGE:CUDA>>>:/wd4251
/wd4275>)
endif()
if(NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTERNAL_HO)
target_compile_definitions(spdlog PRIVATE FMT_EXPORT PUBLIC FMT_SHARED)
endif ()
else ()
endif()
else()
add_library(spdlog STATIC ${SPDLOG_SRCS} ${SPDLOG_ALL_HEADERS})
endif ()
endif()
add_library(spdlog::spdlog ALIAS spdlog)
target_compile_definitions(spdlog PUBLIC SPDLOG_COMPILED_LIB)
target_include_directories(spdlog PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
target_link_libraries(spdlog PUBLIC Threads::Threads)
spdlog_enable_warnings(spdlog)
set_target_properties(spdlog PROPERTIES VERSION ${SPDLOG_VERSION} SOVERSION ${SPDLOG_VERSION_MAJOR})
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)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/pch.h.in ${PROJECT_BINARY_DIR}/spdlog_pch.h @ONLY)
target_precompile_headers(spdlog PRIVATE ${PROJECT_BINARY_DIR}/spdlog_pch.h)
endif ()
endif()
# ---------------------------------------------------------------------------------------
# Header only version
@ -182,92 +182,91 @@ add_library(spdlog_header_only INTERFACE)
add_library(spdlog::spdlog_header_only ALIAS spdlog_header_only)
target_include_directories(spdlog_header_only 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)
# ---------------------------------------------------------------------------------------
# Use fmt package if using external fmt
# ---------------------------------------------------------------------------------------
if (SPDLOG_FMT_EXTERNAL OR SPDLOG_FMT_EXTERNAL_HO)
if (NOT TARGET fmt::fmt)
if(SPDLOG_FMT_EXTERNAL OR SPDLOG_FMT_EXTERNAL_HO)
if(NOT TARGET fmt::fmt)
find_package(fmt CONFIG REQUIRED)
endif ()
endif()
target_compile_definitions(spdlog PUBLIC SPDLOG_FMT_EXTERNAL)
target_compile_definitions(spdlog_header_only INTERFACE SPDLOG_FMT_EXTERNAL)
# use external fmt-header-nly
if (SPDLOG_FMT_EXTERNAL_HO)
if(SPDLOG_FMT_EXTERNAL_HO)
target_link_libraries(spdlog PUBLIC fmt::fmt-header-only)
target_link_libraries(spdlog_header_only INTERFACE fmt::fmt-header-only)
else () # use external compile fmt
else() # use external compile fmt
target_link_libraries(spdlog PUBLIC fmt::fmt)
target_link_libraries(spdlog_header_only INTERFACE fmt::fmt)
endif ()
endif()
set(PKG_CONFIG_REQUIRES fmt) # add dependency to pkg-config
endif ()
endif()
# ---------------------------------------------------------------------------------------
# Add required libraries for Android CMake build
# ---------------------------------------------------------------------------------------
if (ANDROID)
if(ANDROID)
target_link_libraries(spdlog PUBLIC log)
target_link_libraries(spdlog_header_only INTERFACE log)
endif ()
endif()
# ---------------------------------------------------------------------------------------
# Misc definitions according to tweak options
# ---------------------------------------------------------------------------------------
set(SPDLOG_WCHAR_TO_UTF8_SUPPORT ${SPDLOG_WCHAR_SUPPORT})
foreach (
SPDLOG_OPTION
SPDLOG_WCHAR_TO_UTF8_SUPPORT
SPDLOG_WCHAR_FILENAMES
SPDLOG_NO_EXCEPTIONS
SPDLOG_CLOCK_COARSE
SPDLOG_PREVENT_CHILD_FD
SPDLOG_NO_THREAD_ID
SPDLOG_NO_TLS
SPDLOG_NO_ATOMIC_LEVELS
SPDLOG_DISABLE_DEFAULT_LOGGER)
if (${SPDLOG_OPTION})
foreach(
SPDLOG_OPTION
SPDLOG_WCHAR_TO_UTF8_SUPPORT
SPDLOG_WCHAR_FILENAMES
SPDLOG_NO_EXCEPTIONS
SPDLOG_CLOCK_COARSE
SPDLOG_PREVENT_CHILD_FD
SPDLOG_NO_THREAD_ID
SPDLOG_NO_TLS
SPDLOG_NO_ATOMIC_LEVELS
SPDLOG_DISABLE_DEFAULT_LOGGER)
if(${SPDLOG_OPTION})
target_compile_definitions(spdlog PUBLIC ${SPDLOG_OPTION})
target_compile_definitions(spdlog_header_only INTERFACE ${SPDLOG_OPTION})
endif ()
endforeach ()
endif()
endforeach()
if (SPDLOG_NO_EXCEPTIONS AND NOT MSVC)
if(SPDLOG_NO_EXCEPTIONS AND NOT MSVC)
target_compile_options(spdlog PRIVATE -fno-exceptions)
endif ()
endif()
# ---------------------------------------------------------------------------------------
# Build binaries
# ---------------------------------------------------------------------------------------
if (SPDLOG_BUILD_EXAMPLE OR SPDLOG_BUILD_EXAMPLE_HO OR SPDLOG_BUILD_ALL)
if(SPDLOG_BUILD_EXAMPLE OR SPDLOG_BUILD_EXAMPLE_HO OR SPDLOG_BUILD_ALL)
message(STATUS "Generating example(s)")
add_subdirectory(example)
spdlog_enable_warnings(example)
if (SPDLOG_BUILD_EXAMPLE_HO)
if(SPDLOG_BUILD_EXAMPLE_HO)
spdlog_enable_warnings(example_header_only)
endif ()
endif ()
endif()
endif()
if (SPDLOG_BUILD_TESTS OR SPDLOG_BUILD_TESTS_HO OR SPDLOG_BUILD_ALL)
if(SPDLOG_BUILD_TESTS OR SPDLOG_BUILD_TESTS_HO OR SPDLOG_BUILD_ALL)
message(STATUS "Generating tests")
enable_testing()
add_subdirectory(tests)
endif ()
endif()
if (SPDLOG_BUILD_BENCH OR SPDLOG_BUILD_ALL)
if(SPDLOG_BUILD_BENCH OR SPDLOG_BUILD_ALL)
message(STATUS "Generating benchmarks")
add_subdirectory(bench)
endif ()
endif()
# ---------------------------------------------------------------------------------------
# Install
# ---------------------------------------------------------------------------------------
if (SPDLOG_INSTALL)
if(SPDLOG_INSTALL)
message(STATUS "Generating install")
set(project_config_in "${CMAKE_CURRENT_LIST_DIR}/cmake/spdlogConfig.cmake.in")
set(project_config_out "${CMAKE_CURRENT_BINARY_DIR}/spdlogConfig.cmake")
@ -282,16 +281,16 @@ if (SPDLOG_INSTALL)
# ---------------------------------------------------------------------------------------
install(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" PATTERN "fmt/bundled" EXCLUDE)
install(
TARGETS spdlog spdlog_header_only
EXPORT spdlog
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
TARGETS spdlog spdlog_header_only
EXPORT spdlog
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
if (NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTERNAL_HO)
if(NOT SPDLOG_FMT_EXTERNAL AND NOT SPDLOG_FMT_EXTERNAL_HO)
install(DIRECTORY include/${PROJECT_NAME}/fmt/bundled/
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/fmt/bundled/")
endif ()
endif()
# ---------------------------------------------------------------------------------------
# Install pkg-config file
@ -317,5 +316,4 @@ if (SPDLOG_INSTALL)
# Support creation of installable packages
# ---------------------------------------------------------------------------------------
include(cmake/spdlogCPack.cmake)
endif ()
endif()

10
bench/CMakeLists.txt

@ -10,17 +10,15 @@ endif()
find_package(Threads REQUIRED)
find_package(benchmark CONFIG)
if (NOT benchmark_FOUND)
if(NOT benchmark_FOUND)
message(STATUS "Using CMake Version ${CMAKE_VERSION}")
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.11.0")
# User can fetch googlebenchmark
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.11.0")
# User can fetch googlebenchmark
message(STATUS "Downloading GoogleBenchmark")
include(FetchContent)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE INTERNAL "")
# Do not build and run googlebenchmark tests
FetchContent_Declare(googlebenchmark
GIT_REPOSITORY https://github.com/google/benchmark.git
GIT_TAG v1.5.2)
FetchContent_Declare(googlebenchmark GIT_REPOSITORY https://github.com/google/benchmark.git GIT_TAG v1.5.2)
FetchContent_MakeAvailable(googlebenchmark)
else()

47
cmake/utils.cmake

@ -2,21 +2,21 @@
function(spdlog_extract_version)
file(READ "${CMAKE_CURRENT_LIST_DIR}/include/spdlog/version.h" file_contents)
string(REGEX MATCH "SPDLOG_VER_MAJOR ([0-9]+)" _ "${file_contents}")
if (NOT CMAKE_MATCH_COUNT EQUAL 1)
if(NOT CMAKE_MATCH_COUNT EQUAL 1)
message(FATAL_ERROR "Could not extract major version number from spdlog/version.h")
endif ()
endif()
set(ver_major ${CMAKE_MATCH_1})
string(REGEX MATCH "SPDLOG_VER_MINOR ([0-9]+)" _ "${file_contents}")
if (NOT CMAKE_MATCH_COUNT EQUAL 1)
if(NOT CMAKE_MATCH_COUNT EQUAL 1)
message(FATAL_ERROR "Could not extract minor version number from spdlog/version.h")
endif ()
endif()
set(ver_minor ${CMAKE_MATCH_1})
string(REGEX MATCH "SPDLOG_VER_PATCH ([0-9]+)" _ "${file_contents}")
if (NOT CMAKE_MATCH_COUNT EQUAL 1)
if(NOT CMAKE_MATCH_COUNT EQUAL 1)
message(FATAL_ERROR "Could not extract patch version number from spdlog/version.h")
endif ()
endif()
set(ver_patch ${CMAKE_MATCH_1})
set(SPDLOG_VERSION_MAJOR ${ver_major} PARENT_SCOPE)
@ -27,32 +27,32 @@ endfunction()
# Turn on warnings on the given target
function(spdlog_enable_warnings target_name)
if (SPDLOG_BUILD_WARNINGS)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
if(SPDLOG_BUILD_WARNINGS)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
list(APPEND MSVC_OPTIONS "/W3")
if (MSVC_VERSION GREATER 1900) # Allow non fatal security warnings for msvc 2015
if(MSVC_VERSION GREATER 1900) # Allow non fatal security warnings for msvc 2015
list(APPEND MSVC_OPTIONS "/WX")
endif ()
endif ()
endif()
endif()
target_compile_options(
${target_name}
PRIVATE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall
-Wextra
-Wconversion
-pedantic
-Werror
-Wfatal-errors>
$<$<CXX_COMPILER_ID:MSVC>:${MSVC_OPTIONS}>)
endif ()
${target_name}
PRIVATE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall
-Wextra
-Wconversion
-pedantic
-Werror
-Wfatal-errors>
$<$<CXX_COMPILER_ID:MSVC>:${MSVC_OPTIONS}>)
endif()
endfunction()
# Enable address sanitizer (gcc/clang only)
function(spdlog_enable_sanitizer target_name)
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
message(FATAL_ERROR "Sanitizer supported only for gcc/clang")
endif ()
endif()
message(STATUS "Address sanitizer enabled")
target_compile_options(${target_name} PRIVATE -fsanitize=address,undefined)
target_compile_options(${target_name} PRIVATE -fno-sanitize=signed-integer-overflow)
@ -60,4 +60,3 @@ function(spdlog_enable_sanitizer target_name)
target_compile_options(${target_name} PRIVATE -fno-omit-frame-pointer)
target_link_libraries(${target_name} PRIVATE -fsanitize=address,undefined -fuse-ld=gold)
endfunction()

4
example/example.cpp

@ -246,7 +246,7 @@ void err_handler_example()
// syslog example (linux/osx/freebsd)
#ifndef _WIN32
#include "spdlog/sinks/syslog_sink.h"
# include "spdlog/sinks/syslog_sink.h"
void syslog_example()
{
std::string ident = "spdlog-example";
@ -257,7 +257,7 @@ void syslog_example()
// Android example.
#if defined(__ANDROID__)
#include "spdlog/sinks/android_sink.h"
# include "spdlog/sinks/android_sink.h"
void android_example()
{
std::string tag = "spdlog-android";

2
include/spdlog/async_logger-inl.h

@ -4,7 +4,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/async_logger.h>
# include <spdlog/async_logger.h>
#endif
#include <spdlog/sinks/sink.h>

2
include/spdlog/async_logger.h

@ -64,5 +64,5 @@ private:
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "async_logger-inl.h"
# include "async_logger-inl.h"
#endif

2
include/spdlog/cfg/helpers-inl.h

@ -4,7 +4,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/cfg/helpers.h>
# include <spdlog/cfg/helpers.h>
#endif
#include <spdlog/spdlog.h>

2
include/spdlog/cfg/helpers.h

@ -25,5 +25,5 @@ SPDLOG_API void load_levels(const std::string &txt);
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "helpers-inl.h"
# include "helpers-inl.h"
#endif // SPDLOG_HEADER_ONLY

4
include/spdlog/common-inl.h

@ -4,7 +4,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/common.h>
# include <spdlog/common.h>
#endif
#include <algorithm>
@ -16,7 +16,7 @@ namespace level {
#if __cplusplus >= 201703L
constexpr
#endif
static string_view_t level_string_views[] SPDLOG_LEVEL_NAMES;
static string_view_t level_string_views[] SPDLOG_LEVEL_NAMES;
static const char *short_level_names[] SPDLOG_SHORT_LEVEL_NAMES;

2
include/spdlog/details/backtracer-inl.h

@ -4,7 +4,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/details/backtracer.h>
# include <spdlog/details/backtracer.h>
#endif
namespace spdlog {
namespace details {

3
include/spdlog/details/backtracer.h

@ -41,6 +41,5 @@ public:
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "backtracer-inl.h"
# include "backtracer-inl.h"
#endif

2
include/spdlog/details/file_helper-inl.h

@ -4,7 +4,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/details/file_helper.h>
# include <spdlog/details/file_helper.h>
#endif
#include <spdlog/details/os.h>

2
include/spdlog/details/file_helper.h

@ -55,5 +55,5 @@ private:
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "file_helper-inl.h"
# include "file_helper-inl.h"
#endif

2
include/spdlog/details/log_msg-inl.h

@ -4,7 +4,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/details/log_msg.h>
# include <spdlog/details/log_msg.h>
#endif
#include <spdlog/details/os.h>

2
include/spdlog/details/log_msg.h

@ -33,5 +33,5 @@ struct SPDLOG_API log_msg
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "log_msg-inl.h"
# include "log_msg-inl.h"
#endif

6
include/spdlog/details/log_msg_buffer-inl.h

@ -4,7 +4,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/details/log_msg_buffer.h>
# include <spdlog/details/log_msg_buffer.h>
#endif
namespace spdlog {
@ -26,9 +26,7 @@ SPDLOG_INLINE log_msg_buffer::log_msg_buffer(const log_msg_buffer &other)
update_string_views();
}
SPDLOG_INLINE log_msg_buffer::log_msg_buffer(log_msg_buffer &&other) SPDLOG_NOEXCEPT
: log_msg{other}
, buffer{std::move(other.buffer)}
SPDLOG_INLINE log_msg_buffer::log_msg_buffer(log_msg_buffer &&other) SPDLOG_NOEXCEPT : log_msg{other}, buffer{std::move(other.buffer)}
{
update_string_views();
}

2
include/spdlog/details/log_msg_buffer.h

@ -29,5 +29,5 @@ public:
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "log_msg_buffer-inl.h"
# include "log_msg_buffer-inl.h"
#endif

130
include/spdlog/details/os-inl.h

@ -4,7 +4,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/details/os.h>
# include <spdlog/details/os.h>
#endif
#include <spdlog/common.h>
@ -23,45 +23,45 @@
#ifdef _WIN32
#include <io.h> // _get_osfhandle and _isatty support
#include <process.h> // _get_pid support
#include <spdlog/details/windows_include.h>
# include <io.h> // _get_osfhandle and _isatty support
# include <process.h> // _get_pid support
# include <spdlog/details/windows_include.h>
#ifdef __MINGW32__
#include <share.h>
#endif
# ifdef __MINGW32__
# include <share.h>
# endif
#if defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)
#include <limits>
#endif
# if defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)
# include <limits>
# endif
#include <direct.h> // for _mkdir/_wmkdir
# include <direct.h> // for _mkdir/_wmkdir
#else // unix
#include <fcntl.h>
#include <unistd.h>
# include <fcntl.h>
# include <unistd.h>
#ifdef __linux__
#include <sys/syscall.h> //Use gettid() syscall under linux to get thread id
# ifdef __linux__
# include <sys/syscall.h> //Use gettid() syscall under linux to get thread id
#elif defined(_AIX)
#include <pthread.h> // for pthread_getthreadid_np
# elif defined(_AIX)
# include <pthread.h> // for pthread_getthreadid_np
#elif defined(__DragonFly__) || defined(__FreeBSD__)
#include <pthread_np.h> // for pthread_getthreadid_np
# elif defined(__DragonFly__) || defined(__FreeBSD__)
# include <pthread_np.h> // for pthread_getthreadid_np
#elif defined(__NetBSD__)
#include <lwp.h> // for _lwp_self
# elif defined(__NetBSD__)
# include <lwp.h> // for _lwp_self
#elif defined(__sun)
#include <thread.h> // for thr_self
#endif
# elif defined(__sun)
# include <thread.h> // for thr_self
# endif
#endif // unix
#ifndef __has_feature // Clang - feature checking macros.
#define __has_feature(x) 0 // Compatibility with non-clang compilers.
#ifndef __has_feature // Clang - feature checking macros.
# define __has_feature(x) 0 // Compatibility with non-clang compilers.
#endif
namespace spdlog {
@ -123,12 +123,12 @@ SPDLOG_INLINE std::tm gmtime() SPDLOG_NOEXCEPT
SPDLOG_INLINE bool fopen_s(FILE **fp, const filename_t &filename, const filename_t &mode)
{
#ifdef _WIN32
#ifdef SPDLOG_WCHAR_FILENAMES
# ifdef SPDLOG_WCHAR_FILENAMES
*fp = ::_wfsopen((filename.c_str()), mode.c_str(), _SH_DENYNO);
#else
# else
*fp = ::_fsopen((filename.c_str()), mode.c_str(), _SH_DENYNO);
#endif
#if defined(SPDLOG_PREVENT_CHILD_FD)
# endif
# if defined(SPDLOG_PREVENT_CHILD_FD)
if (*fp != nullptr)
{
auto file_handle = reinterpret_cast<HANDLE>(_get_osfhandle(::_fileno(*fp)));
@ -138,9 +138,9 @@ SPDLOG_INLINE bool fopen_s(FILE **fp, const filename_t &filename, const filename
*fp = nullptr;
}
}
#endif
# endif
#else // unix
#if defined(SPDLOG_PREVENT_CHILD_FD)
# if defined(SPDLOG_PREVENT_CHILD_FD)
const int mode_flag = mode == SPDLOG_FILENAME_T("ab") ? O_APPEND : O_TRUNC;
const int fd = ::open((filename.c_str()), O_CREAT | O_WRONLY | O_CLOEXEC | mode_flag, mode_t(0644));
if (fd == -1)
@ -152,9 +152,9 @@ SPDLOG_INLINE bool fopen_s(FILE **fp, const filename_t &filename, const filename
{
::close(fd);
}
#else
# else
*fp = ::fopen((filename.c_str()), mode.c_str());
#endif
# endif
#endif
return *fp == nullptr;
@ -187,11 +187,11 @@ SPDLOG_INLINE int rename(const filename_t &filename1, const filename_t &filename
SPDLOG_INLINE bool path_exists(const filename_t &filename) SPDLOG_NOEXCEPT
{
#ifdef _WIN32
#ifdef SPDLOG_WCHAR_FILENAMES
# ifdef SPDLOG_WCHAR_FILENAMES
auto attribs = ::GetFileAttributesW(filename.c_str());
#else
# else
auto attribs = ::GetFileAttributesA(filename.c_str());
#endif
# endif
return attribs != INVALID_FILE_ATTRIBUTES;
#else // common linux/unix all have the stat system call
struct stat buffer;
@ -200,9 +200,9 @@ SPDLOG_INLINE bool path_exists(const filename_t &filename) SPDLOG_NOEXCEPT
}
#ifdef _MSC_VER
// avoid warning about unreachable statement at the end of filesize()
#pragma warning(push)
#pragma warning(disable: 4702)
// avoid warning about unreachable statement at the end of filesize()
# pragma warning(push)
# pragma warning(disable : 4702)
#endif
// Return file size according to open FILE* object
@ -214,49 +214,49 @@ SPDLOG_INLINE size_t filesize(FILE *f)
}
#if defined(_WIN32) && !defined(__CYGWIN__)
int fd = ::_fileno(f);
#if defined(_WIN64) // 64 bits
# if defined(_WIN64) // 64 bits
__int64 ret = ::_filelengthi64(fd);
if (ret >= 0)
{
return static_cast<size_t>(ret);
}
#else // windows 32 bits
# else // windows 32 bits
long ret = ::_filelength(fd);
if (ret >= 0)
{
return static_cast<size_t>(ret);
}
#endif
# endif
#else // unix
// OpenBSD doesn't compile with :: before the fileno(..)
#if defined(__OpenBSD__)
# if defined(__OpenBSD__)
int fd = fileno(f);
#else
# else
int fd = ::fileno(f);
#endif
# endif
// 64 bits(but not in osx or cygwin, where fstat64 is deprecated)
#if (defined(__linux__) || defined(__sun) || defined(_AIX)) && (defined(__LP64__) || defined(_LP64))
# if (defined(__linux__) || defined(__sun) || defined(_AIX)) && (defined(__LP64__) || defined(_LP64))
struct stat64 st;
if (::fstat64(fd, &st) == 0)
{
return static_cast<size_t>(st.st_size);
}
#else // other unix or linux 32 bits or cygwin
# else // other unix or linux 32 bits or cygwin
struct stat st;
if (::fstat(fd, &st) == 0)
{
return static_cast<size_t>(st.st_size);
}
#endif
# endif
#endif
throw_spdlog_ex("Failed getting file size from fd", errno);
return 0; // will not be reached.
}
#ifdef _MSC_VER
#pragma warning(pop)
# pragma warning(pop)
#endif
// Return utc offset in minutes or throw spdlog_ex on failure
@ -264,13 +264,13 @@ SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm)
{
#ifdef _WIN32
#if _WIN32_WINNT < _WIN32_WINNT_WS08
# if _WIN32_WINNT < _WIN32_WINNT_WS08
TIME_ZONE_INFORMATION tzinfo;
auto rv = ::GetTimeZoneInformation(&tzinfo);
#else
# else
DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
auto rv = ::GetDynamicTimeZoneInformation(&tzinfo);
#endif
# endif
if (rv == TIME_ZONE_ID_INVALID)
throw_spdlog_ex("Failed getting timezone info. ", errno);
@ -286,7 +286,7 @@ SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm)
return offset;
#else
#if defined(sun) || defined(__sun) || defined(_AIX) || (!defined(_BSD_SOURCE) && !defined(_GNU_SOURCE))
# if defined(sun) || defined(__sun) || defined(_AIX) || (!defined(_BSD_SOURCE) && !defined(_GNU_SOURCE))
// 'tm_gmtoff' field is BSD extension and it's missing on SunOS/Solaris
struct helper
{
@ -316,9 +316,9 @@ SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm)
};
auto offset_seconds = helper::calculate_gmt_offset(tm);
#else
# else
auto offset_seconds = tm.tm_gmtoff;
#endif
# endif
return static_cast<int>(offset_seconds / 60);
#endif
@ -332,9 +332,9 @@ SPDLOG_INLINE size_t _thread_id() SPDLOG_NOEXCEPT
#ifdef _WIN32
return static_cast<size_t>(::GetCurrentThreadId());
#elif defined(__linux__)
#if defined(__ANDROID__) && defined(__ANDROID_API__) && (__ANDROID_API__ < 21)
#define SYS_gettid __NR_gettid
#endif
# if defined(__ANDROID__) && defined(__ANDROID_API__) && (__ANDROID_API__ < 21)
# define SYS_gettid __NR_gettid
# endif
return static_cast<size_t>(::syscall(SYS_gettid));
#elif defined(_AIX) || defined(__DragonFly__) || defined(__FreeBSD__)
return static_cast<size_t>(::pthread_getthreadid_np());
@ -519,11 +519,11 @@ SPDLOG_INLINE void utf8_to_wstrbuf(string_view_t str, wmemory_buf_t &target)
static SPDLOG_INLINE bool mkdir_(const filename_t &path)
{
#ifdef _WIN32
#ifdef SPDLOG_WCHAR_FILENAMES
# ifdef SPDLOG_WCHAR_FILENAMES
return ::_wmkdir(path.c_str()) == 0;
#else
# else
return ::_mkdir(path.c_str()) == 0;
#endif
# endif
#else
return ::mkdir(path.c_str(), mode_t(0755)) == 0;
#endif
@ -580,14 +580,14 @@ std::string SPDLOG_INLINE getenv(const char *field)
{
#if defined(_MSC_VER)
#if defined(__cplusplus_winrt)
# if defined(__cplusplus_winrt)
return std::string{}; // not supported under uwp
#else
# else
size_t len = 0;
char buf[128];
bool ok = ::getenv_s(&len, buf, sizeof(buf), field) == 0;
return ok ? buf : std::string{};
#endif
# endif
#else // revert to getenv
char *buf = ::getenv(field);
return buf ? buf : std::string{};

22
include/spdlog/details/os.h

@ -22,22 +22,22 @@ SPDLOG_API std::tm gmtime() SPDLOG_NOEXCEPT;
// eol definition
#if !defined(SPDLOG_EOL)
#ifdef _WIN32
#define SPDLOG_EOL "\r\n"
#else
#define SPDLOG_EOL "\n"
#endif
# ifdef _WIN32
# define SPDLOG_EOL "\r\n"
# else
# define SPDLOG_EOL "\n"
# endif
#endif
SPDLOG_CONSTEXPR static const char *default_eol = SPDLOG_EOL;
// folder separator
#if !defined(SPDLOG_FOLDER_SEPS)
#ifdef _WIN32
#define SPDLOG_FOLDER_SEPS "\\/"
#else
#define SPDLOG_FOLDER_SEPS "/"
#endif
# ifdef _WIN32
# define SPDLOG_FOLDER_SEPS "\\/"
# else
# define SPDLOG_FOLDER_SEPS "/"
# endif
#endif
SPDLOG_CONSTEXPR static const char folder_seps[] = SPDLOG_FOLDER_SEPS;
@ -114,5 +114,5 @@ SPDLOG_API std::string getenv(const char *field);
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "os-inl.h"
# include "os-inl.h"
#endif

2
include/spdlog/details/periodic_worker-inl.h

@ -4,7 +4,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/details/periodic_worker.h>
# include <spdlog/details/periodic_worker.h>
#endif
namespace spdlog {

2
include/spdlog/details/periodic_worker.h

@ -36,5 +36,5 @@ private:
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "periodic_worker-inl.h"
# include "periodic_worker-inl.h"
#endif

18
include/spdlog/details/registry-inl.h

@ -4,7 +4,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/details/registry.h>
# include <spdlog/details/registry.h>
#endif
#include <spdlog/common.h>
@ -14,11 +14,11 @@
#ifndef SPDLOG_DISABLE_DEFAULT_LOGGER
// support for the default stdout color logger
#ifdef _WIN32
#include <spdlog/sinks/wincolor_sink.h>
#else
#include <spdlog/sinks/ansicolor_sink.h>
#endif
# ifdef _WIN32
# include <spdlog/sinks/wincolor_sink.h>
# else
# include <spdlog/sinks/ansicolor_sink.h>
# endif
#endif // SPDLOG_DISABLE_DEFAULT_LOGGER
#include <chrono>
@ -36,11 +36,11 @@ SPDLOG_INLINE registry::registry()
#ifndef SPDLOG_DISABLE_DEFAULT_LOGGER
// create default logger (ansicolor_stdout_sink_mt or wincolor_stdout_sink_mt in windows).
#ifdef _WIN32
# ifdef _WIN32
auto color_sink = std::make_shared<sinks::wincolor_stdout_sink_mt>();
#else
# else
auto color_sink = std::make_shared<sinks::ansicolor_stdout_sink_mt>();
#endif
# endif
const char *default_logger_name = "";
default_logger_ = std::make_shared<spdlog::logger>(default_logger_name, std::move(color_sink));

2
include/spdlog/details/registry.h

@ -111,5 +111,5 @@ private:
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "registry-inl.h"
# include "registry-inl.h"
#endif

1
include/spdlog/details/synchronous_factory.h

@ -22,4 +22,3 @@ struct synchronous_factory
}
};
} // namespace spdlog

4
include/spdlog/details/tcp_client.h

@ -4,7 +4,7 @@
#pragma once
#ifdef _WIN32
#error include tcp_client-windows.h instead
# error include tcp_client-windows.h instead
#endif
// tcp client helper
@ -111,7 +111,7 @@ public:
#endif
#if !defined(SO_NOSIGPIPE) && !defined(MSG_NOSIGNAL)
#error "tcp_sink would raise SIGPIPE since niether SO_NOSIGPIPE nor MSG_NOSIGNAL are available"
# error "tcp_sink would raise SIGPIPE since niether SO_NOSIGPIPE nor MSG_NOSIGNAL are available"
#endif
}

2
include/spdlog/details/thread_pool-inl.h

@ -4,7 +4,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/details/thread_pool.h>
# include <spdlog/details/thread_pool.h>
#endif
#include <spdlog/common.h>

2
include/spdlog/details/thread_pool.h

@ -117,5 +117,5 @@ private:
} // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY
#include "thread_pool-inl.h"
# include "thread_pool-inl.h"
#endif

4
include/spdlog/details/windows_include.h

@ -1,11 +1,11 @@
#pragma once
#ifndef NOMINMAX
#define NOMINMAX // prevent windows redefining min/max
# define NOMINMAX // prevent windows redefining min/max
#endif
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>

14
include/spdlog/fmt/chrono.h

@ -9,12 +9,12 @@
//
#if !defined(SPDLOG_FMT_EXTERNAL)
#ifdef SPDLOG_HEADER_ONLY
#ifndef FMT_HEADER_ONLY
#define FMT_HEADER_ONLY
#endif
#endif
#include <spdlog/fmt/bundled/chrono.h>
# ifdef SPDLOG_HEADER_ONLY
# ifndef FMT_HEADER_ONLY
# define FMT_HEADER_ONLY
# endif
# endif
# include <spdlog/fmt/bundled/chrono.h>
#else
#include <fmt/chrono.h>
# include <fmt/chrono.h>
#endif

14
include/spdlog/fmt/compile.h

@ -9,12 +9,12 @@
//
#if !defined(SPDLOG_FMT_EXTERNAL)
#ifdef SPDLOG_HEADER_ONLY
#ifndef FMT_HEADER_ONLY
#define FMT_HEADER_ONLY
#endif
#endif
#include <spdlog/fmt/bundled/compile.h>
# ifdef SPDLOG_HEADER_ONLY
# ifndef FMT_HEADER_ONLY
# define FMT_HEADER_ONLY
# endif
# endif
# include <spdlog/fmt/bundled/compile.h>
#else
#include <fmt/compile.h>
# include <fmt/compile.h>
#endif

23
include/spdlog/fmt/fmt.h

@ -11,18 +11,17 @@
//
#if !defined(SPDLOG_FMT_EXTERNAL)
#if !defined(SPDLOG_COMPILED_LIB) && !defined(FMT_HEADER_ONLY)
#define FMT_HEADER_ONLY
#endif
#ifndef FMT_USE_WINDOWS_H
#define FMT_USE_WINDOWS_H 0
#endif
# if !defined(SPDLOG_COMPILED_LIB) && !defined(FMT_HEADER_ONLY)
# define FMT_HEADER_ONLY
# endif
# ifndef FMT_USE_WINDOWS_H
# define FMT_USE_WINDOWS_H 0
# endif
// enable the 'n' flag in for backward compatibility with fmt 6.x
#define FMT_DEPRECATED_N_SPECIFIER
#include <spdlog/fmt/bundled/core.h>
#include <spdlog/fmt/bundled/format.h>
# define FMT_DEPRECATED_N_SPECIFIER
# include <spdlog/fmt/bundled/core.h>
# include <spdlog/fmt/bundled/format.h>
#else // SPDLOG_FMT_EXTERNAL is defined - use external fmtlib
#include <fmt/core.h>
#include <fmt/format.h>
# include <fmt/core.h>
# include <fmt/format.h>
#endif

14
include/spdlog/fmt/ostr.h

@ -9,12 +9,12 @@
//
#if !defined(SPDLOG_FMT_EXTERNAL)
#ifdef SPDLOG_HEADER_ONLY
#ifndef FMT_HEADER_ONLY
#define FMT_HEADER_ONLY
#endif
#endif
#include <spdlog/fmt/bundled/ostream.h>
# ifdef SPDLOG_HEADER_ONLY
# ifndef FMT_HEADER_ONLY
# define FMT_HEADER_ONLY
# endif
# endif
# include <spdlog/fmt/bundled/ostream.h>
#else
#include <fmt/ostream.h>
# include <fmt/ostream.h>
#endif

14
include/spdlog/fmt/xchar.h

@ -9,12 +9,12 @@
//
#if !defined(SPDLOG_FMT_EXTERNAL)
#ifdef SPDLOG_HEADER_ONLY
#ifndef FMT_HEADER_ONLY
#define FMT_HEADER_ONLY
#endif
#endif
#include <spdlog/fmt/bundled/xchar.h>
# ifdef SPDLOG_HEADER_ONLY
# ifndef FMT_HEADER_ONLY
# define FMT_HEADER_ONLY
# endif
# endif
# include <spdlog/fmt/bundled/xchar.h>
#else
#include <fmt/xchar.h>
# include <fmt/xchar.h>
#endif

2
include/spdlog/logger-inl.h

@ -4,7 +4,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/logger.h>
# include <spdlog/logger.h>
#endif
#include <spdlog/sinks/sink.h>

14
include/spdlog/pattern_formatter-inl.h

@ -4,7 +4,7 @@
#pragma once
#ifndef SPDLOG_HEADER_ONLY
#include <spdlog/pattern_formatter.h>
# include <spdlog/pattern_formatter.h>
#endif
#include <spdlog/details/fmt_helper.h>
@ -817,9 +817,9 @@ public:
{}
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4127) // consider using 'if constexpr' instead
#endif // _MSC_VER
# pragma warning(push)
# pragma warning(disable : 4127) // consider using 'if constexpr' instead
#endif // _MSC_VER
static const char *basename(const char *filename)
{
// if the size is 2 (1 character + null terminator) we can use the more efficient strrchr
@ -831,15 +831,15 @@ public:
}