common/Log.cpp | 3 ++- common/Log.hpp | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-)
New commits: commit c2c5bd0e3e04181bf0a21a65b83f8455b7486039 Author: Michael Meeks <[email protected]> AuthorDate: Sat Apr 27 22:00:51 2019 +0100 Commit: Michael Meeks <[email protected]> CommitDate: Sat Apr 27 23:03:16 2019 +0200 Reset the stringstream properly. Avoids some N^2 log-line explosion; also make the method name more findable. Change-Id: I3ee8c521f1ac98a939cd4d758c720b577d3bfa57 Reviewed-on: https://gerrit.libreoffice.org/71443 Reviewed-by: Michael Meeks <[email protected]> Tested-by: Michael Meeks <[email protected]> diff --git a/common/Log.cpp b/common/Log.cpp index 46cfd6095..6b263263a 100644 --- a/common/Log.cpp +++ b/common/Log.cpp @@ -129,10 +129,11 @@ namespace Log // Reuse the same buffer to minimize memory fragmentation. static thread_local std::ostringstream Oss; - std::ostringstream& begin(const char* level) + std::ostringstream& beginLog(const char* level) { // Reset the oss. Oss.clear(); + Oss.str(std::string()); Oss.seekp(0); // Output the prefix. diff --git a/common/Log.hpp b/common/Log.hpp index f4a51d8da..cc4ef9d83 100644 --- a/common/Log.hpp +++ b/common/Log.hpp @@ -55,7 +55,7 @@ namespace Log char* prefix(char* buffer, std::size_t len, const char* level); /// Starts logging by generating the prefix and returning an oss. - std::ostringstream& begin(const char* level); + std::ostringstream& beginLog(const char* level); inline bool traceEnabled() { return logger().trace(); } inline bool debugEnabled() { return logger().debug(); } @@ -250,7 +250,7 @@ namespace Log #ifdef __ANDROID__ #define LOG_BODY_(LOG, PRIO, LVL, X, FILEP) \ - std::ostringstream& oss_ = Log::begin(LVL); \ + std::ostringstream& oss_ = Log::beginLog(LVL); \ oss_ << X; \ LOG_END(oss_, FILEP); \ ((void)__android_log_print(ANDROID_LOG_DEBUG, "loolwsd", "%s %s", LVL, oss_.str().c_str())) @@ -259,7 +259,7 @@ namespace Log #define LOG_BODY_(LOG, PRIO, LVL, X, FILEP) \ Poco::Message m_(LOG.name(), "", Poco::Message::PRIO_##PRIO); \ - std::ostringstream& oss_ = Log::begin(LVL); \ + std::ostringstream& oss_ = Log::beginLog(LVL); \ oss_ << X; \ LOG_END(oss_, FILEP); \ m_.setText(oss_.str()); \ _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
