1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
6
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
7
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
8
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
9
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
10
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
11
|
|
|
* THE SOFTWARE. |
12
|
|
|
* |
13
|
|
|
* This software consists of voluntary contributions made by many individuals |
14
|
|
|
* and is licensed under the MIT license. |
15
|
|
|
* |
16
|
|
|
* Copyright (c) 2015-2017 Yuuki Takezawa |
17
|
|
|
* |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
namespace Ytake\LaravelFluent; |
21
|
|
|
|
22
|
|
|
use Fluent\Logger\FluentLogger; |
23
|
|
|
use Monolog\Logger as Monolog; |
24
|
|
|
use Psr\Log\LoggerInterface; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Class LogServiceProvider |
28
|
|
|
*/ |
29
|
|
|
class LogServiceProvider extends \Illuminate\Log\LogServiceProvider |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* {@inheritdoc} |
33
|
|
|
*/ |
34
|
|
|
public function register() |
35
|
|
|
{ |
36
|
|
|
/** |
37
|
|
|
* for package configure |
38
|
|
|
*/ |
39
|
|
|
$configPath = __DIR__ . '/config/fluent.php'; |
40
|
|
|
$this->mergeConfigFrom($configPath, 'fluent'); |
41
|
|
|
$this->publishes([$configPath => config_path('fluent.php')], 'log'); |
42
|
|
|
parent::register(); |
43
|
|
|
|
44
|
|
|
$configure = $this->app['config']->get('fluent'); |
45
|
|
|
if ($configure['always']) { |
46
|
|
|
$this->configureFluentHandler($this->app->make(LoggerInterface::class)); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* {@inheritdoc} |
52
|
|
|
*/ |
53
|
|
|
public function createLogger() |
54
|
|
|
{ |
55
|
|
|
$log = new Writer(new Monolog($this->channel()), $this->app['events']); |
56
|
|
|
if ($this->app->hasMonologConfigurator()) { |
|
|
|
|
57
|
|
|
call_user_func($this->app->getMonologConfigurator(), $log->getMonolog()); |
|
|
|
|
58
|
|
|
} else { |
59
|
|
|
$this->configureHandler($log); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
return $log; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @param Writer $log |
67
|
|
|
*/ |
68
|
|
|
protected function configureFluentHandler(Writer $log) |
69
|
|
|
{ |
70
|
|
|
$configure = $this->app['config']->get('fluent'); |
71
|
|
|
if (!is_null($configure['packer'])) { |
72
|
|
|
if (class_exists($configure['packer'])) { |
73
|
|
|
$log->setPacker($this->app->make($configure['packer'])); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
$log->useFluentLogger( |
77
|
|
|
$configure['host'] ?? FluentLogger::DEFAULT_ADDRESS, |
78
|
|
|
(int)$configure['port'] ?? FluentLogger::DEFAULT_LISTEN_PORT, |
79
|
|
|
$configure['options'] ?? [], |
80
|
|
|
$configure['tagFormat'] ?? null |
81
|
|
|
); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.