]> git.mxchange.org Git - friendica.git/blob - src/Util/Logger/FriendicaDevelopHandler.php
remove file added by mistake
[friendica.git] / src / Util / Logger / FriendicaDevelopHandler.php
1 <?php
2
3 namespace Friendica\Util\Logger;
4
5 use Monolog\Handler;
6 use Monolog\Logger;
7
8 /**
9  * Simple handler for Friendica developers to use for deeper logging
10  *
11  * If you want to debug only interactions from your IP or the IP of a remote server for federation debug,
12  * you'll use Logger::develop() for the duration of your work, and you clean it up when you're done before submitting your PR.
13  */
14 class FriendicaDevelopHandler extends Handler\AbstractHandler
15 {
16         /**
17          * @var string The IP of the developer who wants to debug
18          */
19         private $developerIp;
20
21         /**
22          * @param string $developerIp  The IP of the developer who wants to debug
23          * @param int    $level        The minimum logging level at which this handler will be triggered
24          * @param bool   $bubble       Whether the messages that are handled can bubble up the stack or not
25          */
26         public function __construct($developerIp, $level = Logger::DEBUG, $bubble = true)
27         {
28                 parent::__construct($level, $bubble);
29
30                 $this->developerIp = $developerIp;
31         }
32
33         /**
34          * {@inheritdoc}
35          */
36         public function handle(array $record)
37         {
38                 if (!$this->isHandling($record)) {
39                         return false;
40                 }
41
42                 /// Just in case the remote IP is the same as the developer IP log the output
43                 if (!is_null($this->developerIp) && $_SERVER['REMOTE_ADDR'] != $this->developerIp)
44                 {
45                         return false;
46                 }
47
48                 return false === $this->bubble;
49         }
50 }