[PR #326] [MERGED] GELF: Allow for both the legacy and the updated official library #1080

Closed
opened 2026-03-04 03:04:50 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Seldaek/monolog/pull/326
Author: @bzikarsky
Created: 2/22/2014
Status: Merged
Merged: 2/23/2014
Merged by: @Seldaek

Base: masterHead: gelf-php-compat


📝 Commits (3)

  • c8289fd Updated GelfHandler/GelfFormatter
  • f0ed3d8 Allow for both mlehner/gelf-php and graylog2/gelf-php usage
  • b56ed7b Merge remote-tracking branch 'official/master' into gelf-php-compat

📊 Changes

5 files changed (+175 additions, -35 deletions)

View changed files

📝 composer.json (+2 -2)
📝 src/Monolog/Handler/GelfHandler.php (+19 -6)
📝 tests/Monolog/Formatter/GelfMessageFormatterTest.php (+8 -3)
tests/Monolog/Handler/GelfHandlerLegacyTest.php (+95 -0)
📝 tests/Monolog/Handler/GelfHandlerTest.php (+51 -24)

📄 Description

Since https://github.com/Seldaek/monolog/pull/287 would have broken BC, this PR allows to use both the legacy GELF library (mlehner/gelf-php) and the official new one (graylog2/gelf-php) with Monolog.

Changes:

  • Removed typehint in GelfHandler and replaced it with a runtime check for either IMessagePublisher or PublisherInterface
  • The GelfHandlerTest is quite dependent on the used GELF library. That's why I moved the tests for the legacy library to a separate file GeldHandlerLegacyTest
  • Introduced a feature-switch in GelfFormatterTest for an easy test with both libraries
  • composer.json now defaults to graylog2/gelf-php for suggestion and require-dev. I cannot think of a way to automatically test for both the legacy and current library (naming clashes). To verify legacy-compatibility, one must manually change to mlehner/gelf-php: ~1.0, and run composer update && phpunit. Better idea are very welcome!

This enables users to switch to the current gelf-library by changing their composer.json to graylog2/gelf-php and does not change anything for users unwilling or unable to change. It should be able to introduce this PR in the next minor version.

/cc @h4cc


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Seldaek/monolog/pull/326 **Author:** [@bzikarsky](https://github.com/bzikarsky) **Created:** 2/22/2014 **Status:** ✅ Merged **Merged:** 2/23/2014 **Merged by:** [@Seldaek](https://github.com/Seldaek) **Base:** `master` ← **Head:** `gelf-php-compat` --- ### 📝 Commits (3) - [`c8289fd`](https://github.com/Seldaek/monolog/commit/c8289fd65436fc63650ca62eaf9beb44d203f7b7) Updated GelfHandler/GelfFormatter - [`f0ed3d8`](https://github.com/Seldaek/monolog/commit/f0ed3d8054c8805eec6ad3a29d9e22386aa607e4) Allow for both mlehner/gelf-php and graylog2/gelf-php usage - [`b56ed7b`](https://github.com/Seldaek/monolog/commit/b56ed7b0fd4a6f1fb5f2e5bfd16a4060ae817c39) Merge remote-tracking branch 'official/master' into gelf-php-compat ### 📊 Changes **5 files changed** (+175 additions, -35 deletions) <details> <summary>View changed files</summary> 📝 `composer.json` (+2 -2) 📝 `src/Monolog/Handler/GelfHandler.php` (+19 -6) 📝 `tests/Monolog/Formatter/GelfMessageFormatterTest.php` (+8 -3) ➕ `tests/Monolog/Handler/GelfHandlerLegacyTest.php` (+95 -0) 📝 `tests/Monolog/Handler/GelfHandlerTest.php` (+51 -24) </details> ### 📄 Description Since https://github.com/Seldaek/monolog/pull/287 would have broken BC, this PR allows to use both the legacy GELF library (mlehner/gelf-php) and the official new one (graylog2/gelf-php) with Monolog. Changes: - Removed typehint in `GelfHandler` and replaced it with a runtime check for either `IMessagePublisher` or `PublisherInterface` - The `GelfHandlerTest` is quite dependent on the used GELF library. That's why I moved the tests for the legacy library to a separate file `GeldHandlerLegacyTest` - Introduced a feature-switch in `GelfFormatterTest` for an easy test with both libraries - `composer.json` now defaults to `graylog2/gelf-php` for suggestion and require-dev. I cannot think of a way to automatically test for both the legacy and current library (naming clashes). To verify legacy-compatibility, one must manually change to `mlehner/gelf-php: ~1.0`, and run `composer update && phpunit`. Better idea are very welcome! This enables users to switch to the current gelf-library by changing their `composer.json` to `graylog2/gelf-php` and does not change anything for users unwilling or unable to change. It should be able to introduce this PR in the next minor version. /cc @h4cc --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-04 03:04:50 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#1080
No description provided.