mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-26 16:15:49 +03:00
[PR #402] [CLOSED] Added microsecond support for JSON serialized DateTime objects #1128
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#1128
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?
📋 Pull Request Information
Original PR: https://github.com/Seldaek/monolog/pull/402
Author: @holtkamp
Created: 7/31/2014
Status: ❌ Closed
Base:
master← Head:microsecond-support-for-json-serialized-datetimes📝 Commits (4)
a193537Added microsecond support for JSON serialized DateTime objectsce7a8b6Removed need to override createFromFormat()737b328Merge remote-tracking branch 'upstream/master' into microsecond-support-for-json-serialized-datetimes6347b4dBumped PHP version to 5.4, which supports JsonSerializable📊 Changes
3 files changed (+54 additions, -2 deletions)
View changed files
📝
composer.json(+1 -1)➕
src/Monolog/DateTime.php(+35 -0)📝
src/Monolog/Logger.php(+18 -1)📄 Description
When using the JsonFormatter, all records are encoded using json_encode(). For the timestamp this would mean that a DateTime object results in something like:
This way we 'loose' the ability to format the timestamp with microsecond precision. A way to avoid this loss of detail is to extend the native DateTime class with one that implements JsonSerializable which appends the microseconds.
Note that due to https://bugs.php.net/bug.php?id=60302, this means we can no longer use DateTime::createFromFormat(), so I isolated it in a private function.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.