common/Log.hpp | 2 ++ wsd/LOOLWSD.cpp | 42 ++++++++++++++++++++++++------------------ wsd/Storage.cpp | 12 ++++++------ 3 files changed, 32 insertions(+), 24 deletions(-)
New commits: commit e9614fc697ae3d38ca83a7ce2bcea8cea536e481 Author: Ashod Nakashian <[email protected]> Date: Sat Mar 11 14:42:34 2017 -0500 wsd: support logging file and line with logger objects Change-Id: Ibf82105d91ece29c0a4742c6b2e81f6b179c0be4 Reviewed-on: https://gerrit.libreoffice.org/35081 Reviewed-by: Ashod Nakashian <[email protected]> Tested-by: Ashod Nakashian <[email protected]> diff --git a/common/Log.hpp b/common/Log.hpp index e4cc34d..2ad4e5d 100644 --- a/common/Log.hpp +++ b/common/Log.hpp @@ -185,6 +185,8 @@ namespace Log #define LOG_FTL(X) do { auto& l_ = Log::logger(); if (l_.fatal()) { LOG_BODY_(FATAL, "FTL", X); } } while (false) #define LOG_SFL(X) do { auto& l_ = Log::logger(); if (l_.error()) { LOG_BODY_(FATAL, "FTL", X << " (errno: " << std::strerror(errno) << ")"); } } while (false) +#define LOG_END(l) do { l << __FILE__ << ':' << __LINE__; l.flush(); } while (false) + #define LOG_CHECK(X) do { if (!(X)) { LOG_ERR("Check failed. Expected (" #X ")."); } } while (false) #define LOG_CHECK_RET(X, RET) do { if (!(X)) { LOG_ERR("Check failed. Expected (" #X ")."); return RET; } } while (false) diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index cdf6518..eb06f5f 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -1508,17 +1508,20 @@ private: request.read(message); auto logger = Log::info(); - // logger << "Request from " << request.clientAddress().toString() << ": " - logger << "Prisoner request : " - << request.getMethod() << " " << request.getURI() << " " - << request.getVersion(); - - for (const auto& it : request) + if (logger.enabled()) { - logger << " / " << it.first << ": " << it.second; - } + logger << "Prisoner HTTP Request: " + << request.getMethod() << ' ' + << request.getURI() << ' ' + << request.getVersion(); + + for (const auto& it : request) + { + logger << " / " << it.first << ": " << it.second; + } - logger << Log::end; + LOG_END(logger); + } LOG_TRC("Child connection with URI [" << request.getURI() << "]."); if (request.getURI().find(NEW_CHILD_URI) != 0) @@ -1678,17 +1681,20 @@ private: request.read(message); auto logger = Log::info(); - // logger << "Request from " << request.clientAddress().toString() << ": " - logger << "Request : " - << request.getMethod() << " " << request.getURI() << " " - << request.getVersion(); - - for (const auto& it : request) + if (logger.enabled()) { - logger << " / " << it.first << ": " << it.second; - } + logger << "Client HTTP Request: " + << request.getMethod() << ' ' + << request.getURI() << ' ' + << request.getVersion(); + + for (const auto& it : request) + { + logger << " / " << it.first << ": " << it.second; + } - logger << Log::end; + LOG_END(logger); + } const std::streamsize contentLength = request.getContentLength(); const auto offset = itBody - in.begin(); diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp index 8e7868f..9d2f991 100644 --- a/wsd/Storage.cpp +++ b/wsd/Storage.cpp @@ -379,16 +379,16 @@ std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Po std::istream& rs = psession->receiveResponse(response); callDuration = (std::chrono::steady_clock::now() - startTime); - if (Log::traceEnabled()) + auto logger = Log::trace(); + if (logger.enabled()) { - auto logger = Log::trace(); logger << "WOPI::CheckFileInfo header for URI [" << uriPublic.toString() << "]:\n"; for (const auto& pair : response) { logger << '\t' << pair.first << ": " << pair.second << " / "; } - logger << Log::end; + LOG_END(logger); } Poco::StreamCopier::copyToString(rs, resMsg); @@ -496,16 +496,16 @@ std::string WopiStorage::loadStorageFileToLocal() const std::chrono::duration<double> diff = (std::chrono::steady_clock::now() - startTime); _wopiLoadDuration += diff; - if (Log::traceEnabled()) + auto logger = Log::trace(); + if (logger.enabled()) { - auto logger = Log::trace(); logger << "WOPI::GetFile header for URI [" << uriObject.toString() << "]:\n"; for (const auto& pair : response) { logger << '\t' << pair.first << ": " << pair.second << " / "; } - logger << Log::end; + LOG_END(logger); } _jailedFilePath = Poco::Path(getLocalRootPath(), _fileInfo._filename).toString(); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
