[Libreoffice-commits] online.git: loolwsd/Util.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Wed Mar 9 13:27:32 UTC 2016
loolwsd/Util.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 05f8757f1ded716e67382f25b4575c06984b2163
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Wed Mar 9 08:22:31 2016 -0500
loolwsd: colored logs enabled automatically in tty
It is desirable to have colored logs when running loolwsd
in a terminal, but not redirecting its output to a file.
Outputting to a terminal is now detected and colored logs
are automatically enabled.
To force colored logs in files as well, define
LOOL_LOGCOLOR in the environ. The output color codes
can then be processed using, f.e., `less -r`.
Change-Id: I09fbee4441f210d814ac5ad23dd99d1c33b560b7
Reviewed-on: https://gerrit.libreoffice.org/23080
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 ee7aaca..78e9356 100644
--- a/loolwsd/Util.cpp
+++ b/loolwsd/Util.cpp
@@ -115,7 +115,7 @@ namespace Log
<< std::setw(5) << std::setfill('0') << Poco::Process::id();
SourceId = oss.str();
- auto channel = (std::getenv("LOOL_LOGCOLOR")
+ auto channel = (isatty(fileno(stdout)) || std::getenv("LOOL_LOGCOLOR")
? static_cast<Poco::Channel*>(new Poco::ColorConsoleChannel())
: static_cast<Poco::Channel*>(new Poco::ConsoleChannel()));
auto& logger = Poco::Logger::create(SourceName, channel, Poco::Message::PRIO_INFORMATION);
More information about the Libreoffice-commits
mailing list