diff options
author | Alex Turbov <i.zaufi@gmail.com> | 2019-04-27 17:31:03 +1000 |
---|---|---|
committer | Craig Scott <craig.scott@crascit.com> | 2019-04-28 22:45:44 +1000 |
commit | 6cc93b370ef59208b9b468ebc9d84cc02e3cbd85 (patch) | |
tree | d3dfd8c1ae2826e369ce504ffb483388cb6ddeaf /Source/cmMessageCommand.cxx | |
parent | 377d1b7896e07a171bcfe8da6d9dcda6545052c2 (diff) | |
download | cmake-6cc93b370ef59208b9b468ebc9d84cc02e3cbd85.tar.gz |
message(): Add support for log levels
Relates: #18943
Co-Authored-By: Craig Scott <craig.scott@crascit.com>
Diffstat (limited to 'Source/cmMessageCommand.cxx')
-rw-r--r-- | Source/cmMessageCommand.cxx | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx index 2724030c24..724203736e 100644 --- a/Source/cmMessageCommand.cxx +++ b/Source/cmMessageCommand.cxx @@ -8,6 +8,9 @@ #include "cmMessenger.h" #include "cmRange.h" #include "cmSystemTools.h" +#include "cmake.h" + +#include <cassert> class cmExecutionStatus; @@ -24,41 +27,80 @@ bool cmMessageCommand::InitialPass(std::vector<std::string> const& args, MessageType type = MessageType::MESSAGE; bool status = false; bool fatal = false; + auto level = cmake::LogLevel::LOG_UNDEFINED; if (*i == "SEND_ERROR") { type = MessageType::FATAL_ERROR; + level = cmake::LogLevel::LOG_ERROR; ++i; } else if (*i == "FATAL_ERROR") { fatal = true; type = MessageType::FATAL_ERROR; + level = cmake::LogLevel::LOG_ERROR; ++i; } else if (*i == "WARNING") { type = MessageType::WARNING; + level = cmake::LogLevel::LOG_WARNING; ++i; } else if (*i == "AUTHOR_WARNING") { if (this->Makefile->IsSet("CMAKE_SUPPRESS_DEVELOPER_ERRORS") && !this->Makefile->IsOn("CMAKE_SUPPRESS_DEVELOPER_ERRORS")) { fatal = true; type = MessageType::AUTHOR_ERROR; + level = cmake::LogLevel::LOG_ERROR; } else if (!this->Makefile->IsOn("CMAKE_SUPPRESS_DEVELOPER_WARNINGS")) { type = MessageType::AUTHOR_WARNING; + level = cmake::LogLevel::LOG_WARNING; } else { return true; } ++i; } else if (*i == "STATUS") { status = true; + level = cmake::LogLevel::LOG_STATUS; + ++i; + } else if (*i == "VERBOSE") { + status = true; + level = cmake::LogLevel::LOG_VERBOSE; + ++i; + } else if (*i == "DEBUG") { + status = true; + level = cmake::LogLevel::LOG_DEBUG; + ++i; + } else if (*i == "TRACE") { + status = true; + level = cmake::LogLevel::LOG_TRACE; ++i; } else if (*i == "DEPRECATION") { if (this->Makefile->IsOn("CMAKE_ERROR_DEPRECATED")) { fatal = true; type = MessageType::DEPRECATION_ERROR; + level = cmake::LogLevel::LOG_ERROR; } else if ((!this->Makefile->IsSet("CMAKE_WARN_DEPRECATED") || this->Makefile->IsOn("CMAKE_WARN_DEPRECATED"))) { type = MessageType::DEPRECATION_WARNING; + level = cmake::LogLevel::LOG_WARNING; } else { return true; } ++i; + } else if (*i == "NOTICE") { + // `NOTICE` message type is going to be output to stderr + level = cmake::LogLevel::LOG_NOTICE; + ++i; + } else { + // Messages w/o any type are `NOTICE`s + level = cmake::LogLevel::LOG_NOTICE; + } + assert("Message log level expected to be set" && + level != cmake::LogLevel::LOG_UNDEFINED); + + auto desiredLevel = this->Makefile->GetCMakeInstance()->GetLogLevel(); + assert("Expected a valid log level here" && + desiredLevel != cmake::LogLevel::LOG_UNDEFINED); + + if (desiredLevel < level) { + // Suppress the message + return true; } std::string message = cmJoin(cmMakeRange(i, args.end()), std::string()); |