mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-26 16:15:49 +03:00
[GH-ISSUE #812] Throw exception in StreamHandler upon constructing, not writing #312
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#312
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 @sander-bol on GitHub (Jun 29, 2016).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/812
Currently when using the StreamHandler with a non-writable file location, the exception indicating this is only thrown during the write() operation. During object construction the writability of the stream could already be verified, which would help in making logging a non-breaking aspect of the application. Making this a non-breaking issue currently requires us to wrap all writes in a Try-block.
@Seldaek commented on GitHub (Jul 2, 2016):
The problem then is that we always open the stream even though in most cases the request won't need to if you only log errors. I'd rather not change that, but you could pass in a resource instead of a stream url by doing the fopen() yourself and that way you catch the failure at instantiation time.
@Seldaek commented on GitHub (Jul 2, 2016):
Also alternatively note that you can use https://github.com/Seldaek/monolog/blob/master/src/Monolog/Handler/WhatFailureGroupHandler.php to wrap all your handlers if you want to make sure logging never throws.