From: Joel Rosdahl Date: Sat, 8 Jun 2024 18:41:23 +0000 (+0200) Subject: refactor: Convert Config::m_log_file to fs::path X-Git-Tag: v4.11~107 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e456be8da34bcf3784a34386d57c1081f860d4a3;p=thirdparty%2Fccache.git refactor: Convert Config::m_log_file to fs::path --- diff --git a/src/ccache/Config.cpp b/src/ccache/Config.cpp index e467318e..ee08bf5a 100644 --- a/src/ccache/Config.cpp +++ b/src/ccache/Config.cpp @@ -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); diff --git a/src/ccache/Config.hpp b/src/ccache/Config.hpp index 77b93bf0..809ecc4b 100644 --- a/src/ccache/Config.hpp +++ b/src/ccache/Config.hpp @@ -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; diff --git a/src/ccache/util/logging.cpp b/src/ccache/util/logging.cpp index 717c1913..d032d831 100644 --- a/src/ccache/util/logging.cpp +++ b/src/ccache/util/logging.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -38,10 +39,12 @@ # 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; diff --git a/src/ccache/util/logging.hpp b/src/ccache/util/logging.hpp index 19f11545..1919f0ca 100644 --- a/src/ccache/util/logging.hpp +++ b/src/ccache/util/logging.hpp @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -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();