Completed
Push — master ( 4e360d...80bc96 )
by Daan van
07:27
created

SAML2_Compat_Ssp_Logger::log()   D

Complexity

Conditions 9
Paths 9

Size

Total Lines 28
Code Lines 25

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 28
rs 4.9091
cc 9
eloc 25
nc 9
nop 3
1
<?php
2
3
namespace SAML2\Compat\Ssp;
4
5
use Psr\Log\LoggerInterface;
6
use SimpleSAML_Logger;
7
8
class Logger implements LoggerInterface
9
{
10
    /**
11
     * System is unusable.
12
     *
13
     * @param string $message
14
     * @param array $context
15
     * @return null
16
     */
17
    public function emergency($message, array $context = array())
18
    {
19
        SimpleSAML_Logger::emergency($message . var_export($context, true));
20
    }
21
22
    /**
23
     * Action must be taken immediately.
24
     *
25
     * Example: Entire website down, database unavailable, etc. This should
26
     * trigger the SMS alerts and wake you up.
27
     *
28
     * @param string $message
29
     * @param array $context
30
     * @return null
31
     */
32
    public function alert($message, array $context = array())
33
    {
34
        SimpleSAML_Logger::alert($message . var_export($context, true));
35
    }
36
37
    /**
38
     * Critical conditions.
39
     *
40
     * Example: Application component unavailable, unexpected exception.
41
     *
42
     * @param string $message
43
     * @param array $context
44
     * @return null
45
     */
46
    public function critical($message, array $context = array())
47
    {
48
        SimpleSAML_Logger::critical($message . var_export($context, true));
49
    }
50
51
    /**
52
     * Runtime errors that do not require immediate action but should typically
53
     * be logged and monitored.
54
     *
55
     * @param string $message
56
     * @param array $context
57
     * @return null
58
     */
59
    public function error($message, array $context = array())
60
    {
61
        SimpleSAML_Logger::error($message . var_export($context, true));
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
     * @return null
73
     */
74
    public function warning($message, array $context = array())
75
    {
76
        SimpleSAML_Logger::warning($message . var_export($context, true));
77
    }
78
79
    /**
80
     * Normal but significant events.
81
     *
82
     * @param string $message
83
     * @param array $context
84
     * @return null
85
     */
86
    public function notice($message, array $context = array())
87
    {
88
        SimpleSAML_Logger::notice($message . var_export($context, true));
89
    }
90
91
    /**
92
     * Interesting events.
93
     *
94
     * Example: User logs in, SQL logs.
95
     *
96
     * @param string $message
97
     * @param array $context
98
     * @return null
99
     */
100
    public function info($message, array $context = array())
101
    {
102
        SimpleSAML_Logger::info($message . var_export($context, true));
103
    }
104
105
    /**
106
     * Detailed debug information.
107
     *
108
     * @param string $message
109
     * @param array $context
110
     * @return null
111
     */
112
    public function debug($message, array $context = array())
113
    {
114
        SimpleSAML_Logger::debug($message . var_export($context, true));
115
    }
116
117
    /**
118
     * Logs with an arbitrary level.
119
     *
120
     * @param mixed $level
121
     * @param string $message
122
     * @param array $context
123
     * @return null
124
     */
125
    public function log($level, $message, array $context = array())
126
    {
127
        switch ($level) {
128
            case SimpleSAML_Logger::ALERT:
129
                SimpleSAML_Logger::alert($message);
130
                break;
131
            case SimpleSAML_Logger::CRIT:
132
                SimpleSAML_Logger::critical($message);
133
                break;
134
            case SimpleSAML_Logger::DEBUG:
135
                SimpleSAML_Logger::debug($message);
136
                break;
137
            case SimpleSAML_Logger::EMERG:
138
                SimpleSAML_Logger::emergency($message);
139
                break;
140
            case SimpleSAML_Logger::ERR:
141
                SimpleSAML_Logger::error($message);
142
                break;
143
            case SimpleSAML_Logger::INFO:
144
                SimpleSAML_Logger::info($message);
145
                break;
146
            case SimpleSAML_Logger::NOTICE:
147
                SimpleSAML_Logger::notice($message);
148
                break;
149
            case SimpleSAML_Logger::WARNING:
150
                SimpleSAML_Logger::warning($message);
151
        }
152
    }
153
}
154