From f6215129f6a2220ff767a987535a685f788ac112 Mon Sep 17 00:00:00 2001 From: ADmad Date: Wed, 13 Feb 2013 00:10:32 +0530 Subject: [PATCH] Fix type casting of string scopes to array in log engines --- lib/Cake/Log/Engine/BaseLog.php | 6 ++++-- lib/Cake/Test/Case/Log/CakeLogTest.php | 12 ++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Log/Engine/BaseLog.php b/lib/Cake/Log/Engine/BaseLog.php index 891df2a48c0..8187656bb0b 100644 --- a/lib/Cake/Log/Engine/BaseLog.php +++ b/lib/Cake/Log/Engine/BaseLog.php @@ -57,8 +57,10 @@ public function __construct($config = array()) { */ public function config($config = array()) { if (!empty($config)) { - if (isset($config['types']) && is_string($config['types'])) { - $config['types'] = array($config['types']); + foreach (array('types', 'scopes') as $option) { + if (isset($config[$option]) && is_string($config[$option])) { + $config[$option] = array($config[$option]); + } } $this->_config = $config; } diff --git a/lib/Cake/Test/Case/Log/CakeLogTest.php b/lib/Cake/Test/Case/Log/CakeLogTest.php index 3ebc75efc94..127974d1be1 100644 --- a/lib/Cake/Test/Case/Log/CakeLogTest.php +++ b/lib/Cake/Test/Case/Log/CakeLogTest.php @@ -424,6 +424,18 @@ public function testScopedLoggingExclusive() { public function testScopedLogging() { $this->_resetLogConfig(); $this->_deleteLogs(); + + CakeLog::config('string-scope', array( + 'engine' => 'FileLog', + 'types' => array('info', 'notice', 'warning'), + 'scopes' => 'string-scope', + 'file' => 'string-scope.log' + )); + CakeLog::write('info', 'info message', 'string-scope'); + $this->assertTrue(file_exists(LOGS . 'string-scope.log')); + + CakeLog::drop('string-scope'); + CakeLog::config('shops', array( 'engine' => 'FileLog', 'types' => array('info', 'notice', 'warning'),