@@ -33,14 +33,15 @@ public function logLazyLoading(string $interface, $service): void
33
33
$ debugMsg = 'Set service type ' . $ interface . ' instance by lazy load. ' ;
34
34
$ context = [
35
35
'typeName ' => $ interface ,
36
- 'instance ' => $ service
36
+ 'instance ' => $ this -> stringifyService ( $ service),
37
37
];
38
38
$ this ->logger ->debug ($ debugMsg , $ context );
39
39
}
40
40
41
41
public function logServiceRegistration ($ implementation , string $ interface ): void
42
42
{
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. ' ;
44
45
$ context = [
45
46
'interface ' => $ interface ,
46
47
'implementation ' => $ implementation ,
@@ -52,7 +53,7 @@ public function logNotMatchedTypeInstance(string $typeName, $instance): void
52
53
{
53
54
$ context = [
54
55
'typeName ' => $ typeName ,
55
- 'instance ' => $ instance
56
+ 'instance ' => $ this -> stringifyService ( $ instance)
56
57
];
57
58
$ this ->logger ->critical ('Given instance not belong to this type. Exception will be thrown. ' , $ context );
58
59
}
@@ -62,8 +63,8 @@ public function logServiceInstanceReplacing(string $typeName, $service, $previou
62
63
$ debugMsg = 'Replace service type ' . $ typeName . ' instance with another. ' ;
63
64
$ context = [
64
65
'typeName ' => $ typeName ,
65
- 'instance ' => $ service ,
66
- 'oldInstance ' => $ previousServiceInstance ,
66
+ 'instance ' => $ this -> stringifyService ( $ service) ,
67
+ 'oldInstance ' => $ this -> stringifyService ( $ previousServiceInstance) ,
67
68
];
68
69
$ this ->logger ->debug ($ debugMsg , $ context );
69
70
return [$ debugMsg , $ context ];
@@ -74,8 +75,8 @@ public function logRegisterServiceReplacing($implementation, string $interface,
74
75
$ msg = 'Replace registered service type ' . $ interface . ' with another. ' ;
75
76
$ context = [
76
77
'interface ' => $ interface ,
77
- 'newImplementation ' => $ implementation ,
78
- 'oldImplementation ' => $ oldImplementation ,
78
+ 'newImplementation ' => $ this -> stringifyService ( $ implementation) ,
79
+ 'oldImplementation ' => $ this -> stringifyService ( $ oldImplementation) ,
79
80
];
80
81
$ this ->logger ->debug ($ msg , $ context );
81
82
}
@@ -85,18 +86,19 @@ public function logServiceSetting(string $typeName, $service): void
85
86
$ debugMsg = 'Instance for service type ' . $ typeName . ' was set. ' ;
86
87
$ context = [
87
88
'typeName ' => $ typeName ,
88
- 'instance ' => $ service
89
+ 'instance ' => $ this -> stringifyService ( $ service),
89
90
];
90
91
$ this ->logger ->debug ($ debugMsg , $ context );
91
92
}
92
93
93
- private function stringifyImplementation ($ implementation ): string
94
+ private function stringifyService ($ implementation ): string
94
95
{
95
- // var_export does not handle circular references
96
- // handle this case
97
96
if ($ implementation instanceof CallableBeanContainer) {
98
97
$ implementation = 'user defined callable ' ;
98
+ } elseif (is_object ($ implementation )) {
99
+ $ implementation = get_class ($ implementation );
99
100
}
100
- return var_export ($ implementation , true );
101
+
102
+ return $ implementation ;
101
103
}
102
104
}
0 commit comments