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