Log :: exception(): clean extra args declaration

This commit is contained in:
Benjamin Renard 2023-01-29 19:18:52 +01:00
parent 27af166466
commit f8fa2f9204

View file

@ -302,15 +302,16 @@ class Log {
* @param Throwable $exception * @param Throwable $exception
* @param string|null $prefix The prefix of the log message * @param string|null $prefix The prefix of the log message
* (optional, default: "An exception occured") * (optional, default: "An exception occured")
* @param array $extra_args Extra arguments to use to compute prefix using sprintf
* @return void * @return void
*/ */
public static function exception($exception, $prefix=null) { public static function exception($exception, $prefix=null, ...$extra_args) {
SentryIntegration :: log($exception); SentryIntegration :: log($exception);
// If more than 2 arguments passed, format prefix message using sprintf // If extra arguments passed, format prefix message using sprintf
if ($prefix && func_num_args() > 2) { if ($prefix && $extra_args) {
$prefix = call_user_func_array( $prefix = call_user_func_array(
'sprintf', 'sprintf',
array_merge(array($prefix), array_slice(func_get_args(), 2)) array_merge(array($prefix), $extra_args)
); );
} }
self :: error( self :: error(