Implemented new command-line options replacing --warning-level.
This commit is contained in:
@@ -57,7 +57,8 @@ Logger::Logger(ColorStream &&outputStream)
|
||||
Logger::Logger(ColorStream &&outputStream, ColorStream &&errorStream)
|
||||
: m_outputStream{outputStream},
|
||||
m_errorStream{errorStream},
|
||||
m_logPriority{Priority::Warning}
|
||||
m_logPriority{Priority::Warning},
|
||||
m_abortPriority{Priority::Error}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -66,7 +67,8 @@ Logger::Logger(ColorStream &&outputStream, ColorStream &&errorStream)
|
||||
Logger::Logger(Logger &&other)
|
||||
: m_outputStream{std::move(other.m_outputStream)},
|
||||
m_errorStream{std::move(other.m_errorStream)},
|
||||
m_logPriority{other.m_logPriority}
|
||||
m_logPriority{other.m_logPriority},
|
||||
m_abortPriority{other.m_abortPriority}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -102,6 +104,13 @@ void Logger::setLogPriority(Priority logPriority)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Logger::setAbortPriority(Priority abortPriority)
|
||||
{
|
||||
m_abortPriority = abortPriority;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Logger::setColorPolicy(ColorStream::ColorPolicy colorPolicy)
|
||||
{
|
||||
m_outputStream.setColorPolicy(colorPolicy);
|
||||
@@ -137,8 +146,12 @@ void Logger::log(Priority priority, const input::Location &location, const char
|
||||
{
|
||||
const auto priorityID = static_cast<int>(priority);
|
||||
|
||||
if (priorityID < static_cast<int>(m_logPriority))
|
||||
// Always show messages that lead to program termination
|
||||
if (priorityID < static_cast<int>(m_logPriority) &&
|
||||
priorityID < static_cast<int>(m_abortPriority))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_errorStream
|
||||
<< LocationFormat
|
||||
@@ -148,6 +161,10 @@ void Logger::log(Priority priority, const input::Location &location, const char
|
||||
<< ResetFormat() << " "
|
||||
<< MessageBodyFormat << message
|
||||
<< ResetFormat() << std::endl;
|
||||
|
||||
// TODO: print original warning message
|
||||
if (priorityID >= static_cast<int>(m_abortPriority))
|
||||
throw std::runtime_error("received warning (treated as error by configuration)");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
Reference in New Issue
Block a user