1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Bluz Framework Component |
4
|
|
|
* |
5
|
|
|
* @copyright Bluz PHP Team |
6
|
|
|
* @link https://github.com/bluzphp/framework |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
declare(strict_types=1); |
10
|
|
|
|
11
|
|
|
namespace Bluz\Proxy; |
12
|
|
|
|
13
|
|
|
use Bluz\Common\Nil; |
14
|
|
|
use Bluz\Logger\Logger as Instance; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Proxy to Logger |
18
|
|
|
* |
19
|
|
|
* Example of usage |
20
|
|
|
* <code> |
21
|
|
|
* use Bluz\Proxy\Logger; |
22
|
|
|
* |
23
|
|
|
* Logger::error('Configuration not found'); |
24
|
|
|
* </code> |
25
|
|
|
* |
26
|
|
|
* @package Bluz\Proxy |
27
|
|
|
* @author Anton Shevchuk |
28
|
|
|
* |
29
|
|
|
* @method static Instance getInstance() |
30
|
|
|
* |
31
|
|
|
* @method static void alert($message, array $context = []) |
32
|
|
|
* @see Instance::alert() |
33
|
|
|
* |
34
|
|
|
* @method static void critical($message, array $context = []) |
35
|
|
|
* @see Instance::critical() |
36
|
|
|
* |
37
|
|
|
* @method static void debug($message, array $context = []) |
38
|
|
|
* @see Instance::debug() |
39
|
|
|
* |
40
|
|
|
* @method static void emergency($message, array $context = []) |
41
|
|
|
* @see Instance::emergency() |
42
|
|
|
* |
43
|
|
|
* @method static void error($message, array $context = []) |
44
|
|
|
* @see Instance::error() |
45
|
|
|
* |
46
|
|
|
* @method static void info($message, array $context = []) |
47
|
|
|
* @see Instance::info() |
48
|
|
|
* |
49
|
|
|
* @method static void notice($message, array $context = []) |
50
|
|
|
* @see Instance::notice() |
51
|
|
|
* |
52
|
|
|
* @method static void warning($message, array $context = []) |
53
|
|
|
* @see Instance::warning() |
54
|
|
|
* |
55
|
|
|
* @method static void log($level, $message, array $context = []) |
56
|
|
|
* @see Instance::log() |
57
|
|
|
* |
58
|
|
|
* @method static array get($level) |
59
|
|
|
* @see Instance::get() |
60
|
|
|
*/ |
61
|
|
|
final class Logger |
62
|
|
|
{ |
63
|
|
|
use ProxyTrait; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Init instance |
67
|
|
|
* |
68
|
|
|
* @return Instance|Nil |
69
|
|
|
*/ |
70
|
585 |
|
private static function initInstance() |
|
|
|
|
71
|
|
|
{ |
72
|
585 |
|
if (Config::getData('logger')) { |
73
|
580 |
|
return new Instance(); |
74
|
|
|
} |
75
|
5 |
|
return new Nil(); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* exception |
80
|
|
|
* |
81
|
|
|
* @param \Exception $exception |
82
|
|
|
* |
83
|
|
|
* @return void |
84
|
|
|
*/ |
85
|
2 |
|
public static function exception($exception) |
86
|
|
|
{ |
87
|
2 |
|
self::getInstance()->error( |
88
|
2 |
|
$exception->getMessage() . ' [' . |
89
|
2 |
|
$exception->getFile() . ':' . |
90
|
2 |
|
$exception->getLine() . ']' |
91
|
|
|
); |
92
|
2 |
|
} |
93
|
|
|
} |
94
|
|
|
|