PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.25
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.25
1.10.25 1.10.24 1.10.23 1.10.22 1.10.21 1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 All 169 releases
woocommerce-pos / vendor_prefixed / sentry / sentry / src / Monolog / CompatibilityProcessingHandlerTrait.php

CompatibilityProcessingHandlerTrait.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.25, at vendor_prefixed/sentry/sentry/src/Monolog/CompatibilityProcessingHandlerTrait.php

98 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare (strict_types=1);
4 namespace WCPOS\Vendor\Sentry\Monolog;
5
6 use WCPOS\Vendor\Monolog\Level;
7 use WCPOS\Vendor\Monolog\Logger;
8 use WCPOS\Vendor\Monolog\LogRecord;
9 use WCPOS\Vendor\Sentry\Severity;
10 if (Logger::API >= 3) {
11 /**
12 * Logic which is used if monolog >= 3 is installed.
13 *
14 * @internal
15 */
16 trait CompatibilityProcessingHandlerTrait
17 {
18 /**
19 * @param array<string, mixed>|LogRecord $record
20 */
21 protected abstract function doWrite($record) : void;
22 /**
23 * {@inheritdoc}
24 */
25 protected function write(LogRecord $record) : void
26 {
27 $this->doWrite($record);
28 }
29 /**
30 * Translates the Monolog level into the Sentry severity.
31 */
32 private static function getSeverityFromLevel(int $level) : Severity
33 {
34 $level = Level::from($level);
35 switch ($level) {
36 case Level::Debug:
37 return Severity::debug();
38 case Level::Warning:
39 return Severity::warning();
40 case Level::Error:
41 return Severity::error();
42 case Level::Critical:
43 case Level::Alert:
44 case Level::Emergency:
45 return Severity::fatal();
46 case Level::Info:
47 case Level::Notice:
48 default:
49 return Severity::info();
50 }
51 }
52 }
53 } else {
54 /**
55 * Logic which is used if monolog < 3 is installed.
56 *
57 * @internal
58 */
59 trait CompatibilityProcessingHandlerTrait
60 {
61 /**
62 * @param array<string, mixed>|LogRecord $record
63 */
64 protected abstract function doWrite($record) : void;
65 /**
66 * {@inheritdoc}
67 */
68 protected function write(array $record) : void
69 {
70 $this->doWrite($record);
71 }
72 /**
73 * Translates the Monolog level into the Sentry severity.
74 *
75 * @param Logger::DEBUG|Logger::INFO|Logger::NOTICE|Logger::WARNING|Logger::ERROR|Logger::CRITICAL|Logger::ALERT|Logger::EMERGENCY $level The Monolog log level
76 */
77 private static function getSeverityFromLevel(int $level) : Severity
78 {
79 switch ($level) {
80 case Logger::DEBUG:
81 return Severity::debug();
82 case Logger::WARNING:
83 return Severity::warning();
84 case Logger::ERROR:
85 return Severity::error();
86 case Logger::CRITICAL:
87 case Logger::ALERT:
88 case Logger::EMERGENCY:
89 return Severity::fatal();
90 case Logger::INFO:
91 case Logger::NOTICE:
92 default:
93 return Severity::info();
94 }
95 }
96 }
97 }
98