public function store(string $level, string $message, string $context)
{
$now = new \DateTime('now');
$filename = $now->format($this->fileFormat);
\touch($this->basedir . DIRECTORY_SEPARATOR . $filename);
$file = \realpath($this->basedir . DIRECTORY_SEPARATOR . $filename);
if ($file === false) {
throw new FileNotFound(\trk('errors.file.cannot_write_file'));
}
if (\strpos($file, $this->basedir) === false) {
throw new FileAccessDenied(\trk('errors.file.lfi'));
}
if (!\file_exists($file)) {
\touch($file);
\chmod($file, 0770);
}
$time = $now->format($this->timeFormat);
return \file_put_contents($file, $time . "\t" . \preg_replace('#[^a-z]*#', '', $level) . "\t" . \json_encode($message) . "\t" . $context . "\n", FILE_APPEND);
}