Bug fix if no file logging is required

This commit is contained in:
Dennis Eichhorn 2016-10-16 22:42:20 +02:00
parent 4640872d7e
commit 34ffc44353

View File

@ -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) {