1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-09 14:46:46 +02:00

Merge remote-tracking branch 'webfactory/master'

This commit is contained in:
Jordi Boggiano
2013-02-26 11:14:11 +01:00
3 changed files with 64 additions and 0 deletions

View File

@@ -184,6 +184,7 @@ Processors
- _MemoryUsageProcessor_: Adds the current memory usage to a log record.
- _MemoryPeakUsageProcessor_: Adds the peak memory usage to a log record.
- _ProcessIdProcessor_: Adds the process id to a log record.
- _UidProcessor_: Adds a unique identifier to a log record.
About
=====

View File

@@ -0,0 +1,36 @@
<?php
/*
* This file is part of the Monolog package.
*
* (c) Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Monolog\Processor;
/**
* Adds a unique identifier into records
*
* @author Simon Mönch <sm@webfactory.de>
*/
class UidProcessor
{
private $uid;
public function __construct()
{
if (null === $this->uid) {
$this->uid = substr(hash('md5', uniqid('', true)), 0, 7);
}
}
public function __invoke(array $record)
{
$record['extra']['uid'] = $this->uid;
return $record;
}
}

View File

@@ -0,0 +1,27 @@
<?php
/*
* This file is part of the Monolog package.
*
* (c) Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Monolog\Processor;
use Monolog\TestCase;
class UidProcessorTest extends TestCase
{
/**
* @covers Monolog\Processor\UidProcessor::__invoke
*/
public function testProcessor()
{
$processor = new UidProcessor();
$record = $processor($this->getRecord());
$this->assertArrayHasKey('uid', $record['extra']);
}
}