[Libreoffice-commits] online.git: wsd/FileServer.cpp wsd/FileServer.hpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Wed Dec 21 15:01:10 UTC 2016


 wsd/FileServer.cpp |   26 +++++++++++++-------------
 wsd/FileServer.hpp |    6 ------
 2 files changed, 13 insertions(+), 19 deletions(-)

New commits:
commit a3de232c7a39d57c82891b7d6f75f87c69c46119
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Mon Dec 19 18:24:03 2016 -0500

    wsd: FileServer logging updated
    
    Change-Id: Ia797c6c8f9068805d85f066030f8110f0affb7f4
    Reviewed-on: https://gerrit.libreoffice.org/32286
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp
index f74f80f..b79c376 100644
--- a/wsd/FileServer.cpp
+++ b/wsd/FileServer.cpp
@@ -60,19 +60,19 @@ bool FileServerRequestHandler::isAdminLoggedIn(HTTPServerRequest& request, HTTPS
     try
     {
         const std::string jwtToken = cookies.get("jwt");
-        Log::info("Verifying JWT token: " + jwtToken);
+        LOG_INF("Verifying JWT token: " << jwtToken);
         JWTAuth authAgent(sslKeyPath, "admin", "admin", "admin");
         if (authAgent.verify(jwtToken))
         {
-            Log::trace("JWT token is valid");
+            LOG_TRC("JWT token is valid");
             return true;
         }
 
-        Log::info("Invalid JWT token, let the administrator re-login");
+        LOG_INF("Invalid JWT token, let the administrator re-login");
     }
     catch (const Poco::Exception& exc)
     {
-        Log::info("No existing JWT cookie found");
+        LOG_INF("No existing JWT cookie found");
     }
 
     // If no cookie found, or is invalid, let admin re-login
@@ -80,7 +80,7 @@ bool FileServerRequestHandler::isAdminLoggedIn(HTTPServerRequest& request, HTTPS
     const auto pass = config.getString("admin_console.password", "");
     if (user.empty() || pass.empty())
     {
-        Log::error("Admin Console credentials missing. Denying access until set.");
+        LOG_ERR("Admin Console credentials missing. Denying access until set.");
         return false;
     }
 
@@ -100,7 +100,7 @@ bool FileServerRequestHandler::isAdminLoggedIn(HTTPServerRequest& request, HTTPS
         return true;
     }
 
-    Log::info("Wrong admin credentials.");
+    LOG_INF("Wrong admin credentials.");
     return false;
 }
 
@@ -109,7 +109,7 @@ void FileServerRequestHandler::handleRequest(HTTPServerRequest& request, HTTPSer
     try
     {
         Poco::URI requestUri(request.getURI());
-        Log::trace("Fileserver request: " + requestUri.toString());
+        LOG_TRC("Fileserver request: " << requestUri.toString());
         requestUri.normalize(); // avoid .'s and ..'s
 
         std::vector<std::string> requestSegments;
@@ -169,7 +169,7 @@ void FileServerRequestHandler::handleRequest(HTTPServerRequest& request, HTTPSer
     }
     catch (const Poco::Net::NotAuthenticatedException& exc)
     {
-        Log::error("FileServerRequestHandler::NotAuthenticated: " + exc.displayText());
+        LOG_ERR("FileServerRequestHandler::NotAuthenticated: " << exc.displayText());
         response.set("WWW-Authenticate", "Basic realm=\"online\"");
         response.setStatusAndReason(HTTPResponse::HTTP_UNAUTHORIZED);
         response.setContentLength(0);
@@ -177,14 +177,14 @@ void FileServerRequestHandler::handleRequest(HTTPServerRequest& request, HTTPSer
     }
     catch (const Poco::FileAccessDeniedException& exc)
     {
-        Log::error("FileServerRequestHandler: " + exc.displayText());
+        LOG_ERR("FileServerRequestHandler: " << exc.displayText());
         response.setStatusAndReason(HTTPResponse::HTTP_FORBIDDEN);
         response.setContentLength(0); // TODO return some 403 page?
         response.send();
     }
     catch (const Poco::FileNotFoundException& exc)
     {
-        Log::error("FileServerRequestHandler: " + exc.displayText());
+        LOG_ERR("FileServerRequestHandler: " << exc.displayText());
         response.setStatusAndReason(HTTPResponse::HTTP_NOT_FOUND);
         response.setContentLength(0); // TODO return some 404 page?
         response.send();
@@ -211,11 +211,11 @@ void FileServerRequestHandler::preprocessFile(HTTPServerRequest& request, HTTPSe
 
     const auto host = ((LOOLWSD::isSSLEnabled() || LOOLWSD::isSSLTermination()) ? "wss://" : "ws://") + (LOOLWSD::ServerName.empty() ? request.getHost() : LOOLWSD::ServerName);
     const auto path = Poco::Path(LOOLWSD::FileServerRoot, getRequestPathname(request));
-    Log::debug("Preprocessing file: " + path.toString());
+    LOG_DBG("Preprocessing file: " << path.toString());
 
     if (!Poco::File(path).exists())
     {
-        Log::error("File [" + path.toString() + "] does not exist.");
+        LOG_ERR("File [" << path.toString() << "] does not exist.");
         response.setStatusAndReason(HTTPResponse::HTTP_NOT_FOUND);
         response.setContentLength(0); // TODO return some 404 page?
         response.send();
@@ -275,7 +275,7 @@ void FileServerRequestHandler::preprocessFile(HTTPServerRequest& request, HTTPSe
 
 FileServer::FileServer()
 {
-    Log::info("FileServer ctor.");
+    LOG_INF("FileServer ctor.");
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/wsd/FileServer.hpp b/wsd/FileServer.hpp
index 20a9c8f..afa89fc 100644
--- a/wsd/FileServer.hpp
+++ b/wsd/FileServer.hpp
@@ -13,16 +13,10 @@
 #include "config.h"
 
 #include <string>
-#include <vector>
 
-#include <Poco/Net/HTTPRequest.h>
 #include <Poco/Net/HTTPRequestHandler.h>
-#include <Poco/Net/HTTPServer.h>
 #include <Poco/Net/HTTPServerRequest.h>
 #include <Poco/Net/HTTPServerResponse.h>
-#include <Poco/Net/SecureServerSocket.h>
-
-#include "Log.hpp"
 
 /// Handles file requests over HTTP(S).
 class FileServerRequestHandler : public Poco::Net::HTTPRequestHandler


More information about the Libreoffice-commits mailing list