@@ -33,14 +33,15 @@ public function logLazyLoading(string $interface, $service): void
3333 $ debugMsg = 'Set service type ' . $ interface . ' instance by lazy load. ' ;
3434 $ context = [
3535 'typeName ' => $ interface ,
36- 'instance ' => $ service
36+ 'instance ' => $ this -> stringifyService ( $ service),
3737 ];
3838 $ this ->logger ->debug ($ debugMsg , $ context );
3939 }
4040
4141 public function logServiceRegistration ($ implementation , string $ interface ): void
4242 {
43- $ msg = 'Service with type ' . $ interface . ' and implementation ' . $ this ->stringifyImplementation ($ implementation ) . ' register. ' ;
43+ $ implementation = $ this ->stringifyService ($ implementation );
44+ $ msg = 'Service with type ' . $ interface . ' and implementation ' . $ implementation . ' register. ' ;
4445 $ context = [
4546 'interface ' => $ interface ,
4647 'implementation ' => $ implementation ,
@@ -52,7 +53,7 @@ public function logNotMatchedTypeInstance(string $typeName, $instance): void
5253 {
5354 $ context = [
5455 'typeName ' => $ typeName ,
55- 'instance ' => $ instance
56+ 'instance ' => $ this -> stringifyService ( $ instance)
5657 ];
5758 $ this ->logger ->critical ('Given instance not belong to this type. Exception will be thrown. ' , $ context );
5859 }
@@ -62,8 +63,8 @@ public function logServiceInstanceReplacing(string $typeName, $service, $previou
6263 $ debugMsg = 'Replace service type ' . $ typeName . ' instance with another. ' ;
6364 $ context = [
6465 'typeName ' => $ typeName ,
65- 'instance ' => $ service ,
66- 'oldInstance ' => $ previousServiceInstance ,
66+ 'instance ' => $ this -> stringifyService ( $ service) ,
67+ 'oldInstance ' => $ this -> stringifyService ( $ previousServiceInstance) ,
6768 ];
6869 $ this ->logger ->debug ($ debugMsg , $ context );
6970 return [$ debugMsg , $ context ];
@@ -74,8 +75,8 @@ public function logRegisterServiceReplacing($implementation, string $interface,
7475 $ msg = 'Replace registered service type ' . $ interface . ' with another. ' ;
7576 $ context = [
7677 'interface ' => $ interface ,
77- 'newImplementation ' => $ implementation ,
78- 'oldImplementation ' => $ oldImplementation ,
78+ 'newImplementation ' => $ this -> stringifyService ( $ implementation) ,
79+ 'oldImplementation ' => $ this -> stringifyService ( $ oldImplementation) ,
7980 ];
8081 $ this ->logger ->debug ($ msg , $ context );
8182 }
@@ -85,18 +86,19 @@ public function logServiceSetting(string $typeName, $service): void
8586 $ debugMsg = 'Instance for service type ' . $ typeName . ' was set. ' ;
8687 $ context = [
8788 'typeName ' => $ typeName ,
88- 'instance ' => $ service
89+ 'instance ' => $ this -> stringifyService ( $ service),
8990 ];
9091 $ this ->logger ->debug ($ debugMsg , $ context );
9192 }
9293
93- private function stringifyImplementation ($ implementation ): string
94+ private function stringifyService ($ implementation ): string
9495 {
95- // var_export does not handle circular references
96- // handle this case
9796 if ($ implementation instanceof CallableBeanContainer) {
9897 $ implementation = 'user defined callable ' ;
98+ } elseif (is_object ($ implementation )) {
99+ $ implementation = get_class ($ implementation );
99100 }
100- return var_export ($ implementation , true );
101+
102+ return (string ) $ implementation ;
101103 }
102104}
0 commit comments