[Libreoffice-commits] online.git: kit/ForKit.cpp kit/Kit.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Tue Jan 9 12:07:07 UTC 2018


 kit/ForKit.cpp |   17 ++++++++++-------
 kit/Kit.cpp    |   14 +++++++++++++-
 2 files changed, 23 insertions(+), 8 deletions(-)

New commits:
commit 95af839fd9183aa0ccb41ec6c13838739d90c819
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Mon Jan 8 23:56:15 2018 -0500

    wsd: trace first child's startup activity
    
    To help debug early failure, log the first
    child's statup at trace-level.
    
    Change-Id: I8a6c8fe535bbc971174c0d950a2243460f81a2c7
    Reviewed-on: https://gerrit.libreoffice.org/47628
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
    Tested-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/kit/ForKit.cpp b/kit/ForKit.cpp
index 48e4ebb5..798126fa 100644
--- a/kit/ForKit.cpp
+++ b/kit/ForKit.cpp
@@ -246,12 +246,6 @@ static int createLibreOfficeKit(const std::string& childRoot,
 
     LOG_DBG("Forking a loolkit process with jailId: " << jailId << ".");
 
-    if (LogLevel != "trace")
-    {
-        LOG_INF("Setting log-level to [" << LogLevel << "].");
-        Log::logger().setLevel(LogLevel);
-    }
-
     const Process::PID pid = fork();
     if (!pid)
     {
@@ -526,7 +520,8 @@ int main(int argc, char** argv)
     LOG_INF("Preinit stage OK.");
 
     // We must have at least one child, more are created dynamically.
-    // Ask this first child to send version information to master process
+    // Ask this first child to send version information to master process and trace startup.
+    ::setenv("LOOL_TRACE_STARTUP", "1", 1);
     Process::PID forKitPid = createLibreOfficeKit(childRoot, sysTemplate, loTemplate, loSubPath, true);
     if (forKitPid < 0)
     {
@@ -534,6 +529,14 @@ int main(int argc, char** argv)
         std::_Exit(Application::EXIT_SOFTWARE);
     }
 
+    // No need to trace subsequent children.
+    ::unsetenv("LOOL_TRACE_STARTUP");
+    if (LogLevel != "trace")
+    {
+        LOG_INF("Setting log-level to [" << LogLevel << "].");
+        Log::logger().setLevel(LogLevel);
+    }
+
     CommandDispatcher commandDispatcher(0);
     LOG_INF("ForKit process is ready.");
 
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index dba54ecb..8bb4864c 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1934,8 +1934,14 @@ void lokit_main(const std::string& childRoot,
         logProperties["path"] = std::string(logFilename);
     }
 
-    Log::initialize("kit", logLevel ? logLevel : "", logColor != nullptr, logToFile, logProperties);
     Util::rng::reseed();
+    const std::string LogLevel = logLevel ? logLevel : "trace";
+    const bool bTraceStartup = (std::getenv("LOOL_TRACE_STARTUP") != nullptr);
+    Log::initialize("kit", bTraceStartup ? "trace" : logLevel, logColor != nullptr, logToFile, logProperties);
+    if (bTraceStartup && LogLevel != "trace")
+    {
+        LOG_INF("Setting log-level to [trace] and delaying setting to requested [" << LogLevel << "].");
+    }
 
     assert(!childRoot.empty());
     assert(!sysTemplate.empty());
@@ -2146,6 +2152,12 @@ void lokit_main(const std::string& childRoot,
 
         auto queue = std::make_shared<TileQueue>();
 
+        if (bTraceStartup && LogLevel != "trace")
+        {
+            LOG_INF("Setting log-level to [" << LogLevel << "].");
+            Log::logger().setLevel(LogLevel);
+        }
+
         const std::string socketName = "child_ws_" + pid;
         IoUtil::SocketProcessor(ws, socketName,
                 [&socketName, &ws, &loKit, &jailId, &queue](const std::vector<char>& data)


More information about the Libreoffice-commits mailing list