PluginProbe
Media Cloud Sync / 1.4.2
Media Cloud Sync v1.4.2
1.4.2 1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 All 36 releases
← All changes | includes/sdk/google/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php +20 -22 1.2.0 → 1.4.2 View file →
@@ -8,40 +8,38 @@
8 8 *
9 9 * For the full copyright and license information, please view the LICENSE
10 10 * file that was distributed with this source code.
11 11 */
12 -namespace Dudlewebs\WPMCS\Monolog\Handler;
12 +namespace Dudlewebs\WPMCS\GCP\Monolog\Handler;
13 13
14 -use Dudlewebs\WPMCS\Monolog\Logger;
15 -use Dudlewebs\WPMCS\Monolog\Formatter\FormatterInterface;
16 -use Dudlewebs\WPMCS\Monolog\Formatter\LineFormatter;
14 +use Dudlewebs\WPMCS\GCP\Monolog\Level;
15 +use Dudlewebs\WPMCS\GCP\Monolog\Formatter\FormatterInterface;
16 +use Dudlewebs\WPMCS\GCP\Monolog\Formatter\LineFormatter;
17 17 /**
18 18 * Common syslog functionality
19 - *
20 - * @phpstan-import-type Level from \Monolog\Logger
21 19 */
22 20 abstract class AbstractSyslogHandler extends AbstractProcessingHandler
23 21 {
24 - /** @var int */
25 - protected $facility;
22 + protected int $facility;
26 23 /**
27 - * Translates Monolog log levels to syslog log priorities.
28 - * @var array
29 - * @phpstan-var array<Level, int>
24 + * List of valid log facility names.
25 + * @var array<string, int>
30 26 */
31 - protected $logLevels = [Logger::DEBUG => \LOG_DEBUG, Logger::INFO => \LOG_INFO, Logger::NOTICE => \LOG_NOTICE, Logger::WARNING => \LOG_WARNING, Logger::ERROR => \LOG_ERR, Logger::CRITICAL => \LOG_CRIT, Logger::ALERT => \LOG_ALERT, Logger::EMERGENCY => \LOG_EMERG];
27 + protected array $facilities = ['auth' => \LOG_AUTH, 'authpriv' => \LOG_AUTHPRIV, 'cron' => \LOG_CRON, 'daemon' => \LOG_DAEMON, 'kern' => \LOG_KERN, 'lpr' => \LOG_LPR, 'mail' => \LOG_MAIL, 'news' => \LOG_NEWS, 'syslog' => \LOG_SYSLOG, 'user' => \LOG_USER, 'uucp' => \LOG_UUCP];
32 28 /**
33 - * List of valid log facility names.
34 - * @var array<string, int>
29 + * Translates Monolog log levels to syslog log priorities.
35 30 */
36 - protected $facilities = ['auth' => \LOG_AUTH, 'authpriv' => \LOG_AUTHPRIV, 'cron' => \LOG_CRON, 'daemon' => \LOG_DAEMON, 'kern' => \LOG_KERN, 'lpr' => \LOG_LPR, 'mail' => \LOG_MAIL, 'news' => \LOG_NEWS, 'syslog' => \LOG_SYSLOG, 'user' => \LOG_USER, 'uucp' => \LOG_UUCP];
31 + protected function toSyslogPriority(Level $level) : int
32 + {
33 + return $level->toRFC5424Level();
34 + }
37 35 /**
38 36 * @param string|int $facility Either one of the names of the keys in $this->facilities, or a LOG_* facility constant
39 37 */
40 - public function __construct($facility = \LOG_USER, $level = Logger::DEBUG, bool $bubble = \true)
38 + public function __construct(string|int $facility = \LOG_USER, int|string|Level $level = Level::Debug, bool $bubble = \true)
41 39 {
42 40 parent::__construct($level, $bubble);
43 - if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
41 + if (!\defined('PHP_WINDOWS_VERSION_BUILD')) {
44 42 $this->facilities['local0'] = \LOG_LOCAL0;
45 43 $this->facilities['local1'] = \LOG_LOCAL1;
46 44 $this->facilities['local2'] = \LOG_LOCAL2;
47 45 $this->facilities['local3'] = \LOG_LOCAL3;
@@ -67,19 +65,19 @@
67 65 $this->facilities['local7'] = 184;
68 66 // LOG_LOCAL7
69 67 }
70 68 // convert textual description of facility to syslog constant
71 - if (is_string($facility) && array_key_exists(strtolower($facility), $this->facilities)) {
72 - $facility = $this->facilities[strtolower($facility)];
73 - } elseif (!in_array($facility, array_values($this->facilities), \true)) {
69 + if (\is_string($facility) && \array_key_exists(\strtolower($facility), $this->facilities)) {
70 + $facility = $this->facilities[\strtolower($facility)];
71 + } elseif (!\in_array($facility, \array_values($this->facilities), \true)) {
74 72 throw new \UnexpectedValueException('Unknown facility value "' . $facility . '" given');
75 73 }
76 74 $this->facility = $facility;
77 75 }
78 76 /**
79 - * {@inheritDoc}
77 + * @inheritDoc
80 78 */
81 - protected function getDefaultFormatter(): FormatterInterface
79 + protected function getDefaultFormatter() : FormatterInterface
82 80 {
83 81 return new LineFormatter('%channel%.%level_name%: %message% %context% %extra%');
84 82 }
85 83 }