loolwsd/LOOLKit.cpp | 10 +++++++++- loolwsd/LOOLWSD.cpp | 13 +++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-)
New commits: commit b8317e7b34120417885833926852657d4e7bce07 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Wed Sep 21 18:12:34 2016 -0400 loolwsd: lokit process logs to file if configured Pass the log-to-file config to the kit processes using envars. Change-Id: Ida79c35ab02d8038685153805be780359bfbe97e Reviewed-on: https://gerrit.libreoffice.org/29161 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp index 36b7817..7c9f451 100644 --- a/loolwsd/LOOLKit.cpp +++ b/loolwsd/LOOLKit.cpp @@ -1349,7 +1349,15 @@ void lokit_main(const std::string& childRoot, bool queryVersion) { // Reinitialize logging when forked. - Log::initialize("kit", getenv("LOOL_LOGLEVEL"), getenv("LOOL_LOGCOLOR")); + const bool logToFile = getenv("LOOL_LOGFILE"); + const auto logFilename = getenv("LOOL_LOGFILENAME"); + std::map<std::string, std::string> logProperties; + if (logToFile && logFilename) + { + logProperties["path"] = std::string(logFilename); + } + + Log::initialize("kit", getenv("LOOL_LOGLEVEL"), getenv("LOOL_LOGCOLOR"), logToFile, logProperties); Util::rng::reseed(); assert(!childRoot.empty()); diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp index 266ac7c..15e9eca 100644 --- a/loolwsd/LOOLWSD.cpp +++ b/loolwsd/LOOLWSD.cpp @@ -1403,7 +1403,9 @@ void LOOLWSD::initialize(Application& self) setenv("LOOL_LOGLEVEL", logLevel.c_str(), true); const auto withColor = !std::getenv("LOOL_NO_LOGCOLOR") && getConfigValue<bool>(conf, "logging.color", true); if (withColor) + { setenv("LOOL_LOGCOLOR", "1", true); + } const auto logToFile = getConfigValue<bool>(conf, "logging.file[@enable]", false); std::map<std::string, std::string> logProperties; @@ -1422,6 +1424,17 @@ void LOOLWSD::initialize(Application& self) } } + // Setup the logfile envar for the kit processes. + if (logToFile) + { + setenv("LOOL_LOGFILE", "1", true); + const auto it = logProperties.find("path"); + if (it != logProperties.end()) + { + setenv("LOOL_LOGFILENAME", it->second.c_str(), true); + } + } + Log::initialize("wsd", logLevel, withColor, logToFile, logProperties); #if ENABLE_SSL _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits