diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-02-27 10:49:59 +0100 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-02-27 11:39:45 +0100 |
commit | f9241e0e94b1094b12fc58ad212cdf02d021b992 (patch) | |
tree | c21623358167a21872aebed8aa0c23ee155a7410 /src | |
parent | bd657023d6da9fbc60b64d4b53db005f347dc874 (diff) | |
download | justbuild-f9241e0e94b1094b12fc58ad212cdf02d021b992.tar.gz |
Logging: Add --log-append clarg to just-mr and enable log forwarding to just
When calling just from just-mr, all logging arguments are forwarded
as early arguments. If any log files are provided, an unconditional
--log-append is also prepended to ensure the contents of the log files
are not overwritten.
Diffstat (limited to 'src')
-rw-r--r-- | src/other_tools/just_mr/cli.hpp | 5 | ||||
-rw-r--r-- | src/other_tools/just_mr/main.cpp | 21 |
2 files changed, 24 insertions, 2 deletions
diff --git a/src/other_tools/just_mr/cli.hpp b/src/other_tools/just_mr/cli.hpp index 30a9032b..2174c331 100644 --- a/src/other_tools/just_mr/cli.hpp +++ b/src/other_tools/just_mr/cli.hpp @@ -48,6 +48,7 @@ struct MultiRepoLogArguments { std::vector<std::filesystem::path> log_files{}; LogLevel log_limit{kDefaultLogLevel}; bool plain_log{false}; + bool log_append{false}; }; struct MultiRepoSetupArguments { @@ -156,6 +157,10 @@ static inline auto SetupMultiRepoLogArguments( app->add_flag("--plain-log", clargs->plain_log, "Do not use ANSI escape sequences to highlight messages."); + app->add_flag( + "--log-append", + clargs->log_append, + "Append messages to log file instead of overwriting existing."); } static inline void SetupMultiRepoSetupArguments( diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp index 3888dddb..66fce212 100644 --- a/src/other_tools/just_mr/main.cpp +++ b/src/other_tools/just_mr/main.cpp @@ -185,8 +185,10 @@ void SetupLogging(MultiRepoLogArguments const& clargs) { LogConfig::SetLogLimit(clargs.log_limit); LogConfig::SetSinks({LogSinkCmdLine::CreateFactory(not clargs.plain_log)}); for (auto const& log_file : clargs.log_files) { - LogConfig::AddSink( - LogSinkFile::CreateFactory(log_file, LogSinkFile::Mode::Overwrite)); + LogConfig::AddSink(LogSinkFile::CreateFactory( + log_file, + clargs.log_append ? LogSinkFile::Mode::Append + : LogSinkFile::Mode::Overwrite)); } } @@ -1087,6 +1089,21 @@ void DefaultReachableRepositories( cmd.emplace_back("--local-build-root"); cmd.emplace_back(*arguments.common.just_mr_paths->root); } + // forward logging arguments + if (not arguments.log.log_files.empty()) { + cmd.emplace_back("--log-append"); + for (auto const& log_file : arguments.log.log_files) { + cmd.emplace_back("-f"); + cmd.emplace_back(log_file.string()); + } + } + cmd.emplace_back("--log-limit"); + cmd.emplace_back( + std::to_string(static_cast<std::underlying_type<LogLevel>::type>( + arguments.log.log_limit))); + if (arguments.log.plain_log) { + cmd.emplace_back("--plain-log"); + } // add args read from just-mrrc if (subcommand and arguments.just_cmd.just_args.contains(*subcommand)) { for (auto const& subcmd_arg : |