Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Seldaek/monolog
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3.3.0
Choose a base ref
...
head repository: Seldaek/monolog
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3.3.1
Choose a head ref
  • 5 commits
  • 4 files changed
  • 1 contributor

Commits on Feb 6, 2023

  1. 2

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2ae0444 View commit details
  2. Update changelog

    Seldaek committed Feb 6, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3e92e9d View commit details
  3. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c8b1e0e View commit details
  4. Add types

    Seldaek committed Feb 6, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f259e2b View commit details
  5. Merge branch '2.x'

    Seldaek committed Feb 6, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9b5daea View commit details
Showing with 54 additions and 0 deletions.
  1. +8 −0 CHANGELOG.md
  2. +5 −0 phpstan-baseline.neon
  3. +31 −0 src/Monolog/Logger.php
  4. +10 −0 tests/Monolog/LoggerTest.php
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions src/Monolog/Logger.php
Original file line number Diff line number Diff line change
@@ -701,4 +701,35 @@ protected function handleException(Throwable $e, LogRecord $record): void

($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();
}
}
10 changes: 10 additions & 0 deletions tests/Monolog/LoggerTest.php
Original file line number Diff line number Diff line change
@@ -699,6 +699,16 @@ public function testCustomHandleException()
$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');