mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-06 13:16:39 +02:00
Merge branch '2.x'
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
### 3.3.1 (2023-02-06)
|
||||
|
||||
* Fixed Logger not being serializable anymore (#1792)
|
||||
|
||||
### 3.3.0 (2023-02-06)
|
||||
|
||||
* Deprecated FlowdockHandler & Formatter as the flowdock service was shutdown (#1748)
|
||||
@@ -80,6 +84,10 @@ New deprecations:
|
||||
value equal to what `Logger::WARNING` was giving you.
|
||||
- `Logger::getLevelName()` is now deprecated.
|
||||
|
||||
### 2.9.1 (2023-02-06)
|
||||
|
||||
* Fixed Logger not being serializable anymore (#1792)
|
||||
|
||||
### 2.9.0 (2023-02-05)
|
||||
|
||||
* Deprecated FlowdockHandler & Formatter as the flowdock service was shutdown (#1748)
|
||||
|
@@ -90,6 +90,11 @@ parameters:
|
||||
count: 1
|
||||
path: src/Monolog/Logger.php
|
||||
|
||||
-
|
||||
message: "#^Variable property access on \\$this\\(Monolog\\\\Logger\\)\\.$#"
|
||||
count: 1
|
||||
path: src/Monolog/Logger.php
|
||||
|
||||
-
|
||||
message: "#^Comparison operation \"\\<\" between int\\<1, 32\\> and 1 is always false\\.$#"
|
||||
count: 1
|
||||
|
@@ -701,4 +701,35 @@ class Logger implements LoggerInterface, ResettableInterface
|
||||
|
||||
($this->exceptionHandler)($e, $record);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function __serialize(): array
|
||||
{
|
||||
return [
|
||||
'name' => $this->name,
|
||||
'handlers' => $this->handlers,
|
||||
'processors' => $this->processors,
|
||||
'microsecondTimestamps' => $this->microsecondTimestamps,
|
||||
'timezone' => $this->timezone,
|
||||
'exceptionHandler' => $this->exceptionHandler,
|
||||
'logDepth' => $this->logDepth,
|
||||
'detectCycles' => $this->detectCycles,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
public function __unserialize(array $data): void
|
||||
{
|
||||
foreach (['name', 'handlers', 'processors', 'microsecondTimestamps', 'timezone', 'exceptionHandler', 'logDepth', 'detectCycles'] as $property) {
|
||||
if (isset($data[$property])) {
|
||||
$this->$property = $data[$property];
|
||||
}
|
||||
}
|
||||
|
||||
$this->fiberLogDepth = new \WeakMap();
|
||||
}
|
||||
}
|
||||
|
@@ -699,6 +699,16 @@ class LoggerTest extends TestCase
|
||||
$logger->info('test');
|
||||
}
|
||||
|
||||
public function testSerializable()
|
||||
{
|
||||
$logger = new Logger(__METHOD__);
|
||||
$copy = unserialize(serialize($logger));
|
||||
self::assertInstanceOf(Logger::class, $copy);
|
||||
self::assertSame($logger->getName(), $copy->getName());
|
||||
self::assertSame($logger->getTimezone()->getName(), $copy->getTimezone()->getName());
|
||||
self::assertSame($logger->getHandlers(), $copy->getHandlers());
|
||||
}
|
||||
|
||||
public function testReset()
|
||||
{
|
||||
$logger = new Logger('app');
|
||||
|
Reference in New Issue
Block a user