-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0015-verbose-Logger-Add-LogLevel-Verbose.patch
244 lines (233 loc) · 11.4 KB
/
0015-verbose-Logger-Add-LogLevel-Verbose.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
From: Oliver Reiche <[email protected]>
Date: Sun, 21 Jan 2024 20:00:32 +0100
Subject: [verbose] Logger: Add LogLevel::Verbose
... and use it for verbose output and action commands.
---
src/buildtool/common/cli.hpp | 6 ++++++
.../execution_engine/executor/executor.hpp | 2 +-
.../graph_traverser/graph_traverser.hpp | 6 +++---
src/buildtool/logging/log_level.hpp | 3 +++
src/buildtool/logging/log_sink_cmdline.hpp | 3 +++
src/buildtool/main/main.cpp | 18 +++++++++---------
.../exports_progress_reporter.cpp | 2 +-
src/other_tools/just_mr/cli.hpp | 6 ++++++
src/other_tools/just_mr/launch.cpp | 5 +++--
src/other_tools/just_mr/main.cpp | 6 ++++++
src/other_tools/just_mr/setup.cpp | 2 +-
11 files changed, 42 insertions(+), 17 deletions(-)
diff --git a/src/buildtool/common/cli.hpp b/src/buildtool/common/cli.hpp
--- a/src/buildtool/common/cli.hpp
+++ b/src/buildtool/common/cli.hpp
@@ -262,6 +262,12 @@ static inline auto SetupLogArguments(
static_cast<int>(kLastLogLevel),
static_cast<int>(kDefaultLogLevel)))
->type_name("NUM");
+ app->add_flag_function(
+ "-v,--verbose",
+ [clargs](auto /*unused*/) { clargs->log_limit = LogLevel::Verbose; },
+ fmt::format(
+ "Enable verbose command line output (shortcut for --log-limit={})",
+ static_cast<int>(LogLevel::Verbose)));
app->add_option_function<std::underlying_type_t<LogLevel>>(
"--restrict-stderr-log-limit",
[clargs](auto const& limit) {
diff --git a/src/buildtool/execution_engine/executor/executor.hpp b/src/buildtool/execution_engine/executor/executor.hpp
--- a/src/buildtool/execution_engine/executor/executor.hpp
+++ b/src/buildtool/execution_engine/executor/executor.hpp
@@ -673,7 +673,7 @@ class ExecutorImpl {
}
return message;
};
- logger.Emit((has_err or has_out) ? LogLevel::Info : LogLevel::Debug,
+ logger.Emit((has_err or has_out) ? LogLevel::Info : LogLevel::Verbose,
std::move(build_message));
}
diff --git a/src/buildtool/graph_traverser/graph_traverser.hpp b/src/buildtool/graph_traverser/graph_traverser.hpp
--- a/src/buildtool/graph_traverser/graph_traverser.hpp
+++ b/src/buildtool/graph_traverser/graph_traverser.hpp
@@ -598,7 +598,7 @@ class GraphTraverser {
std::vector<DependencyGraph::ArtifactNode const*> const& artifact_nodes,
std::map<std::string, ArtifactDescription> const& runfiles) const {
std::string msg_dbg{"Artifact ids:"};
- std::string msg_failed{"Failed artifacts:"};
+ std::string msg_failed{"Build result contains failed artifacts:"};
bool failed{false};
nlohmann::json json{};
for (std::size_t pos = 0; pos < paths.size(); ++pos) {
@@ -639,7 +639,7 @@ class GraphTraverser {
Logger::Log(logger_, LogLevel::Info, "{}", message);
Logger::Log(logger_, LogLevel::Debug, "{}", msg_dbg);
if (failed) {
- Logger::Log(logger_, LogLevel::Info, "{}", msg_failed);
+ Logger::Log(logger_, LogLevel::Warning, "{}", msg_failed);
}
if (clargs_.build.dump_artifacts) {
@@ -693,7 +693,7 @@ class GraphTraverser {
if ((not relpath.empty()) and *relpath.begin() != "..") {
Logger::Log(
logger_,
- LogLevel::Info,
+ LogLevel::Verbose,
"'{}' not a direct logical path of the specified "
"target; will take subobject '{}' of '{}'",
*(clargs_.build.print_to_stdout),
diff --git a/src/buildtool/logging/log_level.hpp b/src/buildtool/logging/log_level.hpp
--- a/src/buildtool/logging/log_level.hpp
+++ b/src/buildtool/logging/log_level.hpp
@@ -29,6 +29,7 @@ enum class LogLevel : std::uint8_t {
Info, ///< Informative messages, such as reporting status or statistics
Progress, ///< Information about the current progress of the build
Performance, ///< Information about performance issues
+ Verbose, ///< Verbose information for advanced users
Debug, ///< Debug messages, such as details from internal processes
Trace ///< Trace messages, verbose details such as function calls
};
@@ -72,6 +73,8 @@ constexpr auto kLastLogLevel = LogLevel::Trace;
return "";
case LogLevel::Performance:
return "PERF";
+ case LogLevel::Verbose:
+ return "INFO";
case LogLevel::Debug:
return "DEBUG";
case LogLevel::Trace:
diff --git a/src/buildtool/logging/log_sink_cmdline.hpp b/src/buildtool/logging/log_sink_cmdline.hpp
--- a/src/buildtool/logging/log_sink_cmdline.hpp
+++ b/src/buildtool/logging/log_sink_cmdline.hpp
@@ -139,6 +139,9 @@ class LogSinkCmdLine final : public ILogSink {
case LogLevel::Performance:
style = fg(fmt::color::light_sky_blue);
break;
+ case LogLevel::Verbose:
+ style = fg(fmt::color::lime_green);
+ break;
case LogLevel::Debug:
style = fg(fmt::color::sky_blue);
break;
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp
--- a/src/buildtool/main/main.cpp
+++ b/src/buildtool/main/main.cpp
@@ -571,6 +571,9 @@ auto DetermineRoots(gsl::not_null<RepositoryConfig*> const& repository_config,
}
if (main_ws_root.has_value()) {
ws_root = FileRoot{*main_ws_root};
+ Logger::Log(LogLevel::Verbose,
+ "Using workspace root {}",
+ main_ws_root->string());
}
}
if (not ws_root) {
@@ -665,7 +668,8 @@ auto DetermineRoots(gsl::not_null<RepositoryConfig*> const& repository_config,
return {main_repo, main_ws_root};
}
-void ReportTaintedness(const AnalysisResult& result) {
+void ReportTaintedness(const AnalysisResult& result,
+ LogLevel level = LogLevel::Info) {
if (result.target->Tainted().empty()) {
// Never report untainted targets
return;
@@ -676,7 +680,7 @@ void ReportTaintedness(const AnalysisResult& result) {
for (auto const& s : result.target->Tainted()) {
tainted.push_back(s);
}
- Logger::Log(LogLevel::Info, "Target tainted {}.", tainted.dump());
+ Logger::Log(level, "Target tainted {}.", tainted.dump());
}
auto DetermineNonExplicitTarget(
@@ -1184,7 +1188,7 @@ auto main(int argc, char* argv[]) -> int {
os << serve_errors.dump() << std::endl;
}
if (result) {
- Logger::Log(LogLevel::Info,
+ Logger::Log(LogLevel::Verbose,
"Analysed target {}",
result->id.ToShortString(
Evaluator::GetExpressionLogLimit()));
@@ -1250,7 +1254,7 @@ auto main(int argc, char* argv[]) -> int {
}
Logger::Log(
- LogLevel::Info,
+ LogLevel::Verbose,
"{}ing{} {}.",
arguments.cmd == SubCommand::kRebuild ? "Rebuild" : "Build",
result->modified ? fmt::format(" input of action {} of",
@@ -1281,11 +1285,7 @@ auto main(int argc, char* argv[]) -> int {
// Repeat taintedness message to make the user aware that
// the artifacts are not for production use.
- ReportTaintedness(*result);
- if (build_result->failed_artifacts) {
- Logger::Log(LogLevel::Warning,
- "Build result contains failed artifacts.");
- }
+ ReportTaintedness(*result, LogLevel::Verbose);
return build_result->failed_artifacts
? kExitSuccessFailedArtifacts
: kExitSuccess;
diff --git a/src/buildtool/progress_reporting/exports_progress_reporter.cpp b/src/buildtool/progress_reporting/exports_progress_reporter.cpp
--- a/src/buildtool/progress_reporting/exports_progress_reporter.cpp
+++ b/src/buildtool/progress_reporting/exports_progress_reporter.cpp
@@ -49,6 +49,6 @@ auto ExportsProgressReporter::Reporter(gsl::not_null<Statistics*> const& stats,
msg = fmt::format(
"{} ({}{})", msg, sample, active > 1 ? ", ..." : "");
}
- Logger::Log(logger, LogLevel::Progress, "{}", msg);
+ Logger::Log(logger, LogLevel::Verbose, "{}", msg);
});
}
diff --git a/src/other_tools/just_mr/cli.hpp b/src/other_tools/just_mr/cli.hpp
--- a/src/other_tools/just_mr/cli.hpp
+++ b/src/other_tools/just_mr/cli.hpp
@@ -282,6 +282,12 @@ static inline auto SetupMultiRepoLogArguments(
static_cast<int>(kLastLogLevel),
static_cast<int>(kDefaultLogLevel)))
->type_name("NUM");
+ app->add_flag_function(
+ "-v,--verbose",
+ [clargs](auto /*unused*/) { clargs->log_limit = LogLevel::Verbose; },
+ fmt::format(
+ "Enable verbose command line output (shortcut for --log-limit={})",
+ static_cast<int>(LogLevel::Verbose)));
app->add_option_function<std::underlying_type_t<LogLevel>>(
"--restrict-stderr-log-limit",
[clargs](auto const& limit) {
diff --git a/src/other_tools/just_mr/launch.cpp b/src/other_tools/just_mr/launch.cpp
--- a/src/other_tools/just_mr/launch.cpp
+++ b/src/other_tools/just_mr/launch.cpp
@@ -265,8 +265,9 @@ auto CallJust(std::optional<std::filesystem::path> const& config_file,
cmd.emplace_back(*it);
}
- Logger::Log(
- LogLevel::Info, "Setup finished, call {}", nlohmann::json(cmd).dump());
+ Logger::Log(LogLevel::Verbose,
+ "Setup finished, call {}",
+ nlohmann::json(cmd).dump());
// create argv
std::vector<char*> argv{};
diff --git a/src/other_tools/just_mr/main.cpp b/src/other_tools/just_mr/main.cpp
--- a/src/other_tools/just_mr/main.cpp
+++ b/src/other_tools/just_mr/main.cpp
@@ -256,6 +256,12 @@ auto main(int argc, char* argv[]) -> int {
}
SetupLogging(arguments.log);
+ if (arguments.common.just_mr_paths->workspace_root) {
+ Logger::Log(
+ LogLevel::Verbose,
+ "Using setup root {}",
+ arguments.common.just_mr_paths->workspace_root->string());
+ }
auto config_file = ReadJustMRRC(&arguments);
// As the rc file can contain logging parameters, reset the logging
// configuration
diff --git a/src/other_tools/just_mr/setup.cpp b/src/other_tools/just_mr/setup.cpp
--- a/src/other_tools/just_mr/setup.cpp
+++ b/src/other_tools/just_mr/setup.cpp
@@ -74,7 +74,7 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
std::string const& multi_repo_tool_name)
-> std::optional<std::filesystem::path> {
// provide report
- Logger::Log(LogLevel::Info, "Performing repositories setup");
+ Logger::Log(LogLevel::Verbose, "Performing repositories setup");
// set anchor dir to setup_root; current dir will be reverted when anchor
// goes out of scope
auto cwd_anchor = FileSystemManager::ChangeDirectory(
--