File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
src/Symfony/Bridge/Monolog/Handler Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -116,10 +116,23 @@ private function sendToElasticsearch(array $records)
116116
117117 $ this ->responses ->attach ($ response );
118118
119- foreach ($ this ->client ->stream ($ this ->responses , 0 ) as $ response => $ chunk ) {
120- if (!$ chunk ->isTimeout () && $ chunk ->isFirst ()) {
121- $ this ->responses ->detach ($ response );
119+ try {
120+ foreach ($ this ->client ->stream ($ this ->responses , 0 ) as $ response => $ chunk ) {
121+ if (!$ chunk ->isTimeout () && $ chunk ->isFirst ()) {
122+ $ this ->responses ->detach ($ response );
123+ }
122124 }
125+ } catch (\Throwable $ e ) {
126+ error_log (sprintf ('Could not push logs to elasticsearch: %s ' , (string ) $ e ));
127+ }
128+ }
129+
130+ public function __destruct ()
131+ {
132+ try {
133+ unset($ this ->responses );
134+ } catch (\Throwable $ e ) {
135+ error_log (sprintf ('Could not push logs to elasticsearch: %s ' , (string ) $ e ));
123136 }
124137 }
125138}
You can’t perform that action at this time.
0 commit comments