Skip to content

Commit

Permalink
Revert 70f7a82
Browse files Browse the repository at this point in the history
  • Loading branch information
gabime committed Oct 21, 2023
1 parent bc7e80c commit 83d5f3d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion example/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void async_example() {
// {:n} - don't split the output to lines.

#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() {
std::vector<char> buf(80);
for (int i = 0; i < 80; i++) {
Expand Down
10 changes: 8 additions & 2 deletions include/spdlog/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@

#include "fmt/fmt.h"

#if defined(SPDLOG_WCHAR_FILENAMES) && !defined(SPDLOG_USE_STD_FORMAT)
#include "fmt/xchar.h"
#if !defined(SPDLOG_USE_STD_FORMAT) && \
FMT_VERSION >= 80000 // backward compatibility with fmt versions older than 8
#define SPDLOG_FMT_RUNTIME(format_string) fmt::runtime(format_string)
#if defined(SPDLOG_WCHAR_FILENAMES)
#include "fmt/xchar.h"
#endif
#else
#define SPDLOG_FMT_RUNTIME(format_string) format_string
#endif

#ifndef SPDLOG_FUNCTION
Expand Down
6 changes: 3 additions & 3 deletions tests/test_errors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ TEST_CASE("default_error_handler", "[errors]") {

auto logger = spdlog::create<spdlog::sinks::basic_file_sink_mt>("test-error", filename, true);
logger->set_pattern("%v");
logger->info("Test message {} {}", 1);
logger->info(SPDLOG_FMT_RUNTIME("Test message {} {}"), 1);
logger->info("Test message {}", 2);
logger->flush();
using spdlog::details::os::default_eol;
Expand All @@ -43,7 +43,7 @@ TEST_CASE("custom_error_handler", "[errors]") {
logger->set_error_handler([=](const std::string &) { throw custom_ex(); });
logger->info("Good message #1");

REQUIRE_THROWS_AS(logger->info("Bad format msg {} {}", "xxx"), custom_ex);
REQUIRE_THROWS_AS(logger->info(SPDLOG_FMT_RUNTIME("Bad format msg {} {}"), "xxx"), custom_ex);
logger->info("Good message #2");
require_message_count(SIMPLE_LOG, 2);
}
Expand Down Expand Up @@ -81,7 +81,7 @@ TEST_CASE("async_error_handler", "[errors]") {
ofs << err_msg;
});
logger->info("Good message #1");
logger->info("Bad format msg {} {}", "xxx");
logger->info(SPDLOG_FMT_RUNTIME("Bad format msg {} {}"), "xxx");
logger->info("Good message #2");
spdlog::drop("logger"); // force logger to drain the queue and shutdown
}
Expand Down

0 comments on commit 83d5f3d

Please sign in to comment.