Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix type casting of string scopes to array in log engines
  • Loading branch information
ADmad committed Feb 12, 2013
1 parent 0d9ef85 commit f621512
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/Cake/Log/Engine/BaseLog.php
Expand Up @@ -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;
}
Expand Down
12 changes: 12 additions & 0 deletions lib/Cake/Test/Case/Log/CakeLogTest.php
Expand Up @@ -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'),
Expand Down

0 comments on commit f621512

Please sign in to comment.