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.2.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.0
Choose a head ref

Commits on Aug 2, 2022

  1. Update BrowserConsoleHandler console output method (#1739)

    Instead of using console.log for all log levels, it uses debug, info, warn and error methods depending on the log level.
    This makes filtering logs easier in the browser console and highlights error level messages.
    pafernandez-oesia authored Aug 2, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    620dca1 View commit details
  2. Fix build

    Seldaek committed Aug 2, 2022

    Verified

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

    Seldaek committed Aug 2, 2022

    Verified

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

Commits on Aug 17, 2022

  1. Verified

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

Commits on Aug 20, 2022

  1. Minor docblock tweaks

    Seldaek committed Aug 20, 2022

    Verified

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

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    5eccd17 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
    6bf3b35 View commit details
  4. Merge branch '2.x'

    Seldaek committed Aug 20, 2022

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    caa6e04 View commit details
  5. Verified

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

    Seldaek committed Aug 20, 2022
    Copy the full SHA
    672dbb3 View commit details
  7. Copy the full SHA
    37b747c View commit details
  8. Copy the full SHA
    e68c006 View commit details

Commits on Oct 14, 2022

  1. Copy the full SHA
    1387e02 View commit details

Commits on Feb 4, 2023

  1. Add ClosureContextProcessor (#1745)

    Co-authored-by: Jordi Boggiano <j.boggiano@seld.be>
    upyx and Seldaek authored Feb 4, 2023
    Copy the full SHA
    e18aa33 View commit details
  2. Fix date/time field for GCP logging (#1758)

    We introduced the formatter using the incorrect field, which was making GCP not to extract the correct value from the payload.
    
    This uses the field that actually maps to the expected format.
    
    More info: https://cloud.google.com/logging/docs/structured-logging
    lcobucci authored Feb 4, 2023
    Copy the full SHA
    e937256 View commit details
  3. Fix date/time field for GCP logging (#1759)

    We introduced the formatter using the incorrect field, which was making
    GCP not to extract the correct value from the payload.
    
    This uses the field that actually maps to the expected format.
    
    More info: https://cloud.google.com/logging/docs/structured-logging
    lcobucci authored Feb 4, 2023
    Copy the full SHA
    69bd363 View commit details
  4. Fix setting of extra attributes in AmqpHandler when handling batches …

    …of records (#1781)
    
    One of content_type, content_encoding, message_id, user_id, app_id, delivery_mode, priority, timestamp, expiration, type or reply_to, headers.
    
    Co-authored-by: Попов Михаил <popov.mv@betcity.ru>
    pmikle and Попов Михаил authored Feb 4, 2023
    Copy the full SHA
    58f5030 View commit details
  5. Fix cycle detection within fibers (#1753)

    * Fix cycle detection within fibers
    
    We keep a separate depth count per fiber.
    
    Fixes #1752.
    
    * Avoid additional call to Fiber::getCurrent()
    
    Suppresses phpstan errors, as they're false positives.
    kelunik authored Feb 4, 2023
    Copy the full SHA
    0f01420 View commit details
  6. Fix ignores

    Seldaek committed Feb 4, 2023
    Copy the full SHA
    6459aeb View commit details
  7. Copy the full SHA
    ea7eac4 View commit details
  8. Copy the full SHA
    8255feb View commit details
  9. Merge branch '2.x'

    Seldaek committed Feb 4, 2023
    Copy the full SHA
    c424dbc View commit details
  10. Copy the full SHA
    616c675 View commit details
  11. Copy the full SHA
    bbc6882 View commit details
  12. Add an option to set the op_type for the ElasticsearchHandler (#1766)

    Co-authored-by: Identei <>
    identei authored Feb 4, 2023
    Copy the full SHA
    f58e4f4 View commit details
  13. Copy the full SHA
    11fbf91 View commit details
  14. Add new option to type defs

    Seldaek committed Feb 4, 2023
    Copy the full SHA
    b40d426 View commit details
  15. Copy the full SHA
    0a60d69 View commit details
  16. GitHub Workflows security hardening (#1763)

    Signed-off-by: Alex <aleksandrosansan@gmail.com>
    sashashura authored Feb 4, 2023
    Copy the full SHA
    3b866c9 View commit details
  17. Ignore enum errors

    Seldaek committed Feb 4, 2023
    Copy the full SHA
    7c04005 View commit details
  18. Copy the full SHA
    1f25f9b View commit details
  19. Copy the full SHA
    2f34389 View commit details
  20. Merge branch '2.x'

    Seldaek committed Feb 4, 2023
    Copy the full SHA
    76dc211 View commit details

Commits on Feb 5, 2023

  1. Update changelog

    Seldaek committed Feb 5, 2023
    Copy the full SHA
    e1c0ae1 View commit details

Commits on Feb 6, 2023

  1. Merge branch '2.x'

    Seldaek committed Feb 6, 2023
    Copy the full SHA
    852643b View commit details
Showing with 415 additions and 87 deletions.
  1. +12 −0 .editorconfig
  2. +1 −0 .gitattributes
  3. +3 −0 .github/workflows/continuous-integration.yml
  4. +3 −0 .github/workflows/lint.yml
  5. +3 −0 .github/workflows/phpstan.yml
  6. +25 −0 CHANGELOG.md
  7. +1 −0 README.md
  8. +6 −6 composer.json
  9. +1 −2 doc/02-handlers-formatters-processors.md
  10. +1 −1 doc/message-structure.md
  11. +10 −21 phpstan-baseline.neon
  12. +4 −4 phpunit.xml.dist
  13. +2 −0 src/Monolog/Formatter/ElasticaFormatter.php
  14. +2 −0 src/Monolog/Formatter/ElasticsearchFormatter.php
  15. +1 −0 src/Monolog/Formatter/FlowdockFormatter.php
  16. +3 −0 src/Monolog/Formatter/FluentdFormatter.php
  17. +3 −8 src/Monolog/Formatter/GelfMessageFormatter.php
  18. +2 −1 src/Monolog/Formatter/GoogleCloudLoggingFormatter.php
  19. +1 −0 src/Monolog/Formatter/HtmlFormatter.php
  20. +2 −0 src/Monolog/Formatter/JsonFormatter.php
  21. +2 −0 src/Monolog/Formatter/LineFormatter.php
  22. +2 −0 src/Monolog/Formatter/LogstashFormatter.php
  23. +1 −0 src/Monolog/Formatter/NormalizerFormatter.php
  24. +2 −0 src/Monolog/Formatter/WildfireFormatter.php
  25. +8 −7 src/Monolog/Handler/AmqpHandler.php
  26. +13 −2 src/Monolog/Handler/BrowserConsoleHandler.php
  27. +3 −0 src/Monolog/Handler/ChromePHPHandler.php
  28. +1 −1 src/Monolog/Handler/DeduplicationHandler.php
  29. +6 −3 src/Monolog/Handler/ElasticsearchHandler.php
  30. +2 −0 src/Monolog/Handler/ErrorLogHandler.php
  31. +1 −1 src/Monolog/Handler/FleepHookHandler.php
  32. +1 −0 src/Monolog/Handler/FlowdockHandler.php
  33. +2 −0 src/Monolog/Handler/GroupHandler.php
  34. +2 −0 src/Monolog/Handler/IFTTTHandler.php
  35. +2 −0 src/Monolog/Handler/MandrillHandler.php
  36. +2 −2 src/Monolog/Handler/RotatingFileHandler.php
  37. +2 −0 src/Monolog/Handler/SendGridHandler.php
  38. +2 −0 src/Monolog/Handler/SlackWebhookHandler.php
  39. +1 −1 src/Monolog/Handler/SyslogUdpHandler.php
  40. +1 −1 src/Monolog/Handler/TelegramBotHandler.php
  41. +14 −0 src/Monolog/Handler/WhatFailureGroupHandler.php
  42. +2 −2 src/Monolog/Level.php
  43. +23 −5 src/Monolog/Logger.php
  44. +51 −0 src/Monolog/Processor/ClosureContextProcessor.php
  45. +1 −1 src/Monolog/Processor/GitProcessor.php
  46. +5 −5 src/Monolog/Processor/IntrospectionProcessor.php
  47. +2 −0 src/Monolog/Processor/PsrLogMessageProcessor.php
  48. +2 −1 src/Monolog/SignalHandler.php
  49. +2 −2 tests/Monolog/Formatter/GoogleCloudLoggingFormatterTest.php
  50. +10 −10 tests/Monolog/Handler/BrowserConsoleHandlerTest.php
  51. +2 −0 tests/Monolog/Handler/ElasticsearchHandlerTest.php
  52. +76 −0 tests/Monolog/LoggerTest.php
  53. +69 −0 tests/Monolog/Processor/ClosureContextProcessorTest.php
  54. +12 −0 tests/Monolog/Processor/GitProcessorTest.php
  55. +2 −0 tests/Monolog/Processor/PsrLogMessageProcessorTest.php
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{yml,yaml}]
indent_size = 2
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -5,3 +5,4 @@
/phpunit.xml.dist export-ignore
/_config.yml export-ignore
/UPGRADE.md export-ignore
/.editorconfig export-ignore
3 changes: 3 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -4,6 +4,9 @@ on:
- push
- pull_request

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
tests:
name: "CI (PHP ${{ matrix.php-version }}, ${{ matrix.dependencies }} deps)"
3 changes: 3 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -4,6 +4,9 @@ on:
push:
pull_request:

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
tests:
name: "Lint"
3 changes: 3 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -7,6 +7,9 @@ on:
env:
COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist"

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
tests:
name: "PHPStan"
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
### 3.3.0 (2023-02-06)

* Deprecated FlowdockHandler & Formatter as the flowdock service was shutdown (#1748)
* Added `ClosureContextProcessor` to allow delaying the creation of context data by setting a Closure in context which is called when the log record is used (#1745)
* Added an ElasticsearchHandler option to set the `op_type` to `create` instead of the default `index` (#1766)
* Added support for enum context values in PsrLogMessageProcessor (#1773)
* Added graylog2/gelf-php 2.x support (#1747)
* Improved `BrowserConsoleHandler` logging to use more appropriate methods than just console.log in the browser (#1739)
* Fixed GitProcessor not filtering correctly based on Level (#1749)
* Fixed `WhatFailureGroupHandler` not catching errors happening inside `close()` (#1791)
* Fixed datetime field in `GoogleCloudLoggingFormatter` (#1758)
* Fixed infinite loop detection within Fibers (#1753)
* Fixed `AmqpHandler->setExtraAttributes` not working with buffering handler wrappers (#1781)

### 3.2.0 (2022-07-24)

* Deprecated `CubeHandler` and `PHPConsoleHandler` as both projects are abandoned and those should not be used anymore (#1734)
@@ -66,6 +80,17 @@ New deprecations:
value equal to what `Logger::WARNING` was giving you.
- `Logger::getLevelName()` is now deprecated.

### 2.9.0 (2023-02-05)

* Deprecated FlowdockHandler & Formatter as the flowdock service was shutdown (#1748)
* Added support for enum context values in PsrLogMessageProcessor (#1773)
* Added graylog2/gelf-php 2.x support (#1747)
* Improved `BrowserConsoleHandler` logging to use more appropriate methods than just console.log in the browser (#1739)
* Fixed `WhatFailureGroupHandler` not catching errors happening inside `close()` (#1791)
* Fixed datetime field in `GoogleCloudLoggingFormatter` (#1758)
* Fixed infinite loop detection within Fibers (#1753)
* Fixed `AmqpHandler->setExtraAttributes` not working with buffering handler wrappers (#1781)

### 2.8.0 (2022-07-24)

* Deprecated `CubeHandler` and `PHPConsoleHandler` as both projects are abandoned and those should not be used anymore (#1734)
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -101,6 +101,7 @@ Bugs and feature request are tracked on [GitHub](https://github.com/Seldaek/mono
- [Drupal](https://www.drupal.org/) is usable with Monolog via the [monolog](https://www.drupal.org/project/monolog) module.
- [Aimeos ecommerce framework](https://aimeos.org/) is usable with Monolog via the [ai-monolog](https://github.com/aimeos/ai-monolog) extension.
- [Magento](https://magento.com/) comes out of the box with Monolog.
- [Spiral Framework](https://spiral.dev) comes out of the box with Monolog bridge.

### Author

12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -21,16 +21,16 @@
"aws/aws-sdk-php": "^3.0",
"doctrine/couchdb": "~1.0@dev",
"elasticsearch/elasticsearch": "^7 || ^8",
"graylog2/gelf-php": "^1.4.2",
"guzzlehttp/guzzle": "^7.4",
"graylog2/gelf-php": "^1.4.2 || ^2@dev",
"guzzlehttp/guzzle": "^7.4.5",
"guzzlehttp/psr7": "^2.2",
"mongodb/mongodb": "^1.8",
"php-amqplib/php-amqplib": "~2.4 || ^3",
"phpstan/phpstan": "^1.4",
"phpstan/phpstan": "^1.9",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-strict-rules": "^1.1",
"phpunit/phpunit": "^9.5.16",
"predis/predis": "^1.1",
"phpstan/phpstan-strict-rules": "^1.4",
"phpunit/phpunit": "^9.5.26",
"predis/predis": "^1.1 || ^2",
"ruflin/elastica": "^7",
"symfony/mailer": "^5.4 || ^6",
"symfony/mime": "^5.4 || ^6"
3 changes: 1 addition & 2 deletions doc/02-handlers-formatters-processors.md
Original file line number Diff line number Diff line change
@@ -31,7 +31,6 @@
[`mail()`](http://php.net/manual/en/function.mail.php) function.
- [_SymfonyMailerHandler_](https://github.com/Seldaek/monolog/blob/main/src/Monolog/Handler/SymfonyMailerHandler.php): Sends emails using a [`symfony/mailer`](https://symfony.com/doc/current/mailer.html) instance.
- [_PushoverHandler_](https://github.com/Seldaek/monolog/blob/main/src/Monolog/Handler/PushoverHandler.php): Sends mobile notifications via the [Pushover](https://www.pushover.net/) API.
- [_FlowdockHandler_](https://github.com/Seldaek/monolog/blob/main/src/Monolog/Handler/FlowdockHandler.php): Logs records to a [Flowdock](https://www.flowdock.com/) account.
- [_SlackWebhookHandler_](https://github.com/Seldaek/monolog/blob/main/src/Monolog/Handler/SlackWebhookHandler.php): Logs records to a [Slack](https://www.slack.com/) account using Slack Webhooks.
- [_SlackHandler_](https://github.com/Seldaek/monolog/blob/main/src/Monolog/Handler/SlackHandler.php): Logs records to a [Slack](https://www.slack.com/) account using the Slack API (complex setup).
- [_SendGridHandler_](https://github.com/Seldaek/monolog/blob/main/src/Monolog/Handler/SendGridHandler.php): Sends emails via the SendGrid API.
@@ -152,7 +151,6 @@
- [_ElasticaFormatter_](https://github.com/Seldaek/monolog/blob/main/src/Monolog/Formatter/ElasticaFormatter.php): Used to format log records into an Elastica\Document object, only useful for the ElasticaHandler.
- [_ElasticsearchFormatter_](https://github.com/Seldaek/monolog/blob/main/src/Monolog/Formatter/ElasticsearchFormatter.php): Used to add index and type keys to log records, only useful for the ElasticsearchHandler.
- [_LogglyFormatter_](https://github.com/Seldaek/monolog/blob/main/src/Monolog/Formatter/LogglyFormatter.php): Used to format log records into Loggly messages, only useful for the LogglyHandler.
- [_FlowdockFormatter_](https://github.com/Seldaek/monolog/blob/main/src/Monolog/Formatter/FlowdockFormatter.php): Used to format log records into Flowdock messages, only useful for the FlowdockHandler.
- [_MongoDBFormatter_](https://github.com/Seldaek/monolog/blob/main/src/Monolog/Formatter/MongoDBFormatter.php): Converts \DateTime instances to \MongoDate and objects recursively to arrays, only useful with the MongoDBHandler.
- [_LogmaticFormatter_](https://github.com/Seldaek/monolog/blob/main/src/Monolog/Formatter/LogmaticFormatter.php): Used to format log records to [Logmatic](http://logmatic.io/) messages, only useful for the LogmaticHandler.
- [_FluentdFormatter_](https://github.com/Seldaek/monolog/blob/main/src/Monolog/Formatter/FluentdFormatter.php): Used to format log records to [Fluentd](https://www.fluentd.org/) logs, only useful with the SocketHandler.
@@ -162,6 +160,7 @@
## Processors

- [_PsrLogMessageProcessor_](https://github.com/Seldaek/monolog/blob/main/src/Monolog/Processor/PsrLogMessageProcessor.php): Processes a log record's message according to PSR-3 rules, replacing `{foo}` with the value from `$context['foo']`.
- [_ClosureContextProcessor_](https://github.com/Seldaek/monolog/blob/main/src/Monolog/Processor/ClosureContextProcessor.php): Allows delaying the creation of context data by setting a Closure in context which is called when the log record is used
- [_IntrospectionProcessor_](https://github.com/Seldaek/monolog/blob/main/src/Monolog/Processor/IntrospectionProcessor.php): Adds the line/file/class/method from which the log call originated.
- [_WebProcessor_](https://github.com/Seldaek/monolog/blob/main/src/Monolog/Processor/WebProcessor.php): Adds the current request URI, request method and client IP to a log record.
- [_MemoryUsageProcessor_](https://github.com/Seldaek/monolog/blob/main/src/Monolog/Processor/MemoryUsageProcessor.php): Adds the current memory usage to a log record.
2 changes: 1 addition & 1 deletion doc/message-structure.md
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ property | type | description
message | string | The log message. When the `PsrLogMessageProcessor` is used this string may contain placeholders that will be replaced by variables from the context, e.g., "User {username} logged in" with `['username' => 'John']` as context will be written as "User John logged in".
level | Monolog\Level case | Severity of the log message. See log levels described in [01-usage.md](01-usage.md#log-levels).
context | array | Arbitrary data passed with the construction of the message. For example the username of the current user or their IP address.
channel | string | The channel this message was logged to. This is the name that was passed when the logger was created with `new Logger($channel)`.
channel | string | The channel this message was logged to. This is the name that was passed when the logger was created with `new Logger('channel')`.
datetime | Monolog\DateTimeImmutable | Date and time when the message was logged. Class extends `\DateTimeImmutable`.
extra | array | A placeholder array where processors can put additional data. Always available, but empty if there are no processors registered.

31 changes: 10 additions & 21 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -10,21 +10,11 @@ parameters:
count: 1
path: src/Monolog/Formatter/JsonFormatter.php

-
message: "#^Cannot access offset 'table' on array\\<array\\|bool\\|float\\|int\\|string\\|null\\>\\|bool\\|float\\|int\\|object\\|string\\.$#"
count: 1
path: src/Monolog/Formatter/WildfireFormatter.php

-
message: "#^Return type \\(array\\<array\\|bool\\|float\\|int\\|string\\|null\\>\\|bool\\|float\\|int\\|object\\|string\\|null\\) of method Monolog\\\\Formatter\\\\WildfireFormatter\\:\\:normalize\\(\\) should be covariant with return type \\(array\\<array\\|bool\\|float\\|int\\|string\\|null\\>\\|bool\\|float\\|int\\|string\\|null\\) of method Monolog\\\\Formatter\\\\NormalizerFormatter\\:\\:normalize\\(\\)$#"
count: 1
path: src/Monolog/Formatter/WildfireFormatter.php

-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 1
path: src/Monolog/Handler/BrowserConsoleHandler.php

-
message: "#^Instanceof between Monolog\\\\Handler\\\\HandlerInterface and Monolog\\\\Handler\\\\HandlerInterface will always evaluate to true\\.$#"
count: 1
@@ -80,33 +70,33 @@ parameters:
count: 1
path: src/Monolog/Handler/SamplingHandler.php

-
message: "#^Match expression does not handle remaining value\\: 'EMERGENCY'$#"
count: 1
path: src/Monolog/Level.php

-
message: "#^Variable property access on \\$this\\(Monolog\\\\LogRecord\\)\\.$#"
count: 4
path: src/Monolog/LogRecord.php

-
message: "#^Parameter \\#1 \\$level \\('alert'\\|'critical'\\|'debug'\\|'emergency'\\|'error'\\|'info'\\|'notice'\\|'warning'\\|Monolog\\\\Level\\) of method Monolog\\\\Logger\\:\\:log\\(\\) should be contravariant with parameter \\$level \\(mixed\\) of method Psr\\\\Log\\\\LoggerInterface\\:\\:log\\(\\)$#"
message: "#^Cannot assign offset Fiber to WeakMap\\<Fiber\\<mixed, mixed, mixed, mixed\\>, int\\>\\.$#"
count: 1
path: src/Monolog/Logger.php

-
message: "#^Comparison operation \"\\<\" between int\\<1, 32\\> and 1 is always false\\.$#"
message: "#^Only numeric types are allowed in post\\-decrement, int\\|null given\\.$#"
count: 1
path: src/Monolog/Processor/UidProcessor.php
path: src/Monolog/Logger.php

-
message: "#^Comparison operation \"\\>\" between int\\<1, 32\\> and 32 is always false\\.$#"
message: "#^Parameter \\#1 \\$level \\('alert'\\|'critical'\\|'debug'\\|'emergency'\\|'error'\\|'info'\\|'notice'\\|'warning'\\|Monolog\\\\Level\\) of method Monolog\\\\Logger\\:\\:log\\(\\) should be contravariant with parameter \\$level \\(mixed\\) of method Psr\\\\Log\\\\LoggerInterface\\:\\:log\\(\\)$#"
count: 1
path: src/Monolog/Logger.php

-
message: "#^Comparison operation \"\\<\" between int\\<1, 32\\> and 1 is always false\\.$#"
count: 1
path: src/Monolog/Processor/UidProcessor.php

-
message: "#^Method Monolog\\\\Processor\\\\UidProcessor\\:\\:generateUid\\(\\) should return non\\-empty\\-string but returns string\\.$#"
message: "#^Comparison operation \"\\>\" between int\\<1, 32\\> and 32 is always false\\.$#"
count: 1
path: src/Monolog/Processor/UidProcessor.php

@@ -119,4 +109,3 @@ parameters:
message: "#^Parameter \\#2 \\$callback of function preg_replace_callback expects callable\\(array\\<int\\|string, string\\>\\)\\: string, Closure\\(mixed\\)\\: array\\<int, string\\>\\|string\\|false given\\.$#"
count: 1
path: src/Monolog/Utils.php

8 changes: 4 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -12,11 +12,11 @@
</testsuite>
</testsuites>

<filter>
<whitelist>
<coverage>
<include>
<directory suffix=".php">src/Monolog/</directory>
</whitelist>
</filter>
</include>
</coverage>

<php>
<ini name="date.timezone" value="UTC"/>
2 changes: 2 additions & 0 deletions src/Monolog/Formatter/ElasticaFormatter.php
Original file line number Diff line number Diff line change
@@ -34,6 +34,8 @@ class ElasticaFormatter extends NormalizerFormatter
/**
* @param string $index Elastic Search index name
* @param ?string $type Elastic Search document type, deprecated as of Elastica 7
*
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(string $index, ?string $type)
{
2 changes: 2 additions & 0 deletions src/Monolog/Formatter/ElasticsearchFormatter.php
Original file line number Diff line number Diff line change
@@ -34,6 +34,8 @@ class ElasticsearchFormatter extends NormalizerFormatter
/**
* @param string $index Elasticsearch index name
* @param string $type Elasticsearch record type
*
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(string $index, string $type)
{
1 change: 1 addition & 0 deletions src/Monolog/Formatter/FlowdockFormatter.php
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
* formats the record to be used in the FlowdockHandler
*
* @author Dominik Liebler <liebler.dominik@gmail.com>
* @deprecated Since 2.9.0 and 3.3.0, Flowdock was shutdown we will thus drop this handler in Monolog 4
*/
class FlowdockFormatter implements FormatterInterface
{
3 changes: 3 additions & 0 deletions src/Monolog/Formatter/FluentdFormatter.php
Original file line number Diff line number Diff line change
@@ -42,6 +42,9 @@ class FluentdFormatter implements FormatterInterface
*/
protected bool $levelTag = false;

/**
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(bool $levelTag = false)
{
if (!function_exists('json_encode')) {
11 changes: 3 additions & 8 deletions src/Monolog/Formatter/GelfMessageFormatter.php
Original file line number Diff line number Diff line change
@@ -63,6 +63,9 @@ private function getGraylog2Priority(Level $level): int
};
}

/**
* @throws \RuntimeException
*/
public function __construct(?string $systemName = null, ?string $extraPrefix = null, string $contextPrefix = 'ctxt_', ?int $maxLength = null)
{
if (!class_exists(Message::class)) {
@@ -110,14 +113,6 @@ public function format(LogRecord $record): Message
if (isset($record->channel)) {
$message->setAdditional('facility', $record->channel);
}
if (isset($extra['line'])) {
$message->setAdditional('line', $extra['line']);
unset($extra['line']);
}
if (isset($extra['file'])) {
$message->setAdditional('file', $extra['file']);
unset($extra['file']);
}

foreach ($extra as $key => $val) {
$val = is_scalar($val) || null === $val ? $val : $this->toJson($val);
3 changes: 2 additions & 1 deletion src/Monolog/Formatter/GoogleCloudLoggingFormatter.php
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
/**
* Encodes message information into JSON in a format compatible with Cloud logging.
*
* @see https://cloud.google.com/logging/docs/structured-logging
* @see https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry
*
* @author Luís Cobucci <lcobucci@gmail.com>
@@ -29,7 +30,7 @@ protected function normalizeRecord(LogRecord $record): array

// Re-key level for GCP logging
$normalized['severity'] = $normalized['level_name'];
$normalized['timestamp'] = $record->datetime->format(DateTimeInterface::RFC3339_EXTENDED);
$normalized['time'] = $record->datetime->format(DateTimeInterface::RFC3339_EXTENDED);

// Remove keys that are not used by GCP
unset($normalized['level'], $normalized['level_name'], $normalized['datetime']);
1 change: 1 addition & 0 deletions src/Monolog/Formatter/HtmlFormatter.php
Original file line number Diff line number Diff line change
@@ -43,6 +43,7 @@ protected function getLevelColor(Level $level): string

/**
* @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(?string $dateFormat = null)
{
2 changes: 2 additions & 0 deletions src/Monolog/Formatter/JsonFormatter.php
Original file line number Diff line number Diff line change
@@ -38,6 +38,8 @@ class JsonFormatter extends NormalizerFormatter

/**
* @param self::BATCH_MODE_* $batchMode
*
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(int $batchMode = self::BATCH_MODE_JSON, bool $appendNewline = true, bool $ignoreEmptyContextAndExtra = false, bool $includeStacktraces = false)
{
2 changes: 2 additions & 0 deletions src/Monolog/Formatter/LineFormatter.php
Original file line number Diff line number Diff line change
@@ -37,6 +37,8 @@ class LineFormatter extends NormalizerFormatter
* @param string|null $format The format of the message
* @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
* @param bool $allowInlineLineBreaks Whether to allow inline line breaks in log entries
*
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(?string $format = null, ?string $dateFormat = null, bool $allowInlineLineBreaks = false, bool $ignoreEmptyContextAndExtra = false, bool $includeStacktraces = false)
{
2 changes: 2 additions & 0 deletions src/Monolog/Formatter/LogstashFormatter.php
Original file line number Diff line number Diff line change
@@ -48,6 +48,8 @@ class LogstashFormatter extends NormalizerFormatter
* @param string|null $systemName The system/machine name, used as the "source" field of logstash, defaults to the hostname of the machine
* @param string $extraKey The key for extra keys inside logstash "fields", defaults to extra
* @param string $contextKey The key for context keys inside logstash "fields", defaults to context
*
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(string $applicationName, ?string $systemName = null, string $extraKey = 'extra', string $contextKey = 'context')
{
1 change: 1 addition & 0 deletions src/Monolog/Formatter/NormalizerFormatter.php
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ class NormalizerFormatter implements FormatterInterface

/**
* @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(?string $dateFormat = null)
{
2 changes: 2 additions & 0 deletions src/Monolog/Formatter/WildfireFormatter.php
Original file line number Diff line number Diff line change
@@ -25,6 +25,8 @@ class WildfireFormatter extends NormalizerFormatter
{
/**
* @param string|null $dateFormat The format of the timestamp: one supported by DateTime::format
*
* @throws \RuntimeException If the function json_encode does not exist
*/
public function __construct(?string $dateFormat = null)
{
15 changes: 8 additions & 7 deletions src/Monolog/Handler/AmqpHandler.php
Original file line number Diff line number Diff line change
@@ -139,13 +139,14 @@ protected function getRoutingKey(LogRecord $record): string

private function createAmqpMessage(string $data): AMQPMessage
{
return new AMQPMessage(
$data,
[
'delivery_mode' => 2,
'content_type' => 'application/json',
]
);
$attributes = [
'delivery_mode' => 2,
'content_type' => 'application/json',
];
if (\count($this->extraAttributes) > 0) {
$attributes = array_merge($attributes, $this->extraAttributes);
}
return new AMQPMessage($data, $attributes);
}

/**
Loading