Fix type casting of string scopes to array in log engines

This commit is contained in:
ADmad 2013-02-13 00:10:32 +05:30
parent 0d9ef854ff
commit f6215129f6
2 changed files with 16 additions and 2 deletions

View file

@ -57,8 +57,10 @@ abstract class BaseLog implements CakeLogInterface {
*/ */
public function config($config = array()) { public function config($config = array()) {
if (!empty($config)) { if (!empty($config)) {
if (isset($config['types']) && is_string($config['types'])) { foreach (array('types', 'scopes') as $option) {
$config['types'] = array($config['types']); if (isset($config[$option]) && is_string($config[$option])) {
$config[$option] = array($config[$option]);
}
} }
$this->_config = $config; $this->_config = $config;
} }

View file

@ -424,6 +424,18 @@ class CakeLogTest extends CakeTestCase {
public function testScopedLogging() { public function testScopedLogging() {
$this->_resetLogConfig(); $this->_resetLogConfig();
$this->_deleteLogs(); $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( CakeLog::config('shops', array(
'engine' => 'FileLog', 'engine' => 'FileLog',
'types' => array('info', 'notice', 'warning'), 'types' => array('info', 'notice', 'warning'),