[Libreoffice-commits] online.git: loolwsd/Util.cpp loolwsd/Util.hpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Thu Dec 24 19:30:21 PST 2015
loolwsd/Util.cpp | 21 +++++++++++++++++++++
loolwsd/Util.hpp | 1 +
2 files changed, 22 insertions(+)
New commits:
commit a06247fa5dc820d66e9371d548d238711c80df62
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Wed Dec 23 16:58:38 2015 -0500
loolwsd: Log level and warnings
Log level can be set from LOOL_LOGLEVEL
environment variable (values are those
supported by Poco::Logger::setLevel).
Added warning logging via warn function.
Change-Id: I450511d5132893b93391b287fa5b3d6f522f4744
Reviewed-on: https://gerrit.libreoffice.org/20928
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/Util.cpp b/loolwsd/Util.cpp
index 87dd14a..c6ee312 100644
--- a/loolwsd/Util.cpp
+++ b/loolwsd/Util.cpp
@@ -29,6 +29,7 @@
#include <Poco/Timestamp.h>
#include <Poco/Thread.h>
#include <Poco/Util/Application.h>
+#include <Poco/Environment.h>
#include "Util.hpp"
#include "Png.hpp"
@@ -77,7 +78,22 @@ namespace Log
{
binname = name;
auto& logger = Poco::Logger::get(name);
+
+ // Configure the logger.
+ // TODO: This should come from a file.
+ try
+ {
+ // See Poco::Logger::setLevel docs for values.
+ // Try: error, information, debug
+ const auto level = Poco::Environment::get("LOOL_LOGLEVEL");
+ logger.setLevel(level);
+ }
+ catch (Poco::NotFoundException& aError)
+ {
+ }
+
logger.information("Initializing " + name);
+ logger.information("Log level is " + logger.getLevel());
}
Poco::Logger& logger()
@@ -95,6 +111,11 @@ namespace Log
logger().information(Util::logPrefix() + msg);
}
+ void warn(const std::string& msg)
+ {
+ return logger().warning(Util::logPrefix() + msg);
+ }
+
void error(const std::string& msg)
{
return logger().error(Util::logPrefix() + msg);
diff --git a/loolwsd/Util.hpp b/loolwsd/Util.hpp
index 8b1babf..aba885b 100644
--- a/loolwsd/Util.hpp
+++ b/loolwsd/Util.hpp
@@ -53,6 +53,7 @@ namespace Log
void debug(const std::string& msg);
void info(const std::string& msg);
+ void warn(const std::string& msg);
void error(const std::string& msg);
}
More information about the Libreoffice-commits
mailing list