]> git.mxchange.org Git - friendica.git/commitdiff
Use a process identifier for logging that contains the pid (#5359)
authorMichael Vogel <icarus@dabo.de>
Tue, 10 Jul 2018 22:32:47 +0000 (00:32 +0200)
committerHypolite Petovan <mrpetovan@eml.cc>
Tue, 10 Jul 2018 22:32:47 +0000 (18:32 -0400)
src/App.php
src/Core/System.php
src/Core/Worker.php

index 097b5e541dc97d69e23ad89fb69fa6d70f3d9d77..38b207c2668acc0a0e1139ffc221ca144346709e 100644 (file)
@@ -193,7 +193,7 @@ class App
 
                $this->query_string = '';
 
-               $this->process_id = uniqid('log', true);
+               $this->process_id = System::processID('log');
 
                set_time_limit(0);
 
index 46d1b34e555a6dfe0bf802e7ab3a13593f9f4ef1..98ae3da2d9ce14876f439b8995febdd19ff1fe35 100644 (file)
@@ -203,6 +203,18 @@ EOT;
                }
        }
 
+       /**
+        * Generates a process identifier for the logging
+        *
+        * @param string $prefix A given prefix
+        *
+        * @return string a generated process identifier
+        */
+       public static function processID($prefix)
+       {
+               return uniqid($prefix . ':' . str_pad(getmypid() . ':', 8, '0') . ':');
+       }
+
        /// @todo Move the following functions from boot.php
        /*
        function killme()
index c4c91bbf8b48f420fcef8c8e9451ce4ccbe5891a..296d40b5046e182ba86cb219f8384f272f170314 100644 (file)
@@ -141,7 +141,7 @@ class Worker
                if (Config::get('system', 'worker_daemon_mode', false)) {
                        self::IPCSetJobState(false);
                }
-               logger("Couldn't select a workerqueue entry, quitting.", LOGGER_DEBUG);
+               logger("Couldn't select a workerqueue entry, quitting process " . getmypid() . ".", LOGGER_DEBUG);
        }
 
        /**
@@ -309,7 +309,7 @@ class Worker
 
                $argc = count($argv);
 
-               $new_process_id = uniqid("wrk", true);
+               $new_process_id = System::processID("wrk");
 
                logger("Process ".$mypid." - Prio ".$queue["priority"]." - ID ".$queue["id"].": ".$funcname." ".$queue["parameter"]." - Process PID: ".$new_process_id);