]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
refactor: Convert Config::m_log_file to fs::path
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 8 Jun 2024 18:41:23 +0000 (20:41 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 30 Jun 2024 15:18:52 +0000 (17:18 +0200)
src/ccache/Config.cpp
src/ccache/Config.hpp
src/ccache/util/logging.cpp
src/ccache/util/logging.hpp

index e467318ebee40db9d7e72cc2131c7a0ba7e64793..ee08bf5a56b42114ae19f124074926b2add83443 100644 (file)
@@ -823,7 +823,7 @@ Config::get_string_value(const std::string& key) const
     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);
index 77b93bf0ff14a91c137f90e12de21ee3bb91f812..809ecc4b94eb143ebebe15385c6c59c92dc44eb8 100644 (file)
@@ -75,7 +75,7 @@ public:
   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;
@@ -195,7 +195,7 @@ private:
   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:";
@@ -383,7 +383,7 @@ Config::keep_comments_cpp() const
   return m_keep_comments_cpp;
 }
 
-inline const std::string&
+inline const std::filesystem::path&
 Config::log_file() const
 {
   return m_log_file;
index 717c19137ffffd5d5aaf5acd80c447e8a0ef394b..d032d831f557dba513e5cc60f22b7bb92c6d0ddc 100644 (file)
@@ -20,6 +20,7 @@
 #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.
@@ -123,7 +126,7 @@ namespace util::logging {
 
 // 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;
 
index 19f115459cb12d03ccd5b933399ba1a2afc37014..1919f0cac420262563a272341c482430590a10eb 100644 (file)
@@ -21,6 +21,7 @@
 #include <fmt/core.h>
 #include <fmt/format.h>
 
+#include <filesystem>
 #include <string>
 #include <string_view>
 
@@ -50,7 +51,7 @@ namespace util::logging {
 
 // 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();