Removed SPDLOG_USE_STD_FORMAT
This commit is contained in:
parent
d7c6cc13a5
commit
ea896885cd
6
.github/workflows/windows.yml
vendored
6
.github/workflows/windows.yml
vendored
@ -56,8 +56,7 @@ jobs:
|
||||
-D SPDLOG_WCHAR_FILENAMES=${{ matrix.config.WCHAR_FILES }} `
|
||||
-D SPDLOG_BUILD_EXAMPLE=${{ matrix.config.BUILD_EXAMPLE }} `
|
||||
-D SPDLOG_BUILD_TESTS=ON `
|
||||
-D SPDLOG_BUILD_WARNINGS=${{ matrix.config.FATAL_ERRORS }} `
|
||||
-D SPDLOG_USE_STD_FORMAT=${{ matrix.config.USE_STD_FORMAT }} `
|
||||
-D SPDLOG_BUILD_WARNINGS=${{ matrix.config.FATAL_ERRORS }} `
|
||||
-D CMAKE_CXX_STANDARD=${{ matrix.config.CXX_STANDARD }} ..
|
||||
|
||||
- name: Build
|
||||
@ -117,8 +116,7 @@ jobs:
|
||||
-D SPDLOG_WCHAR_FILENAMES=${{ matrix.config.WCHAR_FILES }} `
|
||||
-D SPDLOG_BUILD_EXAMPLE=${{ matrix.config.BUILD_EXAMPLE }} `
|
||||
-D SPDLOG_BUILD_TESTS=ON `
|
||||
-D SPDLOG_BUILD_WARNINGS=${{ matrix.config.FATAL_ERRORS }} `
|
||||
-D SPDLOG_USE_STD_FORMAT=${{ matrix.config.USE_STD_FORMAT }} `
|
||||
-D SPDLOG_BUILD_WARNINGS=${{ matrix.config.FATAL_ERRORS }} `
|
||||
-D CMAKE_CXX_STANDARD=${{ matrix.config.CXX_STANDARD }} ..
|
||||
|
||||
- name: Build
|
||||
|
@ -12,12 +12,7 @@
|
||||
#include "spdlog/sinks/rotating_file_sink.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
#if defined(SPDLOG_USE_STD_FORMAT)
|
||||
#include <format>
|
||||
#else
|
||||
#include <fmt/format.h>
|
||||
#endif
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <atomic>
|
||||
#include <cstdlib> // EXIT_FAILURE
|
||||
#include <memory>
|
||||
|
@ -7,10 +7,7 @@ include(CMakeFindDependencyMacro)
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
set(SPDLOG_USE_STD_FORMAT @SPDLOG_USE_STD_FORMAT@)
|
||||
if(NOT SPDLOG_USE_STD_FORMAT)
|
||||
find_dependency(fmt CONFIG)
|
||||
endif()
|
||||
find_dependency(fmt CONFIG)
|
||||
|
||||
set(config_targets_file @config_targets_file@)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/${config_targets_file}")
|
||||
|
@ -27,9 +27,5 @@
|
||||
// Disable default logger creation
|
||||
#cmakedefine SPDLOG_DISABLE_DEFAULT_LOGGER
|
||||
|
||||
// Use std::format instead of fmtlib
|
||||
#cmakedefine SPDLOG_USE_STD_FORMAT
|
||||
|
||||
// Use external fmtlib instead of bundled
|
||||
#cmakedefine SPDLOG_FMT_EXTERNAL
|
||||
|
||||
|
@ -26,13 +26,9 @@ spdlog_ex::spdlog_ex(std::string msg)
|
||||
: msg_(std::move(msg)) {}
|
||||
|
||||
spdlog_ex::spdlog_ex(const std::string &msg, int last_errno) {
|
||||
#ifdef SPDLOG_USE_STD_FORMAT
|
||||
msg_ = std::system_error(std::error_code(last_errno, std::generic_category()), msg).what();
|
||||
#else
|
||||
memory_buf_t outbuf;
|
||||
fmt::format_system_error(outbuf, last_errno, msg.c_str());
|
||||
msg_ = fmt::to_string(outbuf);
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *spdlog_ex::what() const noexcept { return msg_.c_str(); }
|
||||
|
@ -52,7 +52,8 @@ set(SPDLOG_UTESTS_SOURCES
|
||||
test_source_location.cpp
|
||||
test_no_source_location.cpp
|
||||
test_log_level.cpp
|
||||
test_include_sinks.cpp)
|
||||
test_include_sinks.cpp
|
||||
test_bin_to_hex.cpp)
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND SPDLOG_UTESTS_SOURCES test_eventlog.cpp)
|
||||
@ -66,10 +67,6 @@ if(systemd_FOUND)
|
||||
list(APPEND SPDLOG_UTESTS_SOURCES test_systemd.cpp)
|
||||
endif()
|
||||
|
||||
if(NOT SPDLOG_USE_STD_FORMAT)
|
||||
list(APPEND SPDLOG_UTESTS_SOURCES test_bin_to_hex.cpp)
|
||||
endif()
|
||||
|
||||
enable_testing()
|
||||
|
||||
function(spdlog_prepare_test test_target spdlog_lib)
|
||||
|
@ -6,11 +6,7 @@
|
||||
#include "spdlog/sinks/daily_file_sink.h"
|
||||
#include "spdlog/sinks/rotating_file_sink.h"
|
||||
|
||||
#ifdef SPDLOG_USE_STD_FORMAT
|
||||
using filename_memory_buf_t = std::basic_string<spdlog::filename_t::value_type>;
|
||||
#else
|
||||
using filename_memory_buf_t = fmt::basic_memory_buffer<spdlog::filename_t::value_type, 250>;
|
||||
#endif
|
||||
using filename_memory_buf_t = spdlog::memory_buf_t;
|
||||
|
||||
#ifdef SPDLOG_WCHAR_FILENAMES
|
||||
std::string filename_buf_to_utf8string(const filename_memory_buf_t &w) {
|
||||
|
@ -18,7 +18,7 @@ protected:
|
||||
};
|
||||
struct custom_ex {};
|
||||
|
||||
#if !defined(SPDLOG_USE_STD_FORMAT) // std formt doesn't fully support runtime format strings
|
||||
|
||||
TEST_CASE("default_error_handler", "[errors]") {
|
||||
prepare_logdir();
|
||||
spdlog::filename_t filename = SPDLOG_FILENAME_T(SIMPLE_LOG);
|
||||
@ -45,7 +45,6 @@ TEST_CASE("custom_error_handler", "[errors]") {
|
||||
logger->info("Good message #2");
|
||||
require_message_count(SIMPLE_LOG, 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST_CASE("default_error_handler2", "[errors]") {
|
||||
spdlog::drop_all();
|
||||
@ -61,7 +60,6 @@ TEST_CASE("flush_error_handler", "[errors]") {
|
||||
REQUIRE_THROWS_AS(logger->flush(), custom_ex);
|
||||
}
|
||||
|
||||
#if !defined(SPDLOG_USE_STD_FORMAT) // std formt doesn't fully support runtime format strings
|
||||
TEST_CASE("async_error_handler", "[errors]") {
|
||||
prepare_logdir();
|
||||
std::string err_msg("log failed with some msg");
|
||||
@ -86,7 +84,6 @@ TEST_CASE("async_error_handler", "[errors]") {
|
||||
require_message_count(SIMPLE_ASYNC_LOG, 2);
|
||||
REQUIRE(file_contents("test_logs/custom_err.txt") == err_msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Make sure async error handler is executed
|
||||
TEST_CASE("async_error_handler2", "[errors]") {
|
||||
|
Loading…
Reference in New Issue
Block a user