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
59
59
60
60
$ hint = new EventHint ();
61
61
62
- if (isset ($ record ['context ' ][ ' exception ' ]) && $ record [ ' context ' ][ ' exception ' ] instanceof \Throwable ) {
62
+ if ($ this -> hasExceptionContext ($ record ['context ' ]) ) {
63
63
$ hint ->exception = $ record ['context ' ]['exception ' ];
64
64
}
65
65
@@ -94,18 +94,12 @@ private function getMonologContextData(array $context): array
94
94
return [];
95
95
}
96
96
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 ]);
106
100
}
107
101
108
- return $ contextData ;
102
+ return $ context ;
109
103
}
110
104
111
105
/**
@@ -127,4 +121,9 @@ private function getMonologExtraData(array $context): array
127
121
128
122
return $ extraData ;
129
123
}
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
+ }
130
129
}
You can’t perform that action at this time.
0 commit comments