summaryrefslogtreecommitdiff
path: root/src/other_tools/just_mr/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/other_tools/just_mr/main.cpp')
-rw-r--r--src/other_tools/just_mr/main.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp
index 6e114a49..8c238f71 100644
--- a/src/other_tools/just_mr/main.cpp
+++ b/src/other_tools/just_mr/main.cpp
@@ -18,6 +18,7 @@
#include "src/buildtool/build_engine/expression/configuration.hpp"
#include "src/buildtool/logging/log_config.hpp"
#include "src/buildtool/logging/log_sink_cmdline.hpp"
+#include "src/buildtool/logging/log_sink_file.hpp"
#include "src/other_tools/just_mr/cli.hpp"
#include "src/other_tools/just_mr/exit_codes.hpp"
#include "src/other_tools/ops_maps/git_update_map.hpp"
@@ -39,6 +40,7 @@ enum class SubCommand {
struct CommandLineArguments {
SubCommand cmd{SubCommand::kUnknown};
MultiRepoCommonArguments common;
+ MultiRepoLogArguments log;
MultiRepoSetupArguments setup;
MultiRepoFetchArguments fetch;
MultiRepoUpdateArguments update;
@@ -55,6 +57,7 @@ void SetupCommonCommandArguments(
gsl::not_null<CLI::App*> const& app,
gsl::not_null<CommandLineArguments*> const& clargs) {
SetupMultiRepoCommonArguments(app, &clargs->common);
+ SetupMultiRepoLogArguments(app, &clargs->log);
}
/// \brief Setup arguments for subcommand "just-mr fetch".
@@ -80,11 +83,6 @@ void SetupSetupCommandArguments(
SetupMultiRepoSetupArguments(app, &clargs->setup);
}
-void SetupDefaultLogging() {
- LogConfig::SetLogLimit(kDefaultLogLevel);
- LogConfig::SetSinks({LogSinkCmdLine::CreateFactory()});
-}
-
[[nodiscard]] auto ParseCommandLineArguments(int argc, char const* const* argv)
-> CommandLineArguments {
CLI::App app("just-mr");
@@ -171,6 +169,20 @@ void SetupDefaultLogging() {
return clargs;
}
+void SetupDefaultLogging() {
+ LogConfig::SetLogLimit(kDefaultLogLevel);
+ LogConfig::SetSinks({LogSinkCmdLine::CreateFactory()});
+}
+
+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));
+ }
+}
+
[[nodiscard]] auto ReadLocation(
nlohmann::json const& location,
std::optional<std::filesystem::path> const& ws_root)
@@ -1110,6 +1122,7 @@ auto main(int argc, char* argv[]) -> int {
// get the user-defined arguments
auto arguments = ParseCommandLineArguments(argc, argv);
+ SetupLogging(arguments.log);
auto config_file = ReadJustMRRC(&arguments);
if (arguments.common.repository_config) {
config_file = arguments.common.repository_config;