mirror of https://github.com/Icinga/icinga2.git
config: Count errors and warnings.
This commit is contained in:
parent
826a56ba20
commit
d1c194632b
|
@ -25,6 +25,7 @@
|
||||||
#include "base/timer.h"
|
#include "base/timer.h"
|
||||||
#include "base/utility.h"
|
#include "base/utility.h"
|
||||||
#include "base/exception.h"
|
#include "base/exception.h"
|
||||||
|
#include "base/convert.h"
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
#include <boost/tuple/tuple.hpp>
|
#include <boost/tuple/tuple.hpp>
|
||||||
#include <boost/smart_ptr/make_shared.hpp>
|
#include <boost/smart_ptr/make_shared.hpp>
|
||||||
|
@ -66,11 +67,27 @@ static bool LoadConfigFiles(bool validateOnly)
|
||||||
|
|
||||||
bool result = ConfigItem::ActivateItems(validateOnly);
|
bool result = ConfigItem::ActivateItems(validateOnly);
|
||||||
|
|
||||||
|
int warnings = 0, errors = 0;
|
||||||
|
|
||||||
BOOST_FOREACH(const ConfigCompilerMessage& message, ConfigCompilerContext::GetInstance()->GetMessages()) {
|
BOOST_FOREACH(const ConfigCompilerMessage& message, ConfigCompilerContext::GetInstance()->GetMessages()) {
|
||||||
if (message.Error)
|
if (message.Error) {
|
||||||
Log(LogCritical, "config", "Config error: " + message.Text);
|
Log(LogCritical, "config", "Config error: " + message.Text);
|
||||||
else
|
errors++;
|
||||||
|
} else {
|
||||||
Log(LogWarning, "config", "Config warning: " + message.Text);
|
Log(LogWarning, "config", "Config warning: " + message.Text);
|
||||||
|
warnings++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (warnings > 0 || errors > 0) {
|
||||||
|
LogSeverity severity;
|
||||||
|
|
||||||
|
if (errors == 0)
|
||||||
|
severity = LogWarning;
|
||||||
|
else
|
||||||
|
severity = LogCritical;
|
||||||
|
|
||||||
|
Log(severity, "config", Convert::ToString(errors) + " errors, " + Convert::ToString(warnings) + " warnings.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
|
|
Loading…
Reference in New Issue