Skip to content

Commit

Permalink
chore: update fs to v2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Nov 10, 2024
1 parent 7bd1985 commit cd87e9b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"leafs/fs": "^1.3",
"leafs/fs": "^2.0",
"leafs/date": "*"
}
}
14 changes: 9 additions & 5 deletions src/LogWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
},
);
}
}

0 comments on commit cd87e9b

Please sign in to comment.