File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -97,13 +97,27 @@ public function setFactoryName(string $factoryName)
9797 */
9898 public function canLog ($ exception ): bool
9999 {
100- if (in_array (get_class ($ exception ), $ this ->exceptions ) && !in_array (get_class ($ exception ), $ this ->ignored )){
100+ if ((in_array (get_class ($ exception ), $ this ->exceptions ) ||
101+ $ this ->checkInstanceInList ($ exception , $ this ->exceptions )) &&
102+ !in_array (get_class ($ exception ), $ this ->ignored ) &&
103+ !$ this ->checkInstanceInList ($ exception , $ this ->ignored )){
101104 return true ;
102105 }
103106
104107 return false ;
105108 }
106109
110+ private function checkInstanceInList ($ exceptionToCheck , array $ exceptions ): bool
111+ {
112+ foreach ($ exceptions as $ exception ) {
113+ if ($ exceptionToCheck instanceof $ exception ){
114+ return true ;
115+ }
116+ }
117+
118+ return false ;
119+ }
120+
107121
108122
109123}
Original file line number Diff line number Diff line change 66use Exception ;
77use Zend \EventManager \EventManagerInterface ;
88use Zend \EventManager \AbstractListenerAggregate ;
9+ use Zend \Http \Request ;
910use Zend \Mvc \ErrorLogger \Logger \Resolver ;
1011use Zend \Mvc \MvcEvent ;
1112use Zend \Log \Logger ;
@@ -90,9 +91,20 @@ private function handleError(MvcEvent $event): MvcEvent
9091
9192 foreach ($ errorLogging ->getLoggers () as $ logger ) {
9293 if ($ logger ->canLog ($ exception )) {
94+ /** @var Request $request */
95+ $ request = $ event ->getRequest ();
96+
97+
9398 /** @var Logger $loggerInstance */
9499 $ loggerInstance = $ serviceManager ->get ($ logger ->getClassName ());
95- $ loggerInstance ->info ($ exception ->getMessage ());
100+ $ loggerInstance ->err (
101+ $ exception ->getMessage (),[
102+ 'trace ' => $ exception ->getTrace (),
103+ 'file ' => $ exception ->getFile (),
104+ 'line ' => $ exception ->getLine (),
105+ 'code ' => $ exception ->getCode (),
106+ 'request ' => $ request ->toString () . json_encode ($ request ->getPost ())
107+ ]);
96108 }
97109 }
98110 }
You can’t perform that action at this time.
0 commit comments