File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change 55use Buffer \BuffLog \Bufflog ;
66
77// putenv("LOG_VERBOSITY=WARNING");
8- BuffLog::debug ("I am a debug " );
8+ BuffLog::debug ("I am a debug string " );
99BuffLog::debug ("I am a debug with context " , ["my key " => " my value " ]);
1010
1111BuffLog::info ("I am an info " );
Original file line number Diff line number Diff line change @@ -110,15 +110,40 @@ public static function __callStatic($methodName, $args)
110110 if (in_array ($ methodName , array_merge (self ::$ logOutputMethods , self ::$ extraAllowedMethods ))) {
111111
112112 if (in_array ($ methodName , self ::$ logOutputMethods )) {
113- // Where the magic happen. We "proxy" functions name with arguments to the Monolog instance
114- return call_user_func_array (array (self ::getLogger (), $ methodName ), $ args );
113+
114+ if (self ::checkLogParametersType ($ args )) {
115+ // Where the magic happen. We "proxy" functions name with arguments to the Monolog instance
116+ return call_user_func_array (array (self ::getLogger (), $ methodName ), $ args );
117+ }
115118 }
116119 } else {
117120 error_log ("BuffLog:: $ methodName() is not supported yet. Add it to the BuffLog whitelist to allow it " );
118121 }
119122 } else {
120123 error_log ("BuffLog:: $ methodName() method does not exist " );
121124 }
125+
126+ return false ;
127+ }
128+
129+ private static function checkLogParametersType ($ args )
130+ {
131+ if (count ($ args ) > 2 ) {
132+ error_log ("BuffLog: Too many parameters " );
133+ return false ;
134+ }
135+
136+ if (isset ($ args [0 ]) && !is_string ($ args [0 ])) {
137+ error_log ("BuffLog: First parameter must be a string " );
138+ return false ;
139+ }
140+
141+ if (isset ($ args [1 ]) && !is_array ($ args [1 ])) {
142+ error_log ("BuffLog: Second parameter must be an array " );
143+ return false ;
144+ }
145+
146+ return true ;
122147 }
123148
124149}
You can’t perform that action at this time.
0 commit comments