From c434ab9221dd1b6aa8a8fe1a65d99dcd767a5202 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Mon, 4 May 2020 01:24:47 -0400 Subject: [PATCH] adjusted some log levels --- src/context.cpp | 2 +- src/op.cpp | 18 +++++++++--------- src/process.cpp | 14 ++++++++++---- src/process.h | 10 ++++++---- src/tools/cmake.cpp | 4 ++-- src/tools/downloader.cpp | 2 +- src/tools/git.cpp | 6 +++--- src/tools/jom.cpp | 8 ++++++-- src/tools/msbuild.cpp | 4 ++-- src/tools/patcher.cpp | 2 +- 10 files changed, 41 insertions(+), 29 deletions(-) diff --git a/src/context.cpp b/src/context.cpp index d7e7353..9a272b0 100644 --- a/src/context.cpp +++ b/src/context.cpp @@ -233,7 +233,7 @@ std::string context::make_log_string(reason r, level, std::string_view s) const if (s.empty()) oss << "interrupted"; else - oss << s << " (interrupted)"; + oss << s; break; diff --git a/src/op.cpp b/src/op.cpp index f74d578..a7e9a3b 100644 --- a/src/op.cpp +++ b/src/op.cpp @@ -19,7 +19,7 @@ void check(const context& cx, const fs::path& p); void touch(const context& cx, const fs::path& p) { - cx.debug(context::fs, "touching " + p.string()); + cx.trace(context::fs, "touching " + p.string()); check(cx, p); if (!conf::dry()) @@ -28,7 +28,7 @@ void touch(const context& cx, const fs::path& p) void create_directories(const context& cx, const fs::path& p) { - cx.debug(context::fs, "creating dir " + p.string()); + cx.trace(context::fs, "creating dir " + p.string()); check(cx, p); if (!conf::dry()) @@ -37,7 +37,7 @@ void create_directories(const context& cx, const fs::path& p) void delete_directory(const context& cx, const fs::path& p, flags f) { - cx.debug(context::fs, "deleting dir " + p.string()); + cx.trace(context::fs, "deleting dir " + p.string()); check(cx, p); if (!fs::exists(p)) @@ -63,7 +63,7 @@ void delete_directory(const context& cx, const fs::path& p, flags f) void delete_file(const context& cx, const fs::path& p, flags f) { - cx.debug(context::fs, "deleting file " + p.string()); + cx.trace(context::fs, "deleting file " + p.string()); check(cx, p); if (!fs::exists(p)) @@ -92,7 +92,7 @@ void delete_file(const context& cx, const fs::path& p, flags f) void remove_readonly(const context& cx, const fs::path& first) { - cx.debug(context::fs, "removing read-only from " + first.string()); + cx.trace(context::fs, "removing read-only from " + first.string()); check(cx, first); if (!conf::dry()) @@ -194,7 +194,7 @@ void rename(const context& cx, const fs::path& src, const fs::path& dest) "already exists"); } - cx.debug(context::fs, "renaming " + src.string() + " to " + dest.string()); + cx.trace(context::fs, "renaming " + src.string() + " to " + dest.string()); do_rename(cx, src, dest); } @@ -213,7 +213,7 @@ void move_to_directory( src.filename().string() + " already exists"); } - cx.debug(context::fs, "moving " + src.string() + " to " + target.string()); + cx.trace(context::fs, "moving " + src.string() + " to " + target.string()); do_rename(cx, src, target); } @@ -252,7 +252,7 @@ void copy_file_to_dir_if_better( const auto target = dir / file.filename(); if (is_source_better(cx, file, target)) { - cx.debug(context::fs, file.string() + " -> " + dir.string()); + cx.trace(context::fs, file.string() + " -> " + dir.string()); if (!conf::dry()) do_copy_file_to_dir(cx, file, dir); @@ -310,7 +310,7 @@ void do_delete_directory(const context& cx, const fs::path& p) { if (ec.value() == ERROR_ACCESS_DENIED) { - cx.debug( + cx.trace( context::fs, "got access denied trying to delete dir " + p.string() + ", " "trying to remove read-only flag recursively"); diff --git a/src/process.cpp b/src/process.cpp index cd73e5d..88e9983 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -413,7 +413,7 @@ void process::join() GetExitCodeProcess(impl_.handle.get(), &code_); - cx_->debug(context::cmd, + cx_->trace(context::cmd, "process completed, exit code " + std::to_string(code_)); if (impl_.interrupt) @@ -423,7 +423,7 @@ void process::join() { if (flags_ & allow_failure) { - cx_->debug(context::cmd, + cx_->trace(context::cmd, "process failed but failure was allowed"); } else @@ -532,10 +532,16 @@ int process::exit_code() const void process::add_arg(const std::string& k, const std::string& v, arg_flags f) { - if ((f & verbose) && !conf::log_trace()) + if ((f & log_debug) && !conf::log_debug()) return; - if ((f & quiet) && conf::log_trace()) + if ((f & log_trace) && !conf::log_trace()) + return; + + if ((f & log_dump) && !conf::log_dump()) + return; + + if ((f & log_quiet) && conf::log_trace()) return; if (k.empty() && v.empty()) diff --git a/src/process.h b/src/process.h index 01613e8..73f9f7f 100644 --- a/src/process.h +++ b/src/process.h @@ -47,10 +47,12 @@ public: enum arg_flags { noargflags = 0x00, - verbose = 0x01, - quiet = 0x02, - nospace = 0x04, - quote = 0x08 + log_debug = 0x01, + log_trace = 0x02, + log_dump = 0x04, + log_quiet = 0x08, + nospace = 0x10, + quote = 0x20 }; struct filter diff --git a/src/tools/cmake.cpp b/src/tools/cmake.cpp index b594822..00d8436 100644 --- a/src/tools/cmake.cpp +++ b/src/tools/cmake.cpp @@ -66,8 +66,8 @@ void cmake::do_run() process_ .arg("-G", "\"" + g.name + "\"") .arg("-DCMAKE_BUILD_TYPE=Release") - .arg("-DCMAKE_INSTALL_MESSAGE=NEVER", process::quiet) - .arg("--log-level", "WARNING", process::quiet) + .arg("-DCMAKE_INSTALL_MESSAGE=NEVER", process::log_quiet) + .arg("--log-level", "WARNING", process::log_quiet) .arg(g.get_arch(arch_)); if (!prefix_.empty()) diff --git a/src/tools/downloader.cpp b/src/tools/downloader.cpp index a96e6bc..7409c14 100644 --- a/src/tools/downloader.cpp +++ b/src/tools/downloader.cpp @@ -69,7 +69,7 @@ void downloader::do_run() { const fs::path file = path_for_url(u); - cx_->debug(context::net, + cx_->trace(context::net, "trying " + u.string() + " into " + file.string()); dl_->start(u, file); diff --git a/src/tools/git.cpp b/src/tools/git.cpp index eb88f07..e523492 100644 --- a/src/tools/git.cpp +++ b/src/tools/git.cpp @@ -55,8 +55,8 @@ void git_clone::clone() .arg("--recurse-submodules") .arg("--depth", "1") .arg("--branch", branch_) - .arg("--quiet", process::quiet) - .arg("-c", "advice.detachedHead=false", process::quiet) + .arg("--quiet", process::log_quiet) + .arg("-c", "advice.detachedHead=false", process::log_quiet) .arg(url_) .arg(where_); @@ -69,7 +69,7 @@ void git_clone::pull() .binary(third_party::git()) .arg("pull") .arg("--recurse-submodules") - .arg("--quiet", process::quiet) + .arg("--quiet", process::log_quiet) .arg(url_) .arg(branch_) .cwd(where_); diff --git a/src/tools/jom.cpp b/src/tools/jom.cpp index 6247e01..636399a 100644 --- a/src/tools/jom.cpp +++ b/src/tools/jom.cpp @@ -60,8 +60,12 @@ void jom::do_run() if (f.line.find("empower your cores") != std::string::npos) f.lv = context::level::trace; }) - .arg("/C", process::quiet) - .arg("/S", process::quiet) + .arg("/C", process::log_quiet) + .arg("/S", process::log_quiet) + .arg("/L", process::log_quiet) + .arg("/D", process::log_dump) + .arg("/P", process::log_dump) + .arg("/W", process::log_dump) .arg("/K"); if (flags_ & single_job) diff --git a/src/tools/msbuild.cpp b/src/tools/msbuild.cpp index 4bb216a..3d0a9af 100644 --- a/src/tools/msbuild.cpp +++ b/src/tools/msbuild.cpp @@ -87,8 +87,8 @@ void msbuild::do_run() .arg("-property:PlatformToolset=" + toolset) .arg("-property:WindowsTargetPlatformVersion=" + versions::sdk()) .arg("-property:Platform=", plat, process::quote) - .arg("-verbosity:minimal", process::quiet) - .arg("-consoleLoggerParameters:ErrorsOnly", process::quiet); + .arg("-verbosity:minimal", process::log_quiet) + .arg("-consoleLoggerParameters:ErrorsOnly", process::log_quiet); if (!projects_.empty()) process_.arg("-target:" + mob::join(projects_, ",")); diff --git a/src/tools/patcher.cpp b/src/tools/patcher.cpp index 722c96e..3ac620d 100644 --- a/src/tools/patcher.cpp +++ b/src/tools/patcher.cpp @@ -90,7 +90,7 @@ void patcher::do_patch(const fs::path& patch_file) .arg("--read-only", "ignore") .arg("--strip", "0") .arg("--directory", output_) - .arg("--quiet", process::quiet); + .arg("--quiet", process::log_quiet); const auto check = process(base) .flags(process::allow_failure)