mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-27 00:25:50 +03:00
[GH-ISSUE #1274] Cannot write to sftp file #525
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#525
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 @troccoli on GitHub (Jan 2, 2019).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1274
I am trying to use the StreamHandler with an sftp resource.
My code looks like this
However, it seems that the
fwritefails silently. It doesn't returnfalsenor any number of bytes written. To be clear, the following debugging code does not output anythingNow, interestingly, if I try to write something in the constructor, e.g.
I've got my
testingstring in the file.@troccoli commented on GitHub (Jan 3, 2019):
Apparently the issue is that the stream is somehow closed, even if I store it in a protected property.
I have refactored the handler as follows and it works.
However, it's not really great coding.
Since, as I said, I believe
$streamis somehow closed prematurely, or in any case using it again does not work, I have to open a new stream every time. And I cannot refactor the opening of the stream in its own method as I would have the same problem, i.e. the stream is close prematurely. Besides, I need to change the opening mode, fromwtoa, although this may be because of an issue with the sftp server (which is not under my control, so I cannot know for sure).For the time being I keep this code. If anyone has any suggestions on how to make it better please comment on this issue.
@Seldaek commented on GitHub (Jun 30, 2019):
Sorry but no idea about sftp/ssh2 in PHP so can't really help, doesn't look like this is directly something Monolog as a project can do so I will close this.