Skip to content

Commit

Permalink
fix(spdlog): Handle SPDLOG_WCHAR_FILENAMES. Fix #1147
Browse files Browse the repository at this point in the history
  • Loading branch information
romainthomas committed Jan 11, 2025
1 parent 866d55d commit 7cab930
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
namespace LIEF {
namespace logging {


std::shared_ptr<spdlog::logger>
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<spdlog::logger> default_logger(
[[maybe_unused]] const std::string& name = "LIEF",
[[maybe_unused]] const std::string& logcat_tag = "lief",
Expand All @@ -45,7 +53,7 @@ static std::shared_ptr<spdlog::logger> 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);
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 7cab930

Please sign in to comment.