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