diff --git a/composer.json b/composer.json index f20e23b..394af59 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "leafs/fs": "^1.3", + "leafs/fs": "^2.0", "leafs/date": "*" } } diff --git a/src/LogWriter.php b/src/LogWriter.php index 678882e..ea0a169 100755 --- a/src/LogWriter.php +++ b/src/LogWriter.php @@ -25,7 +25,7 @@ public function __construct(string $file, bool $createFile = false) { if (!file_exists($file)) { if ($createFile) { - FS::createFile($file); + FS\File::create($file); } else { trigger_error(basename($file) . " not found in " . dirname($file), E_USER_ERROR); } @@ -60,17 +60,21 @@ public function write($message, $level = null) protected function writeAsLeaf($message, $level) { - FS::prepend( + FS\File::write( $this->logFile, - (string) "[" . (new \Leaf\Date())->tick()->now() . "]\n" . $level . "$message\n" + function ($content) use ($message, $level) { + return "[" . (new \Leaf\Date())->tick()->now() . "]\n" . $level . "$message\n\n" . $content; + }, ); } protected function writeAsLinux($message, $level) { - FS::append( + FS\File::write( $this->logFile, - (string) "[" . (new \Leaf\Date())->tick()->now() . "] " . $level . "$message\n" + function ($content) use ($message, $level) { + return "[" . (new \Leaf\Date())->tick()->now() . "] " . $level . "$message\n\n" . $content; + }, ); } }