mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
normalize-logging
This commit is contained in:
22
app/Logging/NexusFormatter.php
Normal file
22
app/Logging/NexusFormatter.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace App\Logging;
|
||||
|
||||
use Monolog\Formatter\LineFormatter;
|
||||
|
||||
class NexusFormatter
|
||||
{
|
||||
public function __invoke($logger)
|
||||
{
|
||||
foreach ($logger->getHandlers() as $handler) {
|
||||
$handler->setFormatter($this->formatter());
|
||||
}
|
||||
}
|
||||
|
||||
protected function formatter()
|
||||
{
|
||||
$format = "[%datetime%] [" . REQUEST_ID . "] %channel%.%level_name%: %message% %context% %extra%\n";
|
||||
return tap(new LineFormatter($format, null, true, true), function ($formatter) {
|
||||
$formatter->includeStacktraces();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user