mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-21 16:46:11 +02:00
Simplify code and cache the getmypid call, refs #167
This commit is contained in:
@@ -18,20 +18,22 @@ namespace Monolog\Processor;
|
||||
*/
|
||||
class ProcessIdProcessor
|
||||
{
|
||||
private static $pid;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if (null === self::$pid) {
|
||||
self::$pid = getmypid();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $record
|
||||
* @return array
|
||||
*/
|
||||
public function __invoke(array $record)
|
||||
{
|
||||
$pid = getmypid();
|
||||
|
||||
$record['extra'] = array_merge(
|
||||
$record['extra'],
|
||||
array(
|
||||
'process_id' => $pid,
|
||||
)
|
||||
);
|
||||
$record['extra']['process_id'] = self::$pid;
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
Reference in New Issue
Block a user