Skip to content

Commit dd5b4fa

Browse files
rtripaultopengeek
authored andcommitted
Add ability to forward logs to classes implementing ArrayAccess (#233)
1 parent 743dba9 commit dd5b4fa

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/xPDO/xPDO.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,9 +2094,17 @@ protected function _log($level, $msg, $target= '', $def= '', $file= '', $line= '
20942094
$filename = isset($targetOptions['filename']) ? $targetOptions['filename'] : 'error.log';
20952095
$filepath = isset($targetOptions['filepath']) ? $targetOptions['filepath'] : $this->getCachePath() . Cache\xPDOCacheManager::LOG_DIR;
20962096
$this->cacheManager->writeFile($filepath . $filename, $content, 'a');
2097-
} elseif ($target=='ARRAY' && isset($targetOptions['var']) && is_array($targetOptions['var'])) {
2097+
} elseif (
2098+
$target === 'ARRAY' &&
2099+
isset($targetOptions['var']) &&
2100+
(is_array($targetOptions['var']) || $targetOptions['var'] instanceof \ArrayAccess)
2101+
) {
20982102
$targetOptions['var'][] = $content;
2099-
} elseif ($target=='ARRAY_EXTENDED' && isset($targetOptions['var']) && is_array($targetOptions['var'])) {
2103+
} elseif (
2104+
$target === 'ARRAY_EXTENDED' &&
2105+
isset($targetOptions['var']) &&
2106+
(is_array($targetOptions['var']) || $targetOptions['var'] instanceof \ArrayAccess)
2107+
) {
21002108
$targetOptions['var'][] = array(
21012109
'content' => $content,
21022110
'level' => $this->_getLogLevel($level),

0 commit comments

Comments
 (0)