tombstone
tombstone copied to clipboard
Unable to determine stream size. Did you forget to close or flush the stream?
I am getting Unable to determine stream size. Did you forget to close or flush the stream? when i am use S3 as storage with streamwrapper. Can you suggest me how to resolve this issue.
Writing data to S3 seems to have specific requirements. The logging implementation is very similar to what Monolog is doing and I believe Monolog doesn't support S3 out-of-the-box.
I've found this article on StackOverflow, describing that you need to do some client initialization first. Maybe that helps.
Yeah. Same way i did client initialization like this
private function configureS3LogStorage(): void
{
$client = new S3Client([
'region' => 'us-west-2',
"version" => '2006-03-01',
"credentials"=> [
"key" => 'some key',
"secret" => 'some secret'
]
]);
$client->registerStreamWrapper();
}
Before build graveyard, i call this function to initialize client with stream wrapper of s3 storage.
Did you write your own log handler or are you using the standard one that comes with the library? If you're using the battery standard one I'd suggest you try it with a custom one specifically for the S3 use case.
I'm using AnalyzerLogHandler which uses the inbuild StreamHandler . So I just register client and before build graveyard and it was working but concern is that whenever use concurrency of calls it throws.
Unable to determine stream size. Did you forget to close or flush the stream?
I did understand this, but I also don't have an idea where this is coming from. My guess is that something in the way the standard StreamHandler workes is incompatible with the S3 protocol. Therefore my suggestion, to implement a custom handler specifically for S3.
Can i have any sample contract to write custom handler and it would be helpful for me.
Have a look at these classes: https://github.com/scheb/tombstone/tree/1.x/src/logger/Handler
Is it possible to add fflush to flush file output buffer in stream handler because since flush method declared but not implemented in stream handler.
Sorry, I don't understand what you mean.
I wouldn't want to touch the StreamHandler so much as this would potentially break other people's implementations. My recommendation is to implement a custom handler that fits your needs.