mirror of https://github.com/Icinga/icinga2.git
Make Application::Log static and add more logging.
This commit is contained in:
parent
0d8b352150
commit
e35b14f9a4
|
@ -35,7 +35,7 @@ public:
|
|||
|
||||
void Shutdown(void);
|
||||
|
||||
void Log(const char *format, ...);
|
||||
static void Log(const char *format, ...);
|
||||
|
||||
ConfigHive::Ptr GetConfigHive(void) const;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue