summaryrefslogtreecommitdiffstats
path: root/Source/cmMessageCommand.cxx
diff options
context:
space:
mode:
authorAlex Turbov <i.zaufi@gmail.com>2019-10-12 02:37:15 (GMT)
committerCraig Scott <craig.scott@crascit.com>2019-10-12 07:21:36 (GMT)
commit7cf79f44195a86a907dba770f1f7a361d00e77c2 (patch)
treea8c9b970b55979ec5eecce59aadab91036941235 /Source/cmMessageCommand.cxx
parent5bf85e25178f5d9f19d2f30cf66f088c21e1114a (diff)
downloadCMake-7cf79f44195a86a907dba770f1f7a361d00e77c2.zip
CMake-7cf79f44195a86a907dba770f1f7a361d00e77c2.tar.gz
CMake-7cf79f44195a86a907dba770f1f7a361d00e77c2.tar.bz2
message: Support logging a context with each message
Diffstat (limited to 'Source/cmMessageCommand.cxx')
-rw-r--r--Source/cmMessageCommand.cxx25
1 files changed, 17 insertions, 8 deletions
diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx
index 5fee5ca..24ac71a 100644
--- a/Source/cmMessageCommand.cxx
+++ b/Source/cmMessageCommand.cxx
@@ -112,16 +112,25 @@ bool cmMessageCommand(std::vector<std::string> const& args,
auto message = cmJoin(cmMakeRange(i, args.cend()), "");
if (cmake::LogLevel::LOG_NOTICE <= level) {
- // Check if any indentation has requested:
- // `CMAKE_MESSAGE_INDENT` is a list of "padding" pieces
- // to be joined and prepended to the message lines.
auto indent =
cmJoin(cmExpandedList(mf.GetSafeDefinition("CMAKE_MESSAGE_INDENT")), "");
- // Make every line of the `message` indented
- // NOTE Can't reuse `cmDocumentationFormatter::PrintPreformatted`
- // here cuz it appends `\n` to the EOM ;-(
- cmSystemTools::ReplaceString(message, "\n", "\n" + indent);
- message = indent + message;
+ if (!indent.empty()) {
+ cmSystemTools::ReplaceString(message, "\n", "\n" + indent);
+ message = indent + message;
+ }
+
+ const auto showContext = mf.GetCMakeInstance()->GetShowLogContext() ||
+ mf.IsOn("CMAKE_MESSAGE_CONTEXT_SHOW");
+ if (showContext) {
+ // Output the current context (if any)
+ auto context = cmJoin(
+ cmExpandedList(mf.GetSafeDefinition("CMAKE_MESSAGE_CONTEXT")), ".");
+ if (!context.empty()) {
+ context = "[" + context + "] ";
+ cmSystemTools::ReplaceString(message, "\n", "\n" + context);
+ message = context + message;
+ }
+ }
}
switch (level) {