]> git.mxchange.org Git - friendica.git/blob - src/App/FriendicaLoggerProcessor.php
Add Monolog
[friendica.git] / src / App / FriendicaLoggerProcessor.php
1 <?php
2
3 namespace Friendica\App;
4
5 use Monolog\Processor\ProcessorInterface;
6
7 /**
8  * Includes the Friendica specific process_id of "app->process_id"
9  *
10  * @package Friendica\App
11  */
12 class FriendicaLoggerProcessor implements ProcessorInterface
13 {
14         /**
15          * @var string the ID of the current Friendica process
16          */
17         private $processId = null;
18
19         /**
20          * Set the process id based on the Application instance
21          *
22          * @param string $processId the process id
23          */
24         public function setProcessId($processId)
25         {
26                 if (!isset($this->processId) || $this->processId == '')
27                 {
28                         $this->processId = $processId;
29                 }
30         }
31
32         public function __construct()
33         {
34                 $this->processId = session_id();
35         }
36
37         public function __invoke(array $records)
38         {
39                 $records['extra'] = array_merge(
40                         $records['extra'],
41                         [
42                                 'app_id' => $this->processId,
43                         ]
44                 );
45
46                 return $records;
47         }
48 }