From 5184788658432427bf02dea8882d5a14a097ec5a Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Thu, 29 Jan 2015 17:27:18 +0000 Subject: [PATCH] logger : remove the dependency for PHP 5.6 by using standard functions instead of ... for Variable-length argument lists git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1969 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- logger.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/logger.php b/logger.php index 321b4d0..489cb33 100644 --- a/logger.php +++ b/logger.php @@ -55,10 +55,11 @@ class logger /** Store a new message log in the log manager defined by $logtype The message can be multiple types. An array will be stored in textual form - but it will accept only one depth. + but it will accept only one depth. + The $message is not fixed, you can pass the number of parameters you want @param integer|null $priority Priority to use @param mixed ...$message Message to log */ - public function log ($priority=LOG_NOTICE, ...$message) + public function log ($priority=LOG_NOTICE, $message) { if ($this->loglevelmin < $priority) return; @@ -71,8 +72,12 @@ class logger $msg .= "[".$_SERVER["REMOTE_ADDR"]."] "; } + // The messages are all the parameters of the function except the first, + // which is the priority + $messages = func_get_args (); + array_shift ($messages); // Convert each part of message to text - foreach ($message as $m) + foreach ($messages as $m) { if (is_array ($m)) {