@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -declare(strict_types=1); |
|
2 | +declare(strict_types = 1); |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * for package configure |
36 | 36 | */ |
37 | - $configPath = __DIR__ . '/config/fluent.php'; |
|
37 | + $configPath = __DIR__.'/config/fluent.php'; |
|
38 | 38 | $this->mergeConfigFrom($configPath, 'fluent'); |
39 | 39 | $this->publishes([$configPath => config_path('fluent.php')], 'log'); |
40 | 40 | parent::register(); |
@@ -105,7 +105,6 @@ |
||
105 | 105 | /** |
106 | 106 | * Parse the string level into a Monolog constant. |
107 | 107 | * |
108 | - * @param array $config |
|
109 | 108 | * |
110 | 109 | * @throws \InvalidArgumentException |
111 | 110 | * |
@@ -16,109 +16,109 @@ |
||
16 | 16 | |
17 | 17 | class CreateFluentLogger |
18 | 18 | { |
19 | - /** |
|
20 | - * @var Application |
|
21 | - */ |
|
22 | - private $app; |
|
19 | + /** |
|
20 | + * @var Application |
|
21 | + */ |
|
22 | + private $app; |
|
23 | 23 | |
24 | - /** |
|
25 | - * The Log levels. |
|
26 | - * |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - protected $levels = [ |
|
30 | - 'debug' => Logger::DEBUG, |
|
31 | - 'info' => Logger::INFO, |
|
32 | - 'notice' => Logger::NOTICE, |
|
33 | - 'warning' => Logger::WARNING, |
|
34 | - 'error' => Logger::ERROR, |
|
35 | - 'critical' => Logger::CRITICAL, |
|
36 | - 'alert' => Logger::ALERT, |
|
37 | - 'emergency' => Logger::EMERGENCY, |
|
38 | - ]; |
|
24 | + /** |
|
25 | + * The Log levels. |
|
26 | + * |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + protected $levels = [ |
|
30 | + 'debug' => Logger::DEBUG, |
|
31 | + 'info' => Logger::INFO, |
|
32 | + 'notice' => Logger::NOTICE, |
|
33 | + 'warning' => Logger::WARNING, |
|
34 | + 'error' => Logger::ERROR, |
|
35 | + 'critical' => Logger::CRITICAL, |
|
36 | + 'alert' => Logger::ALERT, |
|
37 | + 'emergency' => Logger::EMERGENCY, |
|
38 | + ]; |
|
39 | 39 | |
40 | - /** |
|
41 | - * CreateFluentLogger constructor. |
|
42 | - * |
|
43 | - * @param Application $app |
|
44 | - */ |
|
45 | - public function __construct(Application $app) |
|
46 | - { |
|
47 | - $this->app = $app; |
|
48 | - } |
|
40 | + /** |
|
41 | + * CreateFluentLogger constructor. |
|
42 | + * |
|
43 | + * @param Application $app |
|
44 | + */ |
|
45 | + public function __construct(Application $app) |
|
46 | + { |
|
47 | + $this->app = $app; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Create a custom Monolog instance. |
|
52 | - * |
|
53 | - * @param array $config |
|
54 | - * |
|
55 | - * @return \Monolog\Logger |
|
56 | - */ |
|
57 | - public function __invoke(array $config) |
|
58 | - { |
|
59 | - $configure = $this->app['config']->get('fluent'); |
|
50 | + /** |
|
51 | + * Create a custom Monolog instance. |
|
52 | + * |
|
53 | + * @param array $config |
|
54 | + * |
|
55 | + * @return \Monolog\Logger |
|
56 | + */ |
|
57 | + public function __invoke(array $config) |
|
58 | + { |
|
59 | + $configure = $this->app['config']->get('fluent'); |
|
60 | 60 | |
61 | - if ($configure['packer'] !== null) { |
|
62 | - if (class_exists($configure['packer'])) { |
|
63 | - $packer = $this->app->make($configure['packer']); |
|
64 | - } |
|
65 | - } |
|
61 | + if ($configure['packer'] !== null) { |
|
62 | + if (class_exists($configure['packer'])) { |
|
63 | + $packer = $this->app->make($configure['packer']); |
|
64 | + } |
|
65 | + } |
|
66 | 66 | |
67 | - $fluentLogger = new FluentLogger( |
|
68 | - $configure['host'] ?? FluentLogger::DEFAULT_ADDRESS, |
|
69 | - (int) $configure['port'] ?? FluentLogger::DEFAULT_LISTEN_PORT, |
|
70 | - $configure['options'] ?? [], |
|
71 | - $packer ?? null); |
|
67 | + $fluentLogger = new FluentLogger( |
|
68 | + $configure['host'] ?? FluentLogger::DEFAULT_ADDRESS, |
|
69 | + (int) $configure['port'] ?? FluentLogger::DEFAULT_LISTEN_PORT, |
|
70 | + $configure['options'] ?? [], |
|
71 | + $packer ?? null); |
|
72 | 72 | |
73 | - $logger = new Logger('fluent', [ |
|
74 | - $this->prepareHandler(new FluentHandler( |
|
75 | - $fluentLogger, $configure['tagFormat'] ?? null, $this->level($this->app['config']['app.log_level']))), |
|
76 | - ]); |
|
73 | + $logger = new Logger('fluent', [ |
|
74 | + $this->prepareHandler(new FluentHandler( |
|
75 | + $fluentLogger, $configure['tagFormat'] ?? null, $this->level($this->app['config']['app.log_level']))), |
|
76 | + ]); |
|
77 | 77 | |
78 | - return $logger; |
|
79 | - } |
|
78 | + return $logger; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * Prepare the handler for usage by Monolog. |
|
83 | - * |
|
84 | - * @param \Monolog\Handler\HandlerInterface $handler |
|
85 | - * |
|
86 | - * @return \Monolog\Handler\HandlerInterface |
|
87 | - */ |
|
88 | - protected function prepareHandler(HandlerInterface $handler) |
|
89 | - { |
|
90 | - return $handler->setFormatter($this->formatter()); |
|
91 | - } |
|
81 | + /** |
|
82 | + * Prepare the handler for usage by Monolog. |
|
83 | + * |
|
84 | + * @param \Monolog\Handler\HandlerInterface $handler |
|
85 | + * |
|
86 | + * @return \Monolog\Handler\HandlerInterface |
|
87 | + */ |
|
88 | + protected function prepareHandler(HandlerInterface $handler) |
|
89 | + { |
|
90 | + return $handler->setFormatter($this->formatter()); |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * Get a Monolog formatter instance. |
|
95 | - * |
|
96 | - * @return \Monolog\Formatter\FormatterInterface |
|
97 | - */ |
|
98 | - protected function formatter() |
|
99 | - { |
|
100 | - return tap(new LineFormatter(null, null, true, true), function ($formatter) { |
|
101 | - $formatter->includeStacktraces(); |
|
102 | - }); |
|
103 | - } |
|
93 | + /** |
|
94 | + * Get a Monolog formatter instance. |
|
95 | + * |
|
96 | + * @return \Monolog\Formatter\FormatterInterface |
|
97 | + */ |
|
98 | + protected function formatter() |
|
99 | + { |
|
100 | + return tap(new LineFormatter(null, null, true, true), function ($formatter) { |
|
101 | + $formatter->includeStacktraces(); |
|
102 | + }); |
|
103 | + } |
|
104 | 104 | |
105 | - /** |
|
106 | - * Parse the string level into a Monolog constant. |
|
107 | - * |
|
108 | - * @param array $config |
|
109 | - * |
|
110 | - * @throws \InvalidArgumentException |
|
111 | - * |
|
112 | - * @return int |
|
113 | - */ |
|
114 | - protected function level(string $level) |
|
115 | - { |
|
116 | - $level = $level ?? 'debug'; |
|
105 | + /** |
|
106 | + * Parse the string level into a Monolog constant. |
|
107 | + * |
|
108 | + * @param array $config |
|
109 | + * |
|
110 | + * @throws \InvalidArgumentException |
|
111 | + * |
|
112 | + * @return int |
|
113 | + */ |
|
114 | + protected function level(string $level) |
|
115 | + { |
|
116 | + $level = $level ?? 'debug'; |
|
117 | 117 | |
118 | - if (isset($this->levels[$level])) { |
|
119 | - return $this->levels[$level]; |
|
120 | - } |
|
118 | + if (isset($this->levels[$level])) { |
|
119 | + return $this->levels[$level]; |
|
120 | + } |
|
121 | 121 | |
122 | - throw new \InvalidArgumentException('Invalid log level.'); |
|
123 | - } |
|
122 | + throw new \InvalidArgumentException('Invalid log level.'); |
|
123 | + } |
|
124 | 124 | } |
125 | 125 | \ No newline at end of file |
@@ -97,7 +97,7 @@ |
||
97 | 97 | */ |
98 | 98 | protected function formatter() |
99 | 99 | { |
100 | - return tap(new LineFormatter(null, null, true, true), function ($formatter) { |
|
100 | + return tap(new LineFormatter(null, null, true, true), function($formatter) { |
|
101 | 101 | $formatter->includeStacktraces(); |
102 | 102 | }); |
103 | 103 | } |