get('defaultPermissions'); $this->fileManager = new FileManager($defaultPermissions); } protected function write(array $record): void { if (!$this->url) { throw new RuntimeException( "Missing a logger file path. Check logger params in config." ); } try { if (!is_writable($this->url)) { $checkFileResult = $this->fileManager->checkCreateFile($this->url); if (!$checkFileResult) { return; } } $this->fileManager->appendContents( $this->url, $this->pruneMessage($record) ); } catch (Throwable $e) { $msg = "Could not write file `" . $this->url . "`."; if ($e->getMessage()) { $msg .= " Error message: " . $e->getMessage(); } throw new RuntimeException($msg); } } protected function pruneMessage(array $record) { $message = (string) $record['message']; if (strlen($message) > $this->maxErrorMessageLength) { $record['message'] = substr($message, 0, $this->maxErrorMessageLength) . '...'; $record['formatted'] = $this->getFormatter()->format($record); } return (string) $record['formatted']; } }