From: Gunnar Beutner Date: Thu, 26 Apr 2012 10:58:20 +0000 (+0200) Subject: Make Application::Log static and add more logging. X-Git-Tag: v0.0.1~580^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e35b14f9a4154c7d6875b96cb7fc226bc2896702;p=icinga2 Make Application::Log static and add more logging. --- diff --git a/base/application.h b/base/application.h index 164c0d47c..912ef4336 100644 --- a/base/application.h +++ b/base/application.h @@ -35,7 +35,7 @@ public: void Shutdown(void); - void Log(const char *format, ...); + static void Log(const char *format, ...); ConfigHive::Ptr GetConfigHive(void) const; diff --git a/icinga/endpointmanager.cpp b/icinga/endpointmanager.cpp index 348e36147..7649ed3b9 100644 --- a/icinga/endpointmanager.cpp +++ b/icinga/endpointmanager.cpp @@ -9,6 +9,8 @@ EndpointManager::EndpointManager(shared_ptr sslContext) void EndpointManager::AddListener(unsigned short port) { + Application::Log("Adding new listener: port %d", port); + JsonRpcServer::Ptr server = make_shared(m_SSLContext); RegisterServer(server); @@ -20,6 +22,8 @@ void EndpointManager::AddListener(unsigned short port) void EndpointManager::AddConnection(string host, unsigned short port) { + Application::Log("Adding new endpoint: %s:%d", host.c_str(), port); + JsonRpcEndpoint::Ptr endpoint = make_shared(); endpoint->Connect(host, port, m_SSLContext); RegisterEndpoint(endpoint); @@ -33,6 +37,8 @@ void EndpointManager::RegisterServer(JsonRpcServer::Ptr server) int EndpointManager::NewClientHandler(const NewClientEventArgs& ncea) { + Application::Log("Accepted new client"); + JsonRpcEndpoint::Ptr endpoint = make_shared(); endpoint->SetClient(static_pointer_cast(ncea.Client)); RegisterEndpoint(endpoint); diff --git a/icinga/icingaapplication.cpp b/icinga/icingaapplication.cpp index 833d561e4..6683ccd13 100644 --- a/icinga/icingaapplication.cpp +++ b/icinga/icingaapplication.cpp @@ -131,8 +131,6 @@ int IcingaApplication::NewRpcListenerHandler(const EventArgs& ea) port = (unsigned short)portValue; - Log("Creating JSON-RPC listener on port %d", port); - GetEndpointManager()->AddListener(port); return 0; @@ -167,8 +165,6 @@ int IcingaApplication::NewRpcConnectionHandler(const EventArgs& ea) port = (unsigned short)portValue; - Log("Creating JSON-RPC connection to %s:%d", hostname.c_str(), port); - GetEndpointManager()->AddConnection(hostname, port); return 0; diff --git a/icinga/jsonrpcendpoint.cpp b/icinga/jsonrpcendpoint.cpp index 9a51fde28..25e3d10ce 100644 --- a/icinga/jsonrpcendpoint.cpp +++ b/icinga/jsonrpcendpoint.cpp @@ -141,6 +141,9 @@ int JsonRpcEndpoint::NewMessageHandler(const NewMessageEventArgs& nmea) int JsonRpcEndpoint::ClientClosedHandler(const EventArgs& ea) { + string address = GetAddress(); + Application::Log("Lost connection to endpoint: %s", address.c_str()); + m_PendingCalls.clear(); if (m_Client->GetPeerHost() != string()) { @@ -150,6 +153,8 @@ int JsonRpcEndpoint::ClientClosedHandler(const EventArgs& ea) timer->OnTimerExpired += bind_weak(&JsonRpcEndpoint::ClientReconnectHandler, shared_from_this()); timer->Start(); m_ReconnectTimer = timer; + + Application::Log("Spawned reconnect timer (30 seconds)", address.c_str()); } // TODO: _only_ clear non-persistent method sources/sinks