1 | <?php |
||
30 | abstract class Logger /** @todo extends Psr\Log\AbstractLogger */ { |
||
31 | /** |
||
32 | * System is unusable. |
||
33 | * |
||
34 | * @param string $message |
||
35 | * @param array $context |
||
36 | * |
||
37 | * @return void |
||
38 | */ |
||
39 | public function emergency($message, array $context = array()) |
||
43 | |||
44 | /** |
||
45 | * Action must be taken immediately. |
||
46 | * |
||
47 | * Example: Entire website down, database unavailable, etc. This should |
||
48 | * trigger the SMS alerts and wake you up. |
||
49 | * |
||
50 | * @param string $message |
||
51 | * @param array $context |
||
52 | * |
||
53 | * @return void |
||
54 | */ |
||
55 | public function alert($message, array $context = array()) |
||
59 | |||
60 | /** |
||
61 | * Critical conditions. |
||
62 | * |
||
63 | * Example: Application component unavailable, unexpected exception. |
||
64 | * |
||
65 | * @param string $message |
||
66 | * @param array $context |
||
67 | * |
||
68 | * @return void |
||
69 | */ |
||
70 | public function critical($message, array $context = array()) |
||
74 | |||
75 | /** |
||
76 | * Runtime errors that do not require immediate action but should typically |
||
77 | * be logged and monitored. |
||
78 | * |
||
79 | * @param string $message |
||
80 | * @param array $context |
||
81 | * |
||
82 | * @return void |
||
83 | */ |
||
84 | public function error($message, array $context = array()) |
||
88 | |||
89 | /** |
||
90 | * Exceptional occurrences that are not errors. |
||
91 | * |
||
92 | * Example: Use of deprecated APIs, poor use of an API, undesirable things |
||
93 | * that are not necessarily wrong. |
||
94 | * |
||
95 | * @param string $message |
||
96 | * @param array $context |
||
97 | * |
||
98 | * @return void |
||
99 | */ |
||
100 | public function warning($message, array $context = array()) |
||
104 | |||
105 | /** |
||
106 | * Normal but significant events. |
||
107 | * |
||
108 | * @param string $message |
||
109 | * @param array $context |
||
110 | * |
||
111 | * @return void |
||
112 | */ |
||
113 | public function notice($message, array $context = array()) |
||
117 | |||
118 | /** |
||
119 | * Interesting events. |
||
120 | * |
||
121 | * Example: User logs in, SQL logs. |
||
122 | * |
||
123 | * @param string $message |
||
124 | * @param array $context |
||
125 | * |
||
126 | * @return void |
||
127 | */ |
||
128 | public function info($message, array $context = array()) |
||
132 | |||
133 | /** |
||
134 | * Detailed debug information. |
||
135 | * |
||
136 | * @param string $message |
||
137 | * @param array $context |
||
138 | * |
||
139 | * @return void |
||
140 | */ |
||
141 | public function debug($message, array $context = array()) |
||
145 | |||
146 | /** |
||
147 | * Bake the context into { } placeholders in the message. |
||
148 | * @param string $message |
||
149 | * @param array $context |
||
150 | * |
||
151 | * @return string The baked message; |
||
152 | */ |
||
153 | protected function interpolate( $message, $context ) { |
||
162 | } |
||
163 | |||
166 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.