- BC Break: _PHP_ namespaces changed (PSR-4 standard). The _root_ namespace for all _PF_ related scripts is Exodus4D\Pathfinder
- BC Break: Project folder structure changed. Removed `app/main` dir. - BC Break: Core _PHP_ framework + dependencies moved into `composer.json` and are no longer part of this repo
This commit is contained in:
62
app/Lib/Logging/Handler/SocketHandler.php
Normal file
62
app/Lib/Logging/Handler/SocketHandler.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Exodus 4D
|
||||
* Date: 23.02.2019
|
||||
* Time: 19:11
|
||||
*/
|
||||
|
||||
namespace Exodus4D\Pathfinder\Lib\Logging\Handler;
|
||||
|
||||
|
||||
use Monolog\Logger;
|
||||
|
||||
class SocketHandler extends \Monolog\Handler\SocketHandler {
|
||||
|
||||
/**
|
||||
* some meta data (additional processing information)
|
||||
* @var array|string
|
||||
*/
|
||||
protected $metaData = [];
|
||||
|
||||
/**
|
||||
* SocketHandler constructor.
|
||||
* @param $connectionString
|
||||
* @param int $level
|
||||
* @param bool $bubble
|
||||
* @param array $metaData
|
||||
*/
|
||||
public function __construct($connectionString, $level = Logger::DEBUG, $bubble = true, $metaData = []){
|
||||
$this->metaData = $metaData;
|
||||
|
||||
parent::__construct($connectionString, $level, $bubble);
|
||||
}
|
||||
|
||||
/**
|
||||
* overwrite default handle()
|
||||
* -> change data structure after processor() calls and before formatter() calls
|
||||
* @param array $record
|
||||
* @return bool
|
||||
*/
|
||||
public function handle(array $record) : bool {
|
||||
if (!$this->isHandling($record)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$record = $this->processRecord($record);
|
||||
|
||||
$record = [
|
||||
'task' => 'logData',
|
||||
'load' => [
|
||||
'meta' => $this->metaData,
|
||||
'log' => $record
|
||||
]
|
||||
];
|
||||
|
||||
$record['formatted'] = $this->getFormatter()->format($record);
|
||||
|
||||
$this->write($record);
|
||||
|
||||
return false === $this->bubble;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user