xref: /plugin/dw2pdf/vendor/psr/log/Psr/Log/AbstractLogger.php (revision 0119ca25672bca93bf0779d1cdcf04911dbee191)
1*0119ca25SAndreas Gohr<?php
2*0119ca25SAndreas Gohr
3*0119ca25SAndreas Gohrnamespace Psr\Log;
4*0119ca25SAndreas Gohr
5*0119ca25SAndreas Gohr/**
6*0119ca25SAndreas Gohr * This is a simple Logger implementation that other Loggers can inherit from.
7*0119ca25SAndreas Gohr *
8*0119ca25SAndreas Gohr * It simply delegates all log-level-specific methods to the `log` method to
9*0119ca25SAndreas Gohr * reduce boilerplate code that a simple Logger that does the same thing with
10*0119ca25SAndreas Gohr * messages regardless of the error level has to implement.
11*0119ca25SAndreas Gohr */
12*0119ca25SAndreas Gohrabstract class AbstractLogger implements LoggerInterface
13*0119ca25SAndreas Gohr{
14*0119ca25SAndreas Gohr    /**
15*0119ca25SAndreas Gohr     * System is unusable.
16*0119ca25SAndreas Gohr     *
17*0119ca25SAndreas Gohr     * @param string $message
18*0119ca25SAndreas Gohr     * @param array  $context
19*0119ca25SAndreas Gohr     *
20*0119ca25SAndreas Gohr     * @return void
21*0119ca25SAndreas Gohr     */
22*0119ca25SAndreas Gohr    public function emergency($message, array $context = array())
23*0119ca25SAndreas Gohr    {
24*0119ca25SAndreas Gohr        $this->log(LogLevel::EMERGENCY, $message, $context);
25*0119ca25SAndreas Gohr    }
26*0119ca25SAndreas Gohr
27*0119ca25SAndreas Gohr    /**
28*0119ca25SAndreas Gohr     * Action must be taken immediately.
29*0119ca25SAndreas Gohr     *
30*0119ca25SAndreas Gohr     * Example: Entire website down, database unavailable, etc. This should
31*0119ca25SAndreas Gohr     * trigger the SMS alerts and wake you up.
32*0119ca25SAndreas Gohr     *
33*0119ca25SAndreas Gohr     * @param string $message
34*0119ca25SAndreas Gohr     * @param array  $context
35*0119ca25SAndreas Gohr     *
36*0119ca25SAndreas Gohr     * @return void
37*0119ca25SAndreas Gohr     */
38*0119ca25SAndreas Gohr    public function alert($message, array $context = array())
39*0119ca25SAndreas Gohr    {
40*0119ca25SAndreas Gohr        $this->log(LogLevel::ALERT, $message, $context);
41*0119ca25SAndreas Gohr    }
42*0119ca25SAndreas Gohr
43*0119ca25SAndreas Gohr    /**
44*0119ca25SAndreas Gohr     * Critical conditions.
45*0119ca25SAndreas Gohr     *
46*0119ca25SAndreas Gohr     * Example: Application component unavailable, unexpected exception.
47*0119ca25SAndreas Gohr     *
48*0119ca25SAndreas Gohr     * @param string $message
49*0119ca25SAndreas Gohr     * @param array  $context
50*0119ca25SAndreas Gohr     *
51*0119ca25SAndreas Gohr     * @return void
52*0119ca25SAndreas Gohr     */
53*0119ca25SAndreas Gohr    public function critical($message, array $context = array())
54*0119ca25SAndreas Gohr    {
55*0119ca25SAndreas Gohr        $this->log(LogLevel::CRITICAL, $message, $context);
56*0119ca25SAndreas Gohr    }
57*0119ca25SAndreas Gohr
58*0119ca25SAndreas Gohr    /**
59*0119ca25SAndreas Gohr     * Runtime errors that do not require immediate action but should typically
60*0119ca25SAndreas Gohr     * be logged and monitored.
61*0119ca25SAndreas Gohr     *
62*0119ca25SAndreas Gohr     * @param string $message
63*0119ca25SAndreas Gohr     * @param array  $context
64*0119ca25SAndreas Gohr     *
65*0119ca25SAndreas Gohr     * @return void
66*0119ca25SAndreas Gohr     */
67*0119ca25SAndreas Gohr    public function error($message, array $context = array())
68*0119ca25SAndreas Gohr    {
69*0119ca25SAndreas Gohr        $this->log(LogLevel::ERROR, $message, $context);
70*0119ca25SAndreas Gohr    }
71*0119ca25SAndreas Gohr
72*0119ca25SAndreas Gohr    /**
73*0119ca25SAndreas Gohr     * Exceptional occurrences that are not errors.
74*0119ca25SAndreas Gohr     *
75*0119ca25SAndreas Gohr     * Example: Use of deprecated APIs, poor use of an API, undesirable things
76*0119ca25SAndreas Gohr     * that are not necessarily wrong.
77*0119ca25SAndreas Gohr     *
78*0119ca25SAndreas Gohr     * @param string $message
79*0119ca25SAndreas Gohr     * @param array  $context
80*0119ca25SAndreas Gohr     *
81*0119ca25SAndreas Gohr     * @return void
82*0119ca25SAndreas Gohr     */
83*0119ca25SAndreas Gohr    public function warning($message, array $context = array())
84*0119ca25SAndreas Gohr    {
85*0119ca25SAndreas Gohr        $this->log(LogLevel::WARNING, $message, $context);
86*0119ca25SAndreas Gohr    }
87*0119ca25SAndreas Gohr
88*0119ca25SAndreas Gohr    /**
89*0119ca25SAndreas Gohr     * Normal but significant events.
90*0119ca25SAndreas Gohr     *
91*0119ca25SAndreas Gohr     * @param string $message
92*0119ca25SAndreas Gohr     * @param array  $context
93*0119ca25SAndreas Gohr     *
94*0119ca25SAndreas Gohr     * @return void
95*0119ca25SAndreas Gohr     */
96*0119ca25SAndreas Gohr    public function notice($message, array $context = array())
97*0119ca25SAndreas Gohr    {
98*0119ca25SAndreas Gohr        $this->log(LogLevel::NOTICE, $message, $context);
99*0119ca25SAndreas Gohr    }
100*0119ca25SAndreas Gohr
101*0119ca25SAndreas Gohr    /**
102*0119ca25SAndreas Gohr     * Interesting events.
103*0119ca25SAndreas Gohr     *
104*0119ca25SAndreas Gohr     * Example: User logs in, SQL logs.
105*0119ca25SAndreas Gohr     *
106*0119ca25SAndreas Gohr     * @param string $message
107*0119ca25SAndreas Gohr     * @param array  $context
108*0119ca25SAndreas Gohr     *
109*0119ca25SAndreas Gohr     * @return void
110*0119ca25SAndreas Gohr     */
111*0119ca25SAndreas Gohr    public function info($message, array $context = array())
112*0119ca25SAndreas Gohr    {
113*0119ca25SAndreas Gohr        $this->log(LogLevel::INFO, $message, $context);
114*0119ca25SAndreas Gohr    }
115*0119ca25SAndreas Gohr
116*0119ca25SAndreas Gohr    /**
117*0119ca25SAndreas Gohr     * Detailed debug information.
118*0119ca25SAndreas Gohr     *
119*0119ca25SAndreas Gohr     * @param string $message
120*0119ca25SAndreas Gohr     * @param array  $context
121*0119ca25SAndreas Gohr     *
122*0119ca25SAndreas Gohr     * @return void
123*0119ca25SAndreas Gohr     */
124*0119ca25SAndreas Gohr    public function debug($message, array $context = array())
125*0119ca25SAndreas Gohr    {
126*0119ca25SAndreas Gohr        $this->log(LogLevel::DEBUG, $message, $context);
127*0119ca25SAndreas Gohr    }
128*0119ca25SAndreas Gohr}
129