]> granicus.if.org Git - icinga2/commitdiff
Improve error logging on connection failure (cluster) 7005/head
authorMichael Friedrich <michael.friedrich@icinga.com>
Mon, 1 Apr 2019 14:13:37 +0000 (16:13 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Mon, 1 Apr 2019 14:13:37 +0000 (16:13 +0200)
lib/remote/apilistener.cpp

index 6da42b68cac514ca98f7544f797eabb93597c6de..de6e754c01f369102a88e6ff7c6e5650629e5782 100644 (file)
@@ -413,7 +413,8 @@ void ApiListener::ListenerCoroutineProc(boost::asio::yield_context yc, const std
 
                        asio::spawn(io, [this, sslConn](asio::yield_context yc) { NewClientHandler(yc, sslConn, String(), RoleServer); });
                } catch (const std::exception& ex) {
-                       Log(LogCritical, "ApiListener") << "Cannot accept new connection: " << DiagnosticInformation(ex, false);
+                       Log(LogCritical, "ApiListener")
+                               << "Cannot accept new connection: " << DiagnosticInformation(ex, false);
                }
        }
 }
@@ -457,11 +458,8 @@ void ApiListener::AddConnection(const Endpoint::Ptr& endpoint)
                } catch (const std::exception& ex) {
                        endpoint->SetConnecting(false);
 
-                       std::ostringstream info;
-                       info << "Cannot connect to host '" << host << "' on port '" << port << "'";
-                       Log(LogCritical, "ApiListener", info.str());
-                       Log(LogDebug, "ApiListener")
-                               << info.str() << "\n" << DiagnosticInformation(ex);
+                       Log(LogCritical, "ApiListener")
+                               << "Cannot connect to host '" << host << "' on port '" << port << "': " << ex.what();
                }
        });
 }