]> git.mxchange.org Git - friendica.git/blob - tests/src/Core/Logger/SyslogLoggerWrapper.php
spelling: forums
[friendica.git] / tests / src / Core / Logger / SyslogLoggerWrapper.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2010-2023, the Friendica project
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  */
21
22 namespace Friendica\Test\src\Core\Logger;
23
24 use Friendica\Core\Config\Capability\IManageConfigValues;
25 use Friendica\Core\Logger\Type\SyslogLogger;
26 use Friendica\Core\Logger\Util\Introspection;
27 use Psr\Log\LogLevel;
28
29 /**
30  * Wraps the SyslogLogger for replacing the syslog call with a string field.
31  */
32 class SyslogLoggerWrapper extends SyslogLogger
33 {
34         private $content;
35
36         public function __construct($channel, IManageConfigValues $config, Introspection $introspection, $level = LogLevel::NOTICE)
37         {
38                 parent::__construct($channel, $config, $introspection, $level);
39
40                 $this->content = '';
41         }
42
43         /**
44          * Gets the content from the wrapped Syslog
45          *
46          * @return string
47          */
48         public function getContent()
49         {
50                 return $this->content;
51         }
52
53         /**
54          * {@inheritdoc}
55          * @noinspection PhpMissingParentCallCommonInspection
56          */
57         protected function syslogWrapper(int $level, string $entry)
58         {
59                 $this->content .= $entry . PHP_EOL;
60         }
61 }