From: Gunnar Beutner Date: Wed, 30 Sep 2015 06:41:09 +0000 (+0200) Subject: Improve log messages for HTTP requests X-Git-Tag: v2.4.0~246 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e4953dd35dab402f3ae7d5e019751a09be1721f;p=icinga2 Improve log messages for HTTP requests refs #9074 --- diff --git a/icinga-studio/api.cpp b/icinga-studio/apiclient.cpp similarity index 100% rename from icinga-studio/api.cpp rename to icinga-studio/apiclient.cpp diff --git a/icinga-studio/api.hpp b/icinga-studio/apiclient.hpp similarity index 100% rename from icinga-studio/api.hpp rename to icinga-studio/apiclient.hpp diff --git a/lib/remote/apilistener-configsync.cpp b/lib/remote/apilistener-configsync.cpp index 6d1ddc13e..9f904df5f 100644 --- a/lib/remote/apilistener-configsync.cpp +++ b/lib/remote/apilistener-configsync.cpp @@ -71,9 +71,12 @@ Value ApiListener::ConfigUpdateObjectAPIHandler(const MessageOrigin::Ptr& origin if (!listener) return Empty; + String objType = params->Get("type"); + String objName = params->Get("name"); + if (!listener->GetAcceptConfig()) { Log(LogWarning, "ApiListener") - << "Ignoring config update. '" << listener->GetName() << "' does not accept config."; + << "Ignoring config update for object '" << objName << "' of type '" << objType << "'. '" << listener->GetName() << "' does not accept config."; return Empty; } @@ -99,8 +102,6 @@ Value ApiListener::ConfigUpdateObjectAPIHandler(const MessageOrigin::Ptr& origin } /* update the object */ - String objType = params->Get("type"); - String objName = params->Get("name"); int objVersion = Convert::ToLong(params->Get("version")); ConfigType::Ptr dtype = ConfigType::GetByName(objType); diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index f1288dcaf..b8b879dbd 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -367,7 +367,7 @@ void ApiListener::NewClientHandlerInternal(const Socket::Ptr& client, const Stri } if (ctype == ClientJsonRpc) { - Log(LogInformation, "ApiListener", "New JSON-RPC client"); + Log(LogNotice, "ApiListener", "New JSON-RPC client"); JsonRpcConnection::Ptr aclient = new JsonRpcConnection(identity, verify_ok, tlsStream, role); aclient->Start(); @@ -392,7 +392,7 @@ void ApiListener::NewClientHandlerInternal(const Socket::Ptr& client, const Stri } else AddAnonymousClient(aclient); } else { - Log(LogInformation, "ApiListener", "New HTTP client"); + Log(LogNotice, "ApiListener", "New HTTP client"); HttpServerConnection::Ptr aclient = new HttpServerConnection(identity, verify_ok, tlsStream); aclient->Start(); diff --git a/lib/remote/httpserverconnection.cpp b/lib/remote/httpserverconnection.cpp index 13f321df4..740cb4ce6 100644 --- a/lib/remote/httpserverconnection.cpp +++ b/lib/remote/httpserverconnection.cpp @@ -115,8 +115,6 @@ bool HttpServerConnection::ProcessMessage(void) void HttpServerConnection::ProcessMessageAsync(HttpRequest& request) { - Log(LogInformation, "HttpServerConnection", "Processing Http message"); - String auth_header = request.Headers->Get("authorization"); String::SizeType pos = auth_header.FindFirstOf(" "); @@ -145,6 +143,10 @@ void HttpServerConnection::ProcessMessageAsync(HttpRequest& request) user.reset(); } + Log(LogInformation, "HttpServerConnection") + << "Request: " << request.RequestMethod << " " << request.RequestUrl->Format() + << " (" << (user ? user->GetName() : "") << ")"; + HttpResponse response(m_Stream, request); if (!user) {