From a368030a80442998e50b807ab2005fdf85e858e9 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Sun, 1 Apr 2012 09:30:08 +0200 Subject: [PATCH] Added support for logging. --- base/application.cpp | 17 +++++++++++++++++ base/application.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/base/application.cpp b/base/application.cpp index 838b74fbc..a56019d0a 100644 --- a/base/application.cpp +++ b/base/application.cpp @@ -177,6 +177,8 @@ Component::RefType Application::LoadComponent(string name) if (component.get() != NULL) return component; + Log("Loading component '%s'", name.c_str()); + ConfigObject::RefType componentConfig = m_ConfigHive->GetObject("component", name); if (componentConfig.get() == NULL) { @@ -230,9 +232,24 @@ void Application::UnloadComponent(string name) if (ci == m_Components.end()) return; + Log("Unloading component '%s'", name.c_str()); + Component::RefType component = ci->second; component->Stop(); m_Components.erase(ci); // 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); +} \ No newline at end of file diff --git a/base/application.h b/base/application.h index 110f5dd08..a71e883fc 100644 --- a/base/application.h +++ b/base/application.h @@ -32,6 +32,8 @@ public: bool Daemonize(void); void Shutdown(void); + void Log(const char *format, ...); + ConfigHive::RefType GetConfigHive(void); shared_ptr LoadComponent(string name); -- 2.40.0