From 9d8c84d6cd8d429ce7aed3007a268a4be02cf7be Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 17 Feb 2011 03:16:20 +0100 Subject: [PATCH] Fix constructor handling of arrays --- src/Monolog/Log.php | 2 +- src/Monolog/Logger.php | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Monolog/Log.php b/src/Monolog/Log.php index 049e971f..d06a5b9f 100644 --- a/src/Monolog/Log.php +++ b/src/Monolog/Log.php @@ -23,7 +23,7 @@ class Log { $this->name = $name; $this->level = $level; - $this->writers = (array) $writers; + $this->writers = is_array($writers) ? $writers : array($writers); } public function getName() diff --git a/src/Monolog/Logger.php b/src/Monolog/Logger.php index 3236656e..38fcb90f 100644 --- a/src/Monolog/Logger.php +++ b/src/Monolog/Logger.php @@ -31,7 +31,13 @@ class Logger public function __construct($logs = array()) { - $this->logs = (array) $logs; + $this->logs = array(); + if (!is_array($logs)) { + $logs = array($logs); + } + foreach ($logs as $log) { + $this->logs[$log->getName()] = $log; + } } public function addLog(Log $log)