Skip to content

Commit e72df18

Browse files
committed
Update to default log channel
1 parent f62d18e commit e72df18

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

config/exception-notify.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
| The default channel of the exception notification report.
145145
|
146146
*/
147-
'default' => env('EXCEPTION_NOTIFY_DEFAULT_CHANNEL', 'mail'),
147+
'default' => env('EXCEPTION_NOTIFY_DEFAULT_CHANNEL', 'log'),
148148

149149
/*
150150
|--------------------------------------------------------------------------
@@ -209,6 +209,14 @@
209209
],
210210
],
211211

212+
// Log
213+
'log' => [
214+
'driver' => 'log',
215+
'channel' => env('EXCEPTION_NOTIFY_LOG_CHANNEL', config('logging.default')),
216+
'level' => env('EXCEPTION_NOTIFY_LOG_LEVEL', 'error'),
217+
'pipeline' => [],
218+
],
219+
212220
// 邮件
213221
'mail' => [
214222
'driver' => 'mail',

src/Channels/LogChannel.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@ class LogChannel extends Channel
1919
*/
2020
protected $level;
2121

22-
public function __construct(string $level = 'info')
22+
/**
23+
* @var string
24+
*/
25+
protected $channel;
26+
27+
public function __construct(string $channel, string $level)
2328
{
29+
$this->channel = $channel;
2430
$this->level = $level;
2531
}
2632

2733
public function report(string $report)
2834
{
29-
Log::{$this->level}($report);
35+
Log::channel($this->channel)->{$this->level}($report);
3036
}
3137
}

src/ExceptionNotifyManager.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,10 @@ protected function createFeiShuDriver()
244244

245245
protected function createLogDriver()
246246
{
247-
return new LogChannel(config('exception-notify.channels.log.level', 'error'));
247+
return new LogChannel(
248+
config('exception-notify.channels.log.channel'),
249+
config('exception-notify.channels.log.level')
250+
);
248251
}
249252

250253
protected function createMailDriver()

0 commit comments

Comments
 (0)