Yaffs site version 1.1
[yaffs-website] / vendor / symfony / http-kernel / Tests / Logger.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
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 namespace Symfony\Component\HttpKernel\Tests;
13
14 use Psr\Log\LoggerInterface;
15
16 class Logger implements LoggerInterface
17 {
18     protected $logs;
19
20     public function __construct()
21     {
22         $this->clear();
23     }
24
25     public function getLogs($level = false)
26     {
27         return false === $level ? $this->logs : $this->logs[$level];
28     }
29
30     public function clear()
31     {
32         $this->logs = array(
33             'emergency' => array(),
34             'alert' => array(),
35             'critical' => array(),
36             'error' => array(),
37             'warning' => array(),
38             'notice' => array(),
39             'info' => array(),
40             'debug' => array(),
41         );
42     }
43
44     public function log($level, $message, array $context = array())
45     {
46         $this->logs[$level][] = $message;
47     }
48
49     public function emergency($message, array $context = array())
50     {
51         $this->log('emergency', $message, $context);
52     }
53
54     public function alert($message, array $context = array())
55     {
56         $this->log('alert', $message, $context);
57     }
58
59     public function critical($message, array $context = array())
60     {
61         $this->log('critical', $message, $context);
62     }
63
64     public function error($message, array $context = array())
65     {
66         $this->log('error', $message, $context);
67     }
68
69     public function warning($message, array $context = array())
70     {
71         $this->log('warning', $message, $context);
72     }
73
74     public function notice($message, array $context = array())
75     {
76         $this->log('notice', $message, $context);
77     }
78
79     public function info($message, array $context = array())
80     {
81         $this->log('info', $message, $context);
82     }
83
84     public function debug($message, array $context = array())
85     {
86         $this->log('debug', $message, $context);
87     }
88
89     /**
90      * @deprecated
91      */
92     public function emerg($message, array $context = array())
93     {
94         @trigger_error('Use emergency() which is PSR-3 compatible', E_USER_DEPRECATED);
95
96         $this->log('emergency', $message, $context);
97     }
98
99     /**
100      * @deprecated
101      */
102     public function crit($message, array $context = array())
103     {
104         @trigger_error('Use critical() which is PSR-3 compatible', E_USER_DEPRECATED);
105
106         $this->log('critical', $message, $context);
107     }
108
109     /**
110      * @deprecated
111      */
112     public function err($message, array $context = array())
113     {
114         @trigger_error('Use error() which is PSR-3 compatible', E_USER_DEPRECATED);
115
116         $this->log('error', $message, $context);
117     }
118
119     /**
120      * @deprecated
121      */
122     public function warn($message, array $context = array())
123     {
124         @trigger_error('Use warning() which is PSR-3 compatible', E_USER_DEPRECATED);
125
126         $this->log('warning', $message, $context);
127     }
128 }