mirror of
https://github.com/Icinga/icinga2.git
synced 2025-09-24 02:07:53 +02:00
Introduce Logger#object_filter
This commit is contained in:
parent
d55c3644a2
commit
aaa06575af
@ -74,6 +74,47 @@ void Logger::Stop(bool runtimeRemoved)
|
|||||||
ObjectImpl<Logger>::Stop(runtimeRemoved);
|
ObjectImpl<Logger>::Stop(runtimeRemoved);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Logger::ValidateObjectFilter(const Lazy<Dictionary::Ptr>& lvalue, const ValidationUtils& utils)
|
||||||
|
{
|
||||||
|
ObjectImpl<Logger>::ValidateObjectFilter(lvalue, utils);
|
||||||
|
|
||||||
|
auto filter (lvalue());
|
||||||
|
|
||||||
|
if (filter) {
|
||||||
|
ObjectLock lock (filter);
|
||||||
|
|
||||||
|
for (auto& kv : filter) {
|
||||||
|
auto type (Type::GetByName(kv.first));
|
||||||
|
|
||||||
|
if (!type) {
|
||||||
|
BOOST_THROW_EXCEPTION(
|
||||||
|
ValidationError(this, {"object_filter"}, "No such type: '" + kv.first + "'")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dynamic_cast<ConfigType*>(type.get())) {
|
||||||
|
BOOST_THROW_EXCEPTION(
|
||||||
|
ValidationError(this, {"object_filter"}, "Not a config object type: '" + kv.first + "'")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Array::Ptr objects = kv.second;
|
||||||
|
|
||||||
|
if (objects) {
|
||||||
|
ObjectLock lock (objects);
|
||||||
|
|
||||||
|
for (auto& object : objects) {
|
||||||
|
if (object.GetType() != ValueString) {
|
||||||
|
BOOST_THROW_EXCEPTION(
|
||||||
|
ValidationError(this, {"object_filter", kv.first}, "Must be an array of strings.")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::set<Logger::Ptr> Logger::GetLoggers()
|
std::set<Logger::Ptr> Logger::GetLoggers()
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(m_Mutex);
|
std::unique_lock<std::mutex> lock(m_Mutex);
|
||||||
|
@ -92,6 +92,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void Start(bool runtimeCreated) override;
|
void Start(bool runtimeCreated) override;
|
||||||
void Stop(bool runtimeRemoved) override;
|
void Stop(bool runtimeRemoved) override;
|
||||||
|
void ValidateObjectFilter(const Lazy<Dictionary::Ptr>& lvalue, const ValidationUtils& utils) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void UpdateMinLogSeverity();
|
static void UpdateMinLogSeverity();
|
||||||
|
@ -12,6 +12,13 @@ abstract class Logger : ConfigObject
|
|||||||
[config, set_virtual] String severity {
|
[config, set_virtual] String severity {
|
||||||
default {{{ return "information"; }}}
|
default {{{ return "information"; }}}
|
||||||
};
|
};
|
||||||
|
[config] Dictionary::Ptr object_filter;
|
||||||
|
};
|
||||||
|
|
||||||
|
validator Logger {
|
||||||
|
Dictionary object_filter {
|
||||||
|
Array "*";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user