From 10caf1e1fba66899ddf9b4d047cd21e04e21142e Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Fri, 25 Apr 2025 09:18:46 +0200 Subject: just-mr: support custom message with invocation-directory name Allow to specify a custom string that is extended by the basename of the logging directory, in case invocation logging is activated. This can be used, e.g., to point to the user to service doing something useful with the logged data (or simply presenting it in a nicer form). --- src/other_tools/just_mr/cli.hpp | 1 + src/other_tools/just_mr/launch.cpp | 6 ++++++ src/other_tools/just_mr/rc.cpp | 5 +++++ 3 files changed, 12 insertions(+) (limited to 'src') diff --git a/src/other_tools/just_mr/cli.hpp b/src/other_tools/just_mr/cli.hpp index de1ac9d0..dd1586a4 100644 --- a/src/other_tools/just_mr/cli.hpp +++ b/src/other_tools/just_mr/cli.hpp @@ -92,6 +92,7 @@ struct MultiRepoGcArguments { // Arguments for invocation logging; set only via rc files struct InvocationLogArguments { std::optional directory{std::nullopt}; + std::optional invocation_msg{std::nullopt}; std::optional project_id{std::nullopt}; std::optional metadata{std::nullopt}; std::optional graph_file{std::nullopt}; diff --git a/src/other_tools/just_mr/launch.cpp b/src/other_tools/just_mr/launch.cpp index 76272213..cb0f70d2 100644 --- a/src/other_tools/just_mr/launch.cpp +++ b/src/other_tools/just_mr/launch.cpp @@ -285,6 +285,12 @@ auto CallJust(std::optional const& config_file, "{:%Y-%m-%d-%H:%M}-{}", fmt::gmtime(invocation_time), uuid); dir = dir / invocation_id; if (FileSystemManager::CreateDirectoryExclusive(dir)) { + if (invocation_log.invocation_msg) { + Logger::Log(LogLevel::Info, + "{}{}", + *invocation_log.invocation_msg, + invocation_id); + } Logger::Log( LogLevel::Info, "Invocation logged at {}", dir.string()); log_dir = dir; diff --git a/src/other_tools/just_mr/rc.cpp b/src/other_tools/just_mr/rc.cpp index bcb217cf..5baf302c 100644 --- a/src/other_tools/just_mr/rc.cpp +++ b/src/other_tools/just_mr/rc.cpp @@ -624,6 +624,11 @@ namespace { if (profile->IsString()) { clargs->invocation_log.profile = profile->String(); } + auto msg = + invocation_log->Get("invocation message", Expression::none_t{}); + if (msg->IsString()) { + clargs->invocation_log.invocation_msg = msg->String(); + } } } // read config lookup order -- cgit v1.2.3