Logger   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 140
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 2
dl 0
loc 140
ccs 29
cts 29
cp 1
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A emergency() 0 4 1
A alert() 0 5 1
A critical() 0 5 1
A error() 0 5 1
A warning() 0 5 1
A notice() 0 5 1
A info() 0 5 1
A debug() 0 5 1
A log() 0 6 1
1
<?php
2
/**
3
 * @author @fabfuel <[email protected]>
4
 * @created 23.11.14, 08:46 
5
 */
6
namespace Fabfuel\Prophiler\Adapter\Psr\Log;
7
8
use Fabfuel\Prophiler\Adapter\AdapterAbstract;
9
use Psr\Log\LoggerInterface;
10
11
class Logger extends AdapterAbstract implements LoggerInterface
12
{
13
    const SEVERITY_EMERGENCY = 'emergency';
14
    const SEVERITY_ALERT = 'alert';
15
    const SEVERITY_CRITICAL = 'critical';
16
    const SEVERITY_ERROR = 'error';
17
    const SEVERITY_WARNING = 'warning';
18
    const SEVERITY_NOTICE = 'notice';
19
    const SEVERITY_INFO = 'info';
20
    const SEVERITY_DEBUG = 'debug';
21
22
    /**
23
     * System is unusable.
24
     *
25
     * @param string $message
26
     * @param array $context
27
     * @return null
28
     */
29 1
    public function emergency($message, array $context = array())
30
    {
31 1
        $this->log(self::SEVERITY_EMERGENCY, $message, $context);
32 1
    }
33
34
    /**
35
     * Action must be taken immediately.
36
     *
37
     * Example: Entire website down, database unavailable, etc. This should
38
     * trigger the SMS alerts and wake you up.
39
     *
40
     * @param string $message
41
     * @param array $context
42
     * @return null
43
     */
44 1
    public function alert($message, array $context = array())
45
    {
46 1
        $this->log(self::SEVERITY_ALERT, $message, $context);
47
48 1
    }
49
50
    /**
51
     * Critical conditions.
52
     *
53
     * Example: Application component unavailable, unexpected exception.
54
     *
55
     * @param string $message
56
     * @param array $context
57
     * @return null
58
     */
59 1
    public function critical($message, array $context = array())
60
    {
61 1
        $this->log(self::SEVERITY_CRITICAL, $message, $context);
62
63 1
    }
64
65
    /**
66
     * Runtime errors that do not require immediate action but should typically
67
     * be logged and monitored.
68
     *
69
     * @param string $message
70
     * @param array $context
71
     * @return null
72
     */
73 1
    public function error($message, array $context = array())
74
    {
75 1
        $this->log(self::SEVERITY_ERROR, $message, $context);
76
77 1
    }
78
79
    /**
80
     * Exceptional occurrences that are not errors.
81
     *
82
     * Example: Use of deprecated APIs, poor use of an API, undesirable things
83
     * that are not necessarily wrong.
84
     *
85
     * @param string $message
86
     * @param array $context
87
     * @return null
88
     */
89 1
    public function warning($message, array $context = array())
90
    {
91 1
        $this->log(self::SEVERITY_WARNING, $message, $context);
92
93 1
    }
94
95
    /**
96
     * Normal but significant events.
97
     *
98
     * @param string $message
99
     * @param array $context
100
     * @return null
101
     */
102 1
    public function notice($message, array $context = array())
103
    {
104 1
        $this->log(self::SEVERITY_NOTICE, $message, $context);
105
106 1
    }
107
108
    /**
109
     * Interesting events.
110
     *
111
     * Example: User logs in, SQL logs.
112
     *
113
     * @param string $message
114
     * @param array $context
115
     * @return null
116
     */
117 1
    public function info($message, array $context = array())
118
    {
119 1
        $this->log(self::SEVERITY_INFO, $message, $context);
120
121 1
    }
122
123
    /**
124
     * Detailed debug information.
125
     *
126
     * @param string $message
127
     * @param array $context
128
     * @return null
129
     */
130 1
    public function debug($message, array $context = array())
131
    {
132 1
        $this->log(self::SEVERITY_DEBUG, $message, $context);
133
134 1
    }
135
136
    /**
137
     * Logs with an arbitrary level.
138
     *
139
     * @param string $level
140
     * @param string $message
141
     * @param array $context
142
     * @return null
143
     */
144 8
    public function log($level, $message, array $context = array())
145
    {
146 8
        $context['severity'] = $level;
147 8
        $benchmark = $this->getProfiler()->start($message, $context, 'Logger');
148 8
        $this->getProfiler()->stop($benchmark);
149 8
    }
150
}
151