Skip to content

Commit

Permalink
Logger に各種 Processor を追加で設定するクラスを定義
Browse files Browse the repository at this point in the history
  • Loading branch information
okashoi committed Mar 17, 2019
1 parent c293541 commit af2c0ce
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/app/Logging/CustomizeLogger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace App\Logging;

use Illuminate\Log\Logger;
use Monolog\Processor\ProcessIdProcessor;
use Monolog\Processor\IntrospectionProcessor;
use Monolog\Processor\WebProcessor;

/**
* Class CustomizeLogger
* @package App\Logging
*/
class CustomizeLogger
{
/**
* Customize the given logger instance.
*
* @param Logger $logger
* @return void
*/
public function __invoke(Logger $logger)
{
foreach ($logger->getHandlers() as $handler) {
// url, ip, http_method, referrer を extra に追加
$handler->pushProcessor(new WebProcessor());
// file, line, class, function を extra に追加
$handler->pushProcessor(new IntrospectionProcessor(\Monolog\Logger::DEBUG, ['Illuminate\\']));
// process_id を extra に追加
$handler->pushProcessor(new ProcessIdProcessor());
// process_type を extra に追加
$handler->pushProcessor(new ProcessTypeProcessor());
}
}
}

0 comments on commit af2c0ce

Please sign in to comment.