10 use Monolog\Formatter\LineFormatter;
11 use Monolog\Handler\StreamHandler;
14 class Base extends StreamHandler
43 $this->fileName = $this->sanitizeFileName(
$fileName);
46 $filePath ? $filePath . $this->fileName :
BP . DIRECTORY_SEPARATOR . $this->fileName,
50 $this->setFormatter(
new LineFormatter(
null,
null,
true));
59 private function sanitizeFileName(
$fileName)
62 throw new \InvalidArgumentException(
'Filename expected to be a string');
66 $parts = array_filter($parts,
function (
$value) {
67 return !in_array(
$value, [
'',
'.',
'..']);
70 return implode(
'/', $parts);
80 public function write(array $record)
82 $logDir = $this->filesystem->getParentDirectory($this->url);
83 if (!$this->filesystem->isDirectory($logDir)) {
84 $this->filesystem->createDirectory($logDir);
87 parent::write($record);
__construct(DriverInterface $filesystem, $filePath=null, $fileName=null)