File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ protected function doWrite($record): void
5959
6060 $ hint = new EventHint ();
6161
62- if (isset ($ record ['context ' ][ ' exception ' ]) && $ record [ ' context ' ][ ' exception ' ] instanceof \Throwable ) {
62+ if ($ this -> hasExceptionContext ($ record ['context ' ]) ) {
6363 $ hint ->exception = $ record ['context ' ]['exception ' ];
6464 }
6565
@@ -94,18 +94,12 @@ private function getMonologContextData(array $context): array
9494 return [];
9595 }
9696
97- $ contextData = [];
98-
99- foreach ($ context as $ key => $ value ) {
100- // We skip the `exception` field because it goes in its own context
101- if ($ key === self ::CONTEXT_EXCEPTION_KEY ) {
102- continue ;
103- }
104-
105- $ contextData [$ key ] = $ value ;
97+ if ($ this ->hasExceptionContext ($ context )) {
98+ // remove the exception from the context, as it's set on the hint
99+ unset($ context [self ::CONTEXT_EXCEPTION_KEY ]);
106100 }
107101
108- return $ contextData ;
102+ return $ context ;
109103 }
110104
111105 /**
@@ -127,4 +121,9 @@ private function getMonologExtraData(array $context): array
127121
128122 return $ extraData ;
129123 }
124+
125+ private function hasExceptionContext (array $ context ): bool
126+ {
127+ return isset ($ context [self ::CONTEXT_EXCEPTION_KEY ]) && $ context [self ::CONTEXT_EXCEPTION_KEY ] instanceof \Throwable;
128+ }
130129}
You can’t perform that action at this time.
0 commit comments