Skip to content

Commit 25ed9e0

Browse files
authored
Add ability to forward logs to classes implementing ArrayAccess (#233)
1 parent 4544d16 commit 25ed9e0

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
@@ -2099,9 +2099,17 @@ protected function _log($level, $msg, $target= '', $def= '', $file= '', $line= '
20992099
$filename = isset($targetOptions['filename']) ? $targetOptions['filename'] : 'error.log';
21002100
$filepath = isset($targetOptions['filepath']) ? $targetOptions['filepath'] : $this->getCachePath() . Cache\xPDOCacheManager::LOG_DIR;
21012101
$this->cacheManager->writeFile($filepath . $filename, $content, 'a');
2102-
} elseif ($target=='ARRAY' && isset($targetOptions['var']) && is_array($targetOptions['var'])) {
2102+
} elseif (
2103+
$target === 'ARRAY' &&
2104+
isset($targetOptions['var']) &&
2105+
(is_array($targetOptions['var']) || $targetOptions['var'] instanceof \ArrayAccess)
2106+
) {
21032107
$targetOptions['var'][] = $content;
2104-
} elseif ($target=='ARRAY_EXTENDED' && isset($targetOptions['var']) && is_array($targetOptions['var'])) {
2108+
} elseif (
2109+
$target === 'ARRAY_EXTENDED' &&
2110+
isset($targetOptions['var']) &&
2111+
(is_array($targetOptions['var']) || $targetOptions['var'] instanceof \ArrayAccess)
2112+
) {
21052113
$targetOptions['var'][] = array(
21062114
'content' => $content,
21072115
'level' => $this->_getLogLevel($level),

0 commit comments

Comments
 (0)