<?php
namespace Engine\Logger; class DbEmulated extends \Engine\Logger\File { protected $fileHandle = null; protected $fullFilePath = null; protected $messageIndex = 0; public function __construct() { parent::__construct(); $CFG = \Engine\Loader_Cfg::getInstance()->getGlobal(); $this->directory = realpath($CFG['logger']['pathToRoot'])."/DbEmulated/"; } protected function getRealFullFilepath($level, $logSession) { $fullFilePath = $this->directory.$logSession; clearstatcache(); if (!\Engine\Dir::check($this->directory)) { \Engine\Dir::create($this->directory); } return $fullFilePath; } public function writeRawMessage($fields) { if ($fields['stacktrace']) { foreach ($fields['stacktrace'] as $k=>$trace) { $fields['stacktrace'][$k]['args'] = []; } } $this->fullFilePath = $this->getRealFullFilepath($fields['level'], $fields['logSession']); file_put_contents(sprintf('%s %06d%s', $this->fullFilePath, $this->messageIndex++, ".ser.log"), serialize($fields)); return true; } } 