1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LeadThread\Viddler\Upload\Traits; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\Log; |
6
|
|
|
use Illuminate\Support\Facades\Config; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @Author: Tyler Arbon |
10
|
|
|
* @Date: 2017-08-08 11:20:40 |
11
|
|
|
* @Last Modified by: Tyler Arbon |
12
|
|
|
* @Last Modified time: 2017-08-08 12:09:32 |
13
|
|
|
*/ |
14
|
|
|
trait CanLog |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* System is unusable. |
18
|
|
|
* |
19
|
|
|
* @param string $message |
20
|
|
|
* @param array $context |
21
|
|
|
* |
22
|
|
|
* @return void |
23
|
|
|
*/ |
24
|
|
|
public function emergency($message, array $context = array()) |
25
|
|
|
{ |
26
|
|
|
if (Config::get("viddler.log", false)) { |
27
|
|
|
Log::emergency($message, $context); |
28
|
|
|
} |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Action must be taken immediately. |
33
|
|
|
* |
34
|
|
|
* Example: Entire website down, database unavailable, etc. This should |
35
|
|
|
* trigger the SMS alerts and wake you up. |
36
|
|
|
* |
37
|
|
|
* @param string $message |
38
|
|
|
* @param array $context |
39
|
|
|
* |
40
|
|
|
* @return void |
41
|
|
|
*/ |
42
|
|
|
public function alert($message, array $context = array()) |
43
|
|
|
{ |
44
|
|
|
if (Config::get("viddler.log", false)) { |
45
|
|
|
Log::alert($message, $context); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Critical conditions. |
51
|
|
|
* |
52
|
|
|
* Example: Application component unavailable, unexpected exception. |
53
|
|
|
* |
54
|
|
|
* @param string $message |
55
|
|
|
* @param array $context |
56
|
|
|
* |
57
|
|
|
* @return void |
58
|
|
|
*/ |
59
|
|
|
public function critical($message, array $context = array()) |
60
|
|
|
{ |
61
|
|
|
if (Config::get("viddler.log", false)) { |
62
|
|
|
Log::critical($message, $context); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Runtime errors that do not require immediate action but should typically |
68
|
|
|
* be logged and monitored. |
69
|
|
|
* |
70
|
|
|
* @param string $message |
71
|
|
|
* @param array $context |
72
|
|
|
* |
73
|
|
|
* @return void |
74
|
|
|
*/ |
75
|
6 |
|
public function error($message, array $context = array()) |
76
|
|
|
{ |
77
|
6 |
|
if (Config::get("viddler.log", false)) { |
78
|
|
|
Log::error($message, $context); |
79
|
|
|
} |
80
|
6 |
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Exceptional occurrences that are not errors. |
84
|
|
|
* |
85
|
|
|
* Example: Use of deprecated APIs, poor use of an API, undesirable things |
86
|
|
|
* that are not necessarily wrong. |
87
|
|
|
* |
88
|
|
|
* @param string $message |
89
|
|
|
* @param array $context |
90
|
|
|
* |
91
|
|
|
* @return void |
92
|
|
|
*/ |
93
|
|
|
public function warning($message, array $context = array()) |
94
|
|
|
{ |
95
|
|
|
if (Config::get("viddler.log", false)) { |
96
|
|
|
Log::warning($message, $context); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Normal but significant events. |
102
|
|
|
* |
103
|
|
|
* @param string $message |
104
|
|
|
* @param array $context |
105
|
|
|
* |
106
|
|
|
* @return void |
107
|
|
|
*/ |
108
|
|
|
public function notice($message, array $context = array()) |
109
|
|
|
{ |
110
|
|
|
if (Config::get("viddler.log", false)) { |
111
|
|
|
Log::notice($message, $context); |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Interesting events. |
117
|
|
|
* |
118
|
|
|
* Example: User logs in, SQL logs. |
119
|
|
|
* |
120
|
|
|
* @param string $message |
121
|
|
|
* @param array $context |
122
|
|
|
* |
123
|
|
|
* @return void |
124
|
|
|
*/ |
125
|
18 |
|
public function info($message, array $context = array()) |
126
|
|
|
{ |
127
|
18 |
|
if (Config::get("viddler.log", false)) { |
128
|
|
|
Log::info($message, $context); |
129
|
|
|
} |
130
|
18 |
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Detailed debug information. |
134
|
|
|
* |
135
|
|
|
* @param string $message |
136
|
|
|
* @param array $context |
137
|
|
|
* |
138
|
|
|
* @return void |
139
|
|
|
*/ |
140
|
|
|
public function debug($message, array $context = array()) |
141
|
|
|
{ |
142
|
|
|
if (Config::get("viddler.log", false)) { |
143
|
|
|
Log::debug($message, $context); |
144
|
|
|
} |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* Logs with an arbitrary level. |
149
|
|
|
* |
150
|
|
|
* @param mixed $level |
151
|
|
|
* @param string $message |
152
|
|
|
* @param array $context |
153
|
|
|
* |
154
|
|
|
* @return void |
155
|
|
|
*/ |
156
|
|
|
public function log($level, $message, array $context = array()) |
157
|
|
|
{ |
158
|
|
|
if (Config::get("viddler.log", false)) { |
159
|
|
|
Log::log($level, $message, $context); |
160
|
|
|
} |
161
|
|
|
} |
162
|
|
|
} |
163
|
|
|
|