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 Fluent\Logger\PackerInterface; |
24
|
|
|
use Psr\Log\LoggerInterface; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Class Writer |
28
|
|
|
*/ |
29
|
|
|
class Writer extends \Illuminate\Log\Writer |
30
|
|
|
{ |
31
|
|
|
/** @var null */ |
32
|
|
|
protected $packer = null; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param string $host |
36
|
|
|
* @param int $port |
37
|
|
|
* @param array $options |
38
|
|
|
* @param string|null $tagFormat |
39
|
|
|
* @param string $level |
40
|
|
|
* |
41
|
|
|
* @return LoggerInterface |
42
|
|
|
*/ |
43
|
|
|
public function useFluentLogger( |
44
|
|
|
string $host, |
45
|
|
|
int $port, |
46
|
|
|
array $options = [], |
47
|
|
|
string $tagFormat = null, |
48
|
|
|
string $level = 'debug' |
49
|
|
|
): LoggerInterface { |
50
|
|
|
return $this->monolog->pushHandler( |
51
|
|
|
new FluentHandler( |
52
|
|
|
new FluentLogger($host, $port, $options, $this->packer), |
53
|
|
|
$tagFormat, |
54
|
|
|
$this->parseLevel($level) |
55
|
|
|
) |
56
|
|
|
); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param PackerInterface $packer |
61
|
|
|
*/ |
62
|
|
|
public function setPacker(PackerInterface $packer) |
63
|
|
|
{ |
64
|
|
|
$this->packer = $packer; |
|
|
|
|
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..