mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-21 08:36:33 +02:00
Merge branch '1.x'
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
|
||||
namespace Monolog\Processor;
|
||||
|
||||
use Monolog\Utils;
|
||||
|
||||
/**
|
||||
* Processes a record's message according to PSR-3 rules
|
||||
*
|
||||
@@ -66,7 +68,7 @@ class PsrLogMessageProcessor implements ProcessorInterface
|
||||
$replacements[$placeholder] = $val->format($this->dateFormat ?: static::SIMPLE_DATE);
|
||||
}
|
||||
} elseif (is_object($val)) {
|
||||
$replacements[$placeholder] = '[object '.get_class($val).']';
|
||||
$replacements[$placeholder] = '[object '.Utils::getClass($val).']';
|
||||
} elseif (is_array($val)) {
|
||||
$replacements[$placeholder] = 'array'.@json_encode($val);
|
||||
} else {
|
||||
|
@@ -11,12 +11,14 @@
|
||||
|
||||
namespace Monolog\Processor;
|
||||
|
||||
use Monolog\ResettableInterface;
|
||||
|
||||
/**
|
||||
* Adds a unique identifier into records
|
||||
*
|
||||
* @author Simon Mönch <sm@webfactory.de>
|
||||
*/
|
||||
class UidProcessor implements ProcessorInterface
|
||||
class UidProcessor implements ProcessorInterface, ResettableInterface
|
||||
{
|
||||
private $uid;
|
||||
|
||||
@@ -26,7 +28,7 @@ class UidProcessor implements ProcessorInterface
|
||||
throw new \InvalidArgumentException('The uid length must be an integer between 1 and 32');
|
||||
}
|
||||
|
||||
$this->uid = substr(bin2hex(random_bytes((int) ceil($length / 2))), 0, $length);
|
||||
$this->uid = $this->generateUid($length);
|
||||
}
|
||||
|
||||
public function __invoke(array $record): array
|
||||
@@ -43,4 +45,14 @@ class UidProcessor implements ProcessorInterface
|
||||
{
|
||||
return $this->uid;
|
||||
}
|
||||
|
||||
public function reset()
|
||||
{
|
||||
$this->uid = $this->generateUid(strlen($this->uid));
|
||||
}
|
||||
|
||||
private function generateUid($length)
|
||||
{
|
||||
return substr(bin2hex(random_bytes((int) ceil($length / 2))), 0, $length);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user