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 Sep 26, 2023
1 parent 4544d16 commit 25ed9e0
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 @@ -2099,9 +2099,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 25ed9e0

Please sign in to comment.