diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/file_system/TARGETS | 8 | ||||
-rw-r--r-- | src/buildtool/file_system/git_cas.cpp | 11 | ||||
-rw-r--r-- | src/buildtool/file_system/git_cas.hpp | 4 |
3 files changed, 14 insertions, 9 deletions
diff --git a/src/buildtool/file_system/TARGETS b/src/buildtool/file_system/TARGETS index d327af6e..c8c26458 100644 --- a/src/buildtool/file_system/TARGETS +++ b/src/buildtool/file_system/TARGETS @@ -70,12 +70,16 @@ , "name": ["git_cas"] , "hdrs": ["git_cas.hpp"] , "srcs": ["git_cas.cpp"] - , "deps": ["git_utils", "object_type", ["@", "gsl", "", "gsl"]] + , "deps": + [ "git_utils" + , "object_type" + , ["@", "gsl", "", "gsl"] + , ["src/buildtool/logging", "log_level"] + ] , "stage": ["src", "buildtool", "file_system"] , "private-deps": [ "git_context" , ["", "libgit2"] - , ["src/buildtool/logging", "log_level"] , ["src/buildtool/logging", "logging"] , ["src/utils/cpp", "hex_string"] , ["src/utils/cpp", "path"] diff --git a/src/buildtool/file_system/git_cas.cpp b/src/buildtool/file_system/git_cas.cpp index 7e004934..295b5783 100644 --- a/src/buildtool/file_system/git_cas.cpp +++ b/src/buildtool/file_system/git_cas.cpp @@ -18,7 +18,6 @@ #include <mutex> #include "src/buildtool/file_system/git_context.hpp" -#include "src/buildtool/logging/log_level.hpp" #include "src/buildtool/logging/logger.hpp" #include "src/utils/cpp/hex_string.hpp" #include "src/utils/cpp/path.hpp" @@ -54,8 +53,8 @@ GitCAS::GitCAS() noexcept { GitContext::Create(); } -auto GitCAS::Open(std::filesystem::path const& repo_path) noexcept - -> GitCASPtr { +auto GitCAS::Open(std::filesystem::path const& repo_path, + LogLevel log_failure) noexcept -> GitCASPtr { #ifdef BOOTSTRAP_BUILD_TOOL return nullptr; #else @@ -70,7 +69,7 @@ auto GitCAS::Open(std::filesystem::path const& repo_path) noexcept GIT_REPOSITORY_OPEN_NO_SEARCH, nullptr) != 0 or repo_ptr == nullptr) { - Logger::Log(LogLevel::Error, + Logger::Log(log_failure, "Opening git repository {} failed with:\n{}", repo_path.string(), GitLastError()); @@ -81,7 +80,7 @@ auto GitCAS::Open(std::filesystem::path const& repo_path) noexcept git_odb* odb_ptr = nullptr; if (git_repository_odb(&odb_ptr, result->repo_.get()) != 0 or odb_ptr == nullptr) { - Logger::Log(LogLevel::Error, + Logger::Log(log_failure, "Obtaining git object database {} failed with:\n{}", repo_path.string(), GitLastError()); @@ -97,7 +96,7 @@ auto GitCAS::Open(std::filesystem::path const& repo_path) noexcept try { result->git_path_ = std::filesystem::absolute(git_path); } catch (std::exception const& e) { - Logger::Log(LogLevel::Error, + Logger::Log(log_failure, "Failed to obtain absolute path for {}: {}", git_path.string(), e.what()); diff --git a/src/buildtool/file_system/git_cas.hpp b/src/buildtool/file_system/git_cas.hpp index 0b104f54..f63fd543 100644 --- a/src/buildtool/file_system/git_cas.hpp +++ b/src/buildtool/file_system/git_cas.hpp @@ -25,6 +25,7 @@ #include "gsl/gsl" #include "src/buildtool/file_system/git_utils.hpp" #include "src/buildtool/file_system/object_type.hpp" +#include "src/buildtool/logging/log_level.hpp" class GitCAS; using GitCASPtr = std::shared_ptr<GitCAS const>; @@ -33,7 +34,8 @@ using GitCASPtr = std::shared_ptr<GitCAS const>; class GitCAS { public: [[nodiscard]] static auto Open( - std::filesystem::path const& repo_path) noexcept -> GitCASPtr; + std::filesystem::path const& repo_path, + LogLevel log_failure = LogLevel::Warning) noexcept -> GitCASPtr; [[nodiscard]] static auto CreateEmpty() noexcept -> GitCASPtr; |