]> granicus.if.org Git - icinga2/commitdiff
Improve log messages for HTTP requests
authorGunnar Beutner <gunnar@beutner.name>
Wed, 30 Sep 2015 06:41:09 +0000 (08:41 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Wed, 30 Sep 2015 06:41:09 +0000 (08:41 +0200)
refs #9074

icinga-studio/apiclient.cpp [moved from icinga-studio/api.cpp with 100% similarity]
icinga-studio/apiclient.hpp [moved from icinga-studio/api.hpp with 100% similarity]
lib/remote/apilistener-configsync.cpp
lib/remote/apilistener.cpp
lib/remote/httpserverconnection.cpp

index 6d1ddc13e6f2f01afcc9950511e0a8b4e8fe8a2f..9f904df5f8859de5114361132c6f5d32e30f17b7 100644 (file)
@@ -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);
index f1288dcafd73bf4c44f3a04557e19f47681ffbc3..b8b879dbd57e7b8b7316b815368a5fd255810ecb 100644 (file)
@@ -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();
index 13f321df4d410081b5d759dfaac2ecb23d75ca02..740cb4ce644dc954ac31395c21866711dde51399 100644 (file)
@@ -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() : "<unauthenticated>") << ")";
+
        HttpResponse response(m_Stream, request);
 
        if (!user) {