return format_bool(m_keep_comments_cpp);
case ConfigItem::log_file:
- return m_log_file;
+ return m_log_file.string();
case ConfigItem::max_files:
return FMT("{}", m_max_files);
const std::string& ignore_options() const;
bool inode_cache() const;
bool keep_comments_cpp() const;
- const std::string& log_file() const;
+ const std::filesystem::path& log_file() const;
uint64_t max_files() const;
uint64_t max_size() const;
const std::string& msvc_dep_prefix() const;
bool m_inode_cache = false;
#endif
bool m_keep_comments_cpp = false;
- std::string m_log_file;
+ std::filesystem::path m_log_file;
uint64_t m_max_files = 0;
uint64_t m_max_size = 5ULL * 1024 * 1024 * 1024;
std::string m_msvc_dep_prefix = "Note: including file:";
return m_keep_comments_cpp;
}
-inline const std::string&
+inline const std::filesystem::path&
Config::log_file() const
{
return m_log_file;
#include <ccache/Config.hpp>
#include <ccache/util/FileStream.hpp>
#include <ccache/util/file.hpp>
+#include <ccache/util/filesystem.hpp>
#include <ccache/util/format.hpp>
#include <ccache/util/logging.hpp>
#include <ccache/util/time.hpp>
# endif
#endif
+namespace fs = util::filesystem;
+
namespace {
// Logfile path and file handle, read from Config::log_file().
-std::string logfile_path;
+fs::path logfile_path;
util::FileStream logfile;
// Whether to use syslog() instead.
// Initialize logging. Call only once.
void
-init(bool debug, const std::string& log_file)
+init(bool debug, const fs::path& log_file)
{
debug_log_enabled = debug;
#include <fmt/core.h>
#include <fmt/format.h>
+#include <filesystem>
#include <string>
#include <string_view>
// Initialize global logging state. Must be called once before using the other
// logging functions.
-void init(bool debug, const std::string& log_file);
+void init(bool debug, const std::filesystem::path& log_file);
// Return whether logging is enabled to at least one destination.
bool enabled();