Airship\Engine\LedgerStorage\FileStore::store PHP Method

store() public method

Store a log message -- used by Ledger
public store ( string $level, string $message, string $context ) : mixed
$level string
$message string
$context string (JSON encoded)
return mixed
    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);
    }