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