PluginProbe
ManageWP Worker / 4.9.25
ManageWP Worker v4.9.25
4.9.38 4.9.37 4.9.36 4.9.35 4.9.34 3.8.7 3.8.8 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.18 3.9.19 3.9.2 3.9.20 3.9.21 3.9.22 3.9.23 3.9.24 All 73 releases
worker / src / Monolog / Handler / TestHandler.php

TestHandler.php in ManageWP Worker 4.9.25, at src/Monolog/Handler/TestHandler.php

137 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of the Monolog package.
5 *
6 * (c) Jordi Boggiano <j.boggiano@seld.be>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 /**
13 * Used for testing purposes.
14 *
15 * It records all records and gives you access to them for verification.
16 *
17 * @author Jordi Boggiano <j.boggiano@seld.be>
18 */
19 class Monolog_Handler_TestHandler extends Monolog_Handler_AbstractProcessingHandler
20 {
21 protected $records = array();
22 protected $recordsByLevel = array();
23
24 public function getRecords()
25 {
26 return $this->records;
27 }
28
29 public function hasEmergency($record)
30 {
31 return $this->hasRecord($record, Monolog_Logger::EMERGENCY);
32 }
33
34 public function hasAlert($record)
35 {
36 return $this->hasRecord($record, Monolog_Logger::ALERT);
37 }
38
39 public function hasCritical($record)
40 {
41 return $this->hasRecord($record, Monolog_Logger::CRITICAL);
42 }
43
44 public function hasError($record)
45 {
46 return $this->hasRecord($record, Monolog_Logger::ERROR);
47 }
48
49 public function hasWarning($record)
50 {
51 return $this->hasRecord($record, Monolog_Logger::WARNING);
52 }
53
54 public function hasNotice($record)
55 {
56 return $this->hasRecord($record, Monolog_Logger::NOTICE);
57 }
58
59 public function hasInfo($record)
60 {
61 return $this->hasRecord($record, Monolog_Logger::INFO);
62 }
63
64 public function hasDebug($record)
65 {
66 return $this->hasRecord($record, Monolog_Logger::DEBUG);
67 }
68
69 public function hasEmergencyRecords()
70 {
71 return isset($this->recordsByLevel[Monolog_Logger::EMERGENCY]);
72 }
73
74 public function hasAlertRecords()
75 {
76 return isset($this->recordsByLevel[Monolog_Logger::ALERT]);
77 }
78
79 public function hasCriticalRecords()
80 {
81 return isset($this->recordsByLevel[Monolog_Logger::CRITICAL]);
82 }
83
84 public function hasErrorRecords()
85 {
86 return isset($this->recordsByLevel[Monolog_Logger::ERROR]);
87 }
88
89 public function hasWarningRecords()
90 {
91 return isset($this->recordsByLevel[Monolog_Logger::WARNING]);
92 }
93
94 public function hasNoticeRecords()
95 {
96 return isset($this->recordsByLevel[Monolog_Logger::NOTICE]);
97 }
98
99 public function hasInfoRecords()
100 {
101 return isset($this->recordsByLevel[Monolog_Logger::INFO]);
102 }
103
104 public function hasDebugRecords()
105 {
106 return isset($this->recordsByLevel[Monolog_Logger::DEBUG]);
107 }
108
109 protected function hasRecord($record, $level)
110 {
111 if (!isset($this->recordsByLevel[$level])) {
112 return false;
113 }
114
115 if (is_array($record)) {
116 $record = $record['message'];
117 }
118
119 foreach ($this->recordsByLevel[$level] as $rec) {
120 if ($rec['message'] === $record) {
121 return true;
122 }
123 }
124
125 return false;
126 }
127
128 /**
129 * {@inheritdoc}
130 */
131 protected function write(array $record)
132 {
133 $this->recordsByLevel[$record['level']][] = $record;
134 $this->records[] = $record;
135 }
136 }
137