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