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