From 002f875c53408cc2bd85b8e7ff10c397a697473d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Wed, 21 Jun 2017 03:05:37 +0200 Subject: [PATCH] Lowered default message logging priority to info. --- app/main.cpp | 2 +- src/plasp/output/Logger.cpp | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index 66564dc..6930f99 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -31,7 +31,7 @@ int main(int argc, char **argv) ("parsing-mode", po::value()->default_value("strict"), "Parsing mode (strict, compatibility)") ("language,l", po::value()->default_value("auto"), "Input language (pddl, sas, auto)") ("color", po::value()->default_value("auto"), "Colorize output (always, never, auto)") - ("log-priority,p", po::value()->default_value("warning"), "Log messages starting from this priority (debug, info, warning, error)") + ("log-priority,p", po::value()->default_value("info"), "Log messages starting from this priority (debug, info, warning, error)") ("warnings-as-errors", po::bool_switch(&warningsAsErrors), "Treat warnings as errors"); po::positional_options_description positionalOptionsDescription; diff --git a/src/plasp/output/Logger.cpp b/src/plasp/output/Logger.cpp index 9c0c37e..9f2b3f7 100644 --- a/src/plasp/output/Logger.cpp +++ b/src/plasp/output/Logger.cpp @@ -57,7 +57,7 @@ Logger::Logger(ColorStream &&outputStream) Logger::Logger(ColorStream &&outputStream, ColorStream &&errorStream) : m_outputStream{outputStream}, m_errorStream{errorStream}, - m_logPriority{Priority::Warning}, + m_logPriority{Priority::Info}, m_abortPriority{Priority::Error} { } @@ -104,14 +104,20 @@ void Logger::log(Priority priority, const char *message) { const auto priorityID = static_cast(priority); - if (priorityID < static_cast(m_logPriority)) + if (priorityID < static_cast(m_logPriority) && + priorityID < static_cast(m_abortPriority)) + { return; + } m_errorStream << priorityFormat(priority) << priorityName(priority) << ":" << ResetFormat() << " " << MessageBodyFormat << message << ResetFormat() << std::endl; + + if (priority != Priority::Error && priorityID >= static_cast(m_abortPriority)) + throw std::runtime_error("received warning (treated as error by configuration)"); } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -144,7 +150,8 @@ void Logger::log(Priority priority, const tokenize::Location &location, const ch << ResetFormat() << std::endl; // TODO: print original warning message - if (priorityID >= static_cast(m_abortPriority)) + // TODO: refactor + if (priority != Priority::Error && priorityID >= static_cast(m_abortPriority)) throw std::runtime_error("received warning (treated as error by configuration)"); }