mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-26 16:15:49 +03:00
[GH-ISSUE #1922] Override the source attribute in v3? #825
Labels
No labels
Bug
Documentation
Feature
Needs Work
Support
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/monolog#825
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @hcker2000 on GitHub (Nov 6, 2024).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1922
Monolog v3
We used to be able to use a source processor to override the source and host options but can no longer do this. This was required as the default source and host options inside docker are useless for logging across multiple servers as they all have the same ip and host name.
Here is the old processor code:
How can we do this same thing with v3?
@stof commented on GitHub (Nov 6, 2024):
which source and host options are you talking about ? there is no such options in Monolog.
@hcker2000 commented on GitHub (Nov 6, 2024):
All I know is that the code above works with 2.7.0 and will not work with the latest changes. When I switch the $record parameter to have to be an instance of the
\Monolog\LogRecordclass you can no longer set a source and host that gets json encoded at the top level of the object like{source: "mythinghere", host:"myhosthere"}My guess is that maybe the were not part of monolog but that inside that method it would allow me to add them to all my requests in a single place.
I need to be able to add those as properties at the top level of the object thats sent.
Is there any way to continue to do this?
@Seldaek commented on GitHub (Nov 9, 2024):
You'd need to write those in context or ideally extra data from the Processor, then use a custom formatter that moves the extra data into top level keys (or even just use a formatter to set the keys and skip the processor entirely).
For v3 since records are objects you cannot write arbitrary data on them.
@hcker2000 commented on GitHub (Nov 12, 2024):
Thanks the custom formatter does the trick.