]> granicus.if.org Git - icinga2/commitdiff
Make Application::Log static and add more logging.
authorGunnar Beutner <gunnar.beutner@netways.de>
Thu, 26 Apr 2012 10:58:20 +0000 (12:58 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Thu, 26 Apr 2012 10:58:20 +0000 (12:58 +0200)
base/application.h
icinga/endpointmanager.cpp
icinga/icingaapplication.cpp
icinga/jsonrpcendpoint.cpp

index 164c0d47c7dcb865d3664b9e7089f94dad7984c0..912ef433674124f7d84da9822fc7895d9ef1a6d2 100644 (file)
@@ -35,7 +35,7 @@ public:
 
        void Shutdown(void);
 
-       void Log(const char *format, ...);
+       static void Log(const char *format, ...);
 
        ConfigHive::Ptr GetConfigHive(void) const;
 
index 348e36147cef144b2ba9293c824ccdc475044a62..7649ed3b9fb2b8bc8fcd7d96226e34427a905fb1 100644 (file)
@@ -9,6 +9,8 @@ EndpointManager::EndpointManager(shared_ptr<SSL_CTX> sslContext)
 
 void EndpointManager::AddListener(unsigned short port)
 {
+       Application::Log("Adding new listener: port %d", port);
+
        JsonRpcServer::Ptr server = make_shared<JsonRpcServer>(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<JsonRpcEndpoint>();
        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<JsonRpcEndpoint>();
        endpoint->SetClient(static_pointer_cast<JsonRpcClient>(ncea.Client));
        RegisterEndpoint(endpoint);
index 833d561e47396562e499e8f9e021b9b5f2ba579e..6683ccd1379b4046bf10223c6cf71f23b59fbb2b 100644 (file)
@@ -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;
index 9a51fde28ddc87147bc72b6d50dc9c1ec6811989..25e3d10ce57522d52c3f23b46779d8c2cbedb545 100644 (file)
@@ -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