diff --git a/Log/FileLogger.php b/Log/FileLogger.php index 4f63acd67..9a09921bd 100644 --- a/Log/FileLogger.php +++ b/Log/FileLogger.php @@ -82,6 +82,8 @@ class FileLogger implements LoggerInterface */ private $path = ''; + private $created = false; + /** * Object constructor. * @@ -103,14 +105,22 @@ class FileLogger implements LoggerInterface } if (is_dir($lpath) || strpos($lpath, '.') === false) { - File::create($path = $path . '/' . date('Y-m-d') . '.log'); + $path = $path . '/' . date('Y-m-d') . '.log'; } else { - File::create($path = $lpath); + $path = $lpath; } $this->path = $path; } + private function createFile() + { + if (!file_exists($this->path) && !$this->created) { + File::create($this->path); + $this->created = true; + } + } + /** * Returns instance. * @@ -284,6 +294,7 @@ class FileLogger implements LoggerInterface */ private function write(string $message) { + $this->createFile(); $this->fp = fopen($this->path, 'a'); if ($this->fp !== false) {