From 7cab930c1c597242a788da60cf570a3d3ea6c5af Mon Sep 17 00:00:00 2001 From: Romain Thomas Date: Sat, 11 Jan 2025 05:45:47 +0100 Subject: [PATCH] fix(spdlog): Handle `SPDLOG_WCHAR_FILENAMES`. Fix #1147 --- src/logging.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/logging.cpp b/src/logging.cpp index 39936fe8f3..27b917fa2c 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -28,6 +28,14 @@ namespace LIEF { namespace logging { + +std::shared_ptr + create_basic_logger_mt(const std::string& name, const std::string& path, bool truncate = false) +{ + spdlog::filename_t fname(path.begin(), path.end()); + return spdlog::basic_logger_mt(name, fname, truncate); +} + static std::shared_ptr default_logger( [[maybe_unused]] const std::string& name = "LIEF", [[maybe_unused]] const std::string& logcat_tag = "lief", @@ -45,7 +53,7 @@ static std::shared_ptr default_logger( #endif } else if (current_platform() == PLATFORMS::PLAT_IOS) { - sink = spdlog::basic_logger_mt(name, filepath, truncate); + sink = create_basic_logger_mt(name, filepath, truncate); } else { sink = spdlog::stderr_color_mt(name); @@ -105,7 +113,7 @@ void Logger::destroy() { Logger& Logger::set_log_path(const std::string& path) { auto& registry = spdlog::details::registry::instance(); registry.drop(DEFAULT_NAME); - auto logger = spdlog::basic_logger_mt(DEFAULT_NAME, path, /*truncate=*/true); + auto logger = create_basic_logger_mt(DEFAULT_NAME, path, /*truncate=*/true); set_logger(std::move(logger)); return *this; }