1 | <?php |
||
2 | |||
3 | namespace Nip\Logger\Manager; |
||
4 | |||
5 | /** |
||
6 | * Trait HasChannels |
||
7 | * @package Nip\Logger\Traits |
||
8 | */ |
||
9 | trait HasChannels |
||
10 | { |
||
11 | /** |
||
12 | * The array of resolved channels. |
||
13 | * |
||
14 | * @var array |
||
15 | */ |
||
16 | protected $channels = []; |
||
17 | |||
18 | /** |
||
19 | * Get a log channel instance. |
||
20 | * |
||
21 | * @param string|null $channel |
||
22 | * @return \Psr\Log\LoggerInterface |
||
23 | */ |
||
24 | 1 | public function channel($channel = null) |
|
25 | { |
||
26 | 1 | return $this->driver($channel); |
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
27 | } |
||
28 | |||
29 | /** |
||
30 | * Extract the log channel from the given configuration. |
||
31 | * |
||
32 | * @param array $config |
||
33 | * @return string |
||
34 | */ |
||
35 | 4 | protected function parseChannel(array $config) |
|
36 | { |
||
37 | 4 | return $config['name'] ?? $this->getFallbackChannelName(); |
|
38 | } |
||
39 | |||
40 | /** |
||
41 | * Get fallback log channel name. |
||
42 | * |
||
43 | * @return string |
||
44 | */ |
||
45 | 4 | protected function getFallbackChannelName() |
|
46 | { |
||
47 | 4 | return 'production'; |
|
48 | // return $this->app->bound('env') ? $this->app->environment() : 'production'; |
||
49 | } |
||
50 | } |
||
51 |