mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 07:34:15 +02:00
Added support for logging.
This commit is contained in:
parent
b291bf3cfc
commit
a368030a80
@ -177,6 +177,8 @@ Component::RefType Application::LoadComponent(string name)
|
|||||||
if (component.get() != NULL)
|
if (component.get() != NULL)
|
||||||
return component;
|
return component;
|
||||||
|
|
||||||
|
Log("Loading component '%s'", name.c_str());
|
||||||
|
|
||||||
ConfigObject::RefType componentConfig = m_ConfigHive->GetObject("component", name);
|
ConfigObject::RefType componentConfig = m_ConfigHive->GetObject("component", name);
|
||||||
|
|
||||||
if (componentConfig.get() == NULL) {
|
if (componentConfig.get() == NULL) {
|
||||||
@ -230,9 +232,24 @@ void Application::UnloadComponent(string name)
|
|||||||
if (ci == m_Components.end())
|
if (ci == m_Components.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Log("Unloading component '%s'", name.c_str());
|
||||||
|
|
||||||
Component::RefType component = ci->second;
|
Component::RefType component = ci->second;
|
||||||
component->Stop();
|
component->Stop();
|
||||||
m_Components.erase(ci);
|
m_Components.erase(ci);
|
||||||
|
|
||||||
// TODO: unload DLL
|
// TODO: unload DLL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::Log(const char *format, ...)
|
||||||
|
{
|
||||||
|
char message[512];
|
||||||
|
va_list marker;
|
||||||
|
|
||||||
|
va_start(marker, format);
|
||||||
|
vsnprintf(message, sizeof(message), format, marker);
|
||||||
|
va_end(marker);
|
||||||
|
|
||||||
|
// TODO: log to file
|
||||||
|
fprintf(stderr, "%s\n", message);
|
||||||
|
}
|
@ -32,6 +32,8 @@ public:
|
|||||||
bool Daemonize(void);
|
bool Daemonize(void);
|
||||||
void Shutdown(void);
|
void Shutdown(void);
|
||||||
|
|
||||||
|
void Log(const char *format, ...);
|
||||||
|
|
||||||
ConfigHive::RefType GetConfigHive(void);
|
ConfigHive::RefType GetConfigHive(void);
|
||||||
|
|
||||||
shared_ptr<Component> LoadComponent(string name);
|
shared_ptr<Component> LoadComponent(string name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user