1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Manage Log class in your application |
5
|
|
|
* |
6
|
|
|
* @category Venus\lib |
7
|
|
|
* @package Venus\lib\Log\ |
8
|
|
|
* @author Judicaël Paquet <[email protected]> |
9
|
|
|
* @copyright Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93) |
10
|
|
|
* @license https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël |
11
|
|
|
* @version Release: 1.0.0 |
12
|
|
|
* @filesource https://github.com/las93/venus2 |
13
|
|
|
* @link https://github.com/las93 |
14
|
|
|
* @since 1.0 |
15
|
|
|
*/ |
16
|
|
|
namespace Venus\lib\Log; |
17
|
|
|
|
18
|
|
|
use \Venus\lib\Debug as Debug; |
19
|
|
|
use \Venus\lib\Log\LoggerInterface as LoggerInterface ; |
20
|
|
|
use \Venus\lib\Log\LogLevel as LogLevel; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Manage Log class in your application |
24
|
|
|
* |
25
|
|
|
* @category Venus\lib |
26
|
|
|
* @package Venus\lib\Log\ |
27
|
|
|
* @author Judicaël Paquet <[email protected]> |
28
|
|
|
* @copyright Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93) |
29
|
|
|
* @license https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël |
30
|
|
|
* @version Release: 1.0.0 |
31
|
|
|
* @filesource https://github.com/las93/venus2 |
32
|
|
|
* @link https://github.com/las93 |
33
|
|
|
* @since 1.0 |
34
|
|
|
*/ |
35
|
|
|
abstract class AbstractLogger implements LoggerInterface |
36
|
|
|
{ |
37
|
|
|
/** |
38
|
|
|
* Logs with an arbitrary level. |
39
|
|
|
* |
40
|
|
|
* @param mixed $level |
41
|
|
|
* @param string $message |
42
|
|
|
* @param array $context |
43
|
|
|
* @return void |
44
|
|
|
*/ |
45
|
|
|
public function log($level, $message, array $context = array()) |
46
|
|
|
{ |
47
|
|
|
if (!isset($context['file'])) { $context['file'] = __FILE__; } |
48
|
|
|
if (!isset($context['line'])) { $context['line'] = __LINE__; } |
49
|
|
|
if ($level === null) { $level = LogLevel::INFO; } |
|
|
|
|
50
|
|
|
|
51
|
|
|
if (Debug::isDebug() === true) { |
52
|
|
|
|
53
|
|
|
if (Debug::getKindOfReportLog() === 'error_log' || Debug::getKindOfReportLog() === 'all') { |
54
|
|
|
|
55
|
|
|
error_log($context['file'].'> (l.'.$context['line'].') '.$message); |
56
|
|
|
} |
57
|
|
|
if (Debug::getKindOfReportLog() === 'screen' || Debug::getKindOfReportLog() === 'all') { |
58
|
|
|
|
59
|
|
|
echo '<table width="100%" style="background:orange;border:solid red 15px;"><tr><td style="color:black;padding:10px;font-size:18px;">'; |
60
|
|
|
echo $context['file'].'> (l.'.$context['line'].') '.$message.'<br/>'."\n"; |
61
|
|
|
echo '</td></tr></table>'; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.