wsd: FileServer logging updated

Change-Id: Ia797c6c8f9068805d85f066030f8110f0affb7f4
Reviewed-on: https://gerrit.libreoffice.org/32286
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
This commit is contained in:
Ashod Nakashian 2016-12-19 18:24:03 -05:00 committed by Ashod Nakashian
parent 07b917f97e
commit a3de232c7a
2 changed files with 13 additions and 19 deletions

View file

@ -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: */

View file

@ -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