Skip to content

Commit

Permalink
Fix for Windows compilation.
Browse files Browse the repository at this point in the history
  • Loading branch information
rsmmr committed Jul 5, 2024
1 parent 2f07e3b commit 745641c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "autogen/config.h"
#include "core/configuration.h"
#include "util/filesystem.h"

#include <memory>
#include <string>
Expand Down Expand Up @@ -65,7 +66,7 @@ Result<Nothing> zeek::agent::setGlobalLogger(options::LogType type, options::Log
if ( ! path )
return result::Error("file logging requires a path");

sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(path->string());
sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>(path_to_spdlog_filename(*path));
break;
}

Expand Down
3 changes: 3 additions & 0 deletions src/util/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <string>

#include <ghc/filesystem.hpp>
#include <spdlog/common.h>

/** Type alias. */
namespace filesystem = ghc::filesystem;
Expand All @@ -18,8 +19,10 @@ namespace platform::windows {
std::string narrowWstring(const std::wstring& wstr); // provided by platform.cc
} // namespace platform::windows
inline std::string path_to_string(const filesystem::path& p) { return platform::windows::narrowWstring(p.native()); }
inline spdlog::filename_t path_to_spdlog_filename(const filesystem::path& p) { return p.wstring(); }
#else
inline std::string path_to_string(const filesystem::path& p) { return p.native(); }
inline spdlog::filename_t path_to_spdlog_filename(const filesystem::path& p) { return p.string(); }
#endif

} // namespace zeek::agent

0 comments on commit 745641c

Please sign in to comment.