[Libreoffice-commits] online.git: common/Log.cpp
Ashod Nakashian (via logerrit)
logerrit at kemper.freedesktop.org
Sat Aug 17 01:39:02 UTC 2019
common/Log.cpp | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
New commits:
commit c6c673ed6fb5ff213fcd3030a38e221d28e6aa86
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sun Mar 24 23:16:29 2019 -0400
Commit: Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Sat Aug 17 03:38:43 2019 +0200
wsd: cache the logger instance to avoid costly lookups
Change-Id: Idf9261d46b44afc42a960146886c180e37d8d51f
Reviewed-on: https://gerrit.libreoffice.org/69641
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
Tested-by: Michael Meeks <michael.meeks at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/71085
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/common/Log.cpp b/common/Log.cpp
index 5a0c2655d..4441eb785 100644
--- a/common/Log.cpp
+++ b/common/Log.cpp
@@ -45,11 +45,13 @@ namespace Log
struct StaticNameHelper
{
private:
- std::atomic<bool> _inited;
+ Poco::Logger* _logger;
std::string _name;
std::string _id;
+ std::atomic<bool> _inited;
public:
StaticNameHelper() :
+ _logger(nullptr),
_inited(true)
{
}
@@ -67,6 +69,9 @@ namespace Log
void setName(const std::string& name) { _name = name; }
const std::string& getName() const { return _name; }
+
+ void setLogger(Poco::Logger* logger) { _logger = logger; };
+ Poco::Logger* getLogger() { return _logger; }
};
static StaticNameHelper Source;
@@ -179,6 +184,7 @@ namespace Log
* */
channel->open();
auto& logger = Poco::Logger::create(Source.getName(), channel, Poco::Message::PRIO_TRACE);
+ Source.setLogger(&logger);
logger.setLevel(logLevel.empty() ? std::string("trace") : logLevel);
@@ -201,7 +207,9 @@ namespace Log
Poco::Logger& logger()
{
- return Poco::Logger::get(Source.getInited() ? Source.getName() : std::string());
+ Poco::Logger* pLogger = Source.getLogger();
+ return pLogger ? *pLogger
+ : Poco::Logger::get(Source.getInited() ? Source.getName() : std::string());
}
#if !MOBILEAPP
More information about the Libreoffice-commits
mailing list