Skip to content

Commit

Permalink
Add ability to forward logs to classes implementing ArrayAccess (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
rtripault authored and opengeek committed Sep 26, 2023
1 parent 743dba9 commit dd5b4fa
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/xPDO/xPDO.php
Original file line number Diff line number Diff line change
Expand Up @@ -2094,9 +2094,17 @@ protected function _log($level, $msg, $target= '', $def= '', $file= '', $line= '
$filename = isset($targetOptions['filename']) ? $targetOptions['filename'] : 'error.log';
$filepath = isset($targetOptions['filepath']) ? $targetOptions['filepath'] : $this->getCachePath() . Cache\xPDOCacheManager::LOG_DIR;
$this->cacheManager->writeFile($filepath . $filename, $content, 'a');
} elseif ($target=='ARRAY' && isset($targetOptions['var']) && is_array($targetOptions['var'])) {
} elseif (
$target === 'ARRAY' &&
isset($targetOptions['var']) &&
(is_array($targetOptions['var']) || $targetOptions['var'] instanceof \ArrayAccess)
) {
$targetOptions['var'][] = $content;
} elseif ($target=='ARRAY_EXTENDED' && isset($targetOptions['var']) && is_array($targetOptions['var'])) {
} elseif (
$target === 'ARRAY_EXTENDED' &&
isset($targetOptions['var']) &&
(is_array($targetOptions['var']) || $targetOptions['var'] instanceof \ArrayAccess)
) {
$targetOptions['var'][] = array(
'content' => $content,
'level' => $this->_getLogLevel($level),
Expand Down

0 comments on commit dd5b4fa

Please sign in to comment.