Added support for logging.

This commit is contained in:
Gunnar Beutner 2012-04-01 09:30:08 +02:00
parent b291bf3cfc
commit a368030a80
2 changed files with 19 additions and 0 deletions

View File

@ -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);
}

View File

@ -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);