diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/common/cli.hpp | 11 | ||||
-rw-r--r-- | src/buildtool/main/main.cpp | 3 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/buildtool/common/cli.hpp b/src/buildtool/common/cli.hpp index cfe2263a..cf348bff 100644 --- a/src/buildtool/common/cli.hpp +++ b/src/buildtool/common/cli.hpp @@ -19,8 +19,10 @@ #include <cstddef> #include <cstdlib> #include <filesystem> +#include <optional> #include <string> #include <thread> +#include <type_traits> #include <vector> #include "CLI/CLI.hpp" @@ -47,6 +49,7 @@ struct CommonArguments { struct LogArguments { std::vector<std::filesystem::path> log_files{}; LogLevel log_limit{kDefaultLogLevel}; + std::optional<LogLevel> restrict_stderr_log_limit{}; bool plain_log{false}; bool log_append{false}; }; @@ -249,6 +252,14 @@ static inline auto SetupLogArguments( static_cast<int>(kLastLogLevel), static_cast<int>(kDefaultLogLevel))) ->type_name("NUM"); + app->add_option_function<std::underlying_type_t<LogLevel>>( + "--restrict-stderr-log-limit", + [clargs](auto const& limit) { + clargs->restrict_stderr_log_limit = ToLogLevel(limit); + }, + "Restrict logging on console to the minimum of the specified " + "--log-limit and this value") + ->type_name("NUM"); app->add_flag("--plain-log", clargs->plain_log, "Do not use ANSI escape sequences to highlight messages."); diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp index 18beff58..21f08618 100644 --- a/src/buildtool/main/main.cpp +++ b/src/buildtool/main/main.cpp @@ -87,7 +87,8 @@ void SetupDefaultLogging() { void SetupLogging(LogArguments const& clargs) { LogConfig::SetLogLimit(clargs.log_limit); - LogConfig::SetSinks({LogSinkCmdLine::CreateFactory(not clargs.plain_log)}); + LogConfig::SetSinks({LogSinkCmdLine::CreateFactory( + not clargs.plain_log, clargs.restrict_stderr_log_limit)}); for (auto const& log_file : clargs.log_files) { LogConfig::AddSink(LogSinkFile::CreateFactory( log_file, |