mirror of https://github.com/Icinga/icinga2.git
Merge pull request #6663 from Icinga/feature/silence-logging-runtime-object-creation
Silence config compiler logging for runtime created objects
This commit is contained in:
commit
13c75b7113
|
@ -158,11 +158,11 @@ std::vector<ApplyRule>& ApplyRule::GetRules(const String& type)
|
|||
return it->second;
|
||||
}
|
||||
|
||||
void ApplyRule::CheckMatches()
|
||||
void ApplyRule::CheckMatches(bool silent)
|
||||
{
|
||||
for (const RuleMap::value_type& kv : m_Rules) {
|
||||
for (const ApplyRule& rule : kv.second) {
|
||||
if (!rule.HasMatches())
|
||||
if (!rule.HasMatches() && !silent)
|
||||
Log(LogWarning, "ApplyRule")
|
||||
<< "Apply rule '" << rule.GetName() << "' (" << rule.GetDebugInfo() << ") for type '" << kv.first << "' does not match anywhere!";
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
static bool IsValidTargetType(const String& sourceType, const String& targetType);
|
||||
static std::vector<String> GetTargetTypes(const String& sourceType);
|
||||
|
||||
static void CheckMatches();
|
||||
static void CheckMatches(bool silent);
|
||||
|
||||
private:
|
||||
String m_TargetType;
|
||||
|
|
|
@ -618,7 +618,7 @@ bool ConfigItem::CommitItems(const ActivationContext::Ptr& context, WorkQueue& u
|
|||
return false;
|
||||
}
|
||||
|
||||
ApplyRule::CheckMatches();
|
||||
ApplyRule::CheckMatches(silent);
|
||||
|
||||
if (!silent) {
|
||||
/* log stats for external parsers */
|
||||
|
|
|
@ -143,7 +143,8 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
|
|||
|
||||
std::vector<ConfigItem::Ptr> newItems;
|
||||
|
||||
if (!ConfigItem::CommitItems(ascope.GetContext(), upq, newItems) || !ConfigItem::ActivateItems(upq, newItems, true)) {
|
||||
/* Disable logging for object creation, but do so ourselves later on. */
|
||||
if (!ConfigItem::CommitItems(ascope.GetContext(), upq, newItems, true) || !ConfigItem::ActivateItems(upq, newItems, true, true)) {
|
||||
if (errors) {
|
||||
if (unlink(path.CStr()) < 0 && errno != ENOENT) {
|
||||
BOOST_THROW_EXCEPTION(posix_error()
|
||||
|
@ -164,6 +165,10 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
|
|||
}
|
||||
|
||||
ApiListener::UpdateObjectAuthority();
|
||||
|
||||
Log(LogInformation, "ConfigObjectUtility")
|
||||
<< "Created and activated object '" << fullName << "' of type '" << type->GetName() << "'.";
|
||||
|
||||
} catch (const std::exception& ex) {
|
||||
if (unlink(path.CStr()) < 0 && errno != ENOENT) {
|
||||
BOOST_THROW_EXCEPTION(posix_error()
|
||||
|
|
Loading…
Reference in New Issue