diff --git a/Interfaces/LoggerAwareInterface.php b/Interfaces/LoggerAwareInterface.php deleted file mode 100755 index 8ea8734..0000000 --- a/Interfaces/LoggerAwareInterface.php +++ /dev/null @@ -1,18 +0,0 @@ -=8.0", - "maplephp/http": "^1.0" + "name": "maplephp/log", + "type": "library", + "description": "PHP PSR-3 Logger library, standardized approach to logging messages.", + "keywords": [ + "PSR-3", + "log", + "logger", + "filesystem", + "error log" + ], + "homepage": "https://wazabii.se", + "license": "Apache-2.0", + "authors": [ + { + "name": "Daniel Ronkainen", + "email": "daniel.ronkainen@wazabii.se" }, - "autoload": { - "psr-4": { - "MaplePHP\\Log\\": "" - } - }, - "minimum-stability": "dev" + { + "name": "MaplePHP", + "homepage": "https://wazabii.se" + } + ], + "require": { + "php": ">=8.2", + "psr/log": "^3.0", + "maplephp/http": "^2.0" + }, + "autoload": { + "psr-4": { + "MaplePHP\\Log\\": "src" + } + }, + "minimum-stability": "dev" } \ No newline at end of file diff --git a/AbstractLogger.php b/src/AbstractLogger.php similarity index 90% rename from AbstractLogger.php rename to src/AbstractLogger.php index 2c6af20..d74b3b4 100755 --- a/AbstractLogger.php +++ b/src/AbstractLogger.php @@ -2,7 +2,7 @@ namespace MaplePHP\Log; -use MaplePHP\Log\Interfaces\LoggerInterface; +use Psr\Log\LoggerInterface; /** * This is a simple Logger implementation that other Loggers can inherit from. diff --git a/Handlers/AbstractHandler.php b/src/Handlers/AbstractHandler.php similarity index 100% rename from Handlers/AbstractHandler.php rename to src/Handlers/AbstractHandler.php diff --git a/Handlers/DBHandler.php b/src/Handlers/DBHandler.php similarity index 100% rename from Handlers/DBHandler.php rename to src/Handlers/DBHandler.php diff --git a/Handlers/ErrorLogHandler.php b/src/Handlers/ErrorLogHandler.php similarity index 96% rename from Handlers/ErrorLogHandler.php rename to src/Handlers/ErrorLogHandler.php index a3a6d6f..a1fde95 100755 --- a/Handlers/ErrorLogHandler.php +++ b/src/Handlers/ErrorLogHandler.php @@ -7,7 +7,7 @@ class ErrorLogHandler extends AbstractHandler public function __construct(?string $file = null) { ini_set("log_errors", "1"); - if (!is_null($file)) { + if ($file !== null) { ini_set("error_log", $file); } } diff --git a/Handlers/StreamHandler.php b/src/Handlers/StreamHandler.php similarity index 89% rename from Handlers/StreamHandler.php rename to src/Handlers/StreamHandler.php index ec0c195..f300bea 100755 --- a/Handlers/StreamHandler.php +++ b/src/Handlers/StreamHandler.php @@ -2,8 +2,8 @@ namespace MaplePHP\Log\Handlers; -use MaplePHP\Http\Interfaces\StreamInterface; use MaplePHP\Http\Stream; +use Psr\Http\Message\StreamInterface; class StreamHandler extends AbstractHandler { @@ -21,7 +21,7 @@ public function __construct(string $file, ?int $size = null, ?int $count = null) { $this->file = basename($file); $this->dir = dirname($file) . "/"; - $this->size = !is_null($size) ? ($size * 1024) : $size; + $this->size = $size !== null ? ($size * 1024) : $size; $this->count = $count; } @@ -49,7 +49,7 @@ public function handler(string $level, string $message, array $context, string $ */ protected function stream(): StreamInterface { - if (is_null($this->stream)) { + if ($this->stream === null) { if (!is_writable($this->dir)) { throw new \Exception("The directory \"{$this->dir}\" is not writable!", 1); } @@ -64,7 +64,7 @@ protected function stream(): StreamInterface */ protected function rotate(): void { - if (!is_null($this->size)) { + if ($this->size !== null) { $file = $this->dir . $this->file; $filename = $this->fileInfo("filename"); $extension = $this->fileInfo("extension"); @@ -74,7 +74,7 @@ protected function rotate(): void $count = count($files); sort($files); - if (!is_null($this->count) && ($count >= $this->count)) { + if ($this->count !== null && ($count >= $this->count)) { for ($i = 0; $i < (($count - $this->count) + 1); $i++) { unlink($files[$i]); } @@ -92,7 +92,7 @@ protected function rotate(): void */ private function fileInfo(string $key): ?string { - if (is_null($this->info)) { + if ($this->info === null) { $this->info = pathinfo($this->file); } return ($this->info[$key] ?? null); diff --git a/Interfaces/HandlerInterface.php b/src/Interfaces/HandlerInterface.php similarity index 100% rename from Interfaces/HandlerInterface.php rename to src/Interfaces/HandlerInterface.php diff --git a/InvalidArgumentException.php b/src/InvalidArgumentException.php similarity index 100% rename from InvalidArgumentException.php rename to src/InvalidArgumentException.php diff --git a/LogLevel.php b/src/LogLevel.php similarity index 100% rename from LogLevel.php rename to src/LogLevel.php diff --git a/Logger.php b/src/Logger.php similarity index 97% rename from Logger.php rename to src/Logger.php index a797b50..bac3a14 100755 --- a/Logger.php +++ b/src/Logger.php @@ -69,7 +69,7 @@ public function getContext(): array */ protected function getDate(): string { - if (is_null($this->dateTime)) { + if ($this->dateTime === null) { $this->dateTime = new \DateTime("now"); } return $this->dateTime->format(static::DATETIME_FORMAT); diff --git a/LoggerAwareTrait.php b/src/LoggerAwareTrait.php similarity index 90% rename from LoggerAwareTrait.php rename to src/LoggerAwareTrait.php index d08bc7e..1023eee 100755 --- a/LoggerAwareTrait.php +++ b/src/LoggerAwareTrait.php @@ -2,7 +2,7 @@ namespace MaplePHP\Log; -use MaplePHP\Log\Interfaces\LoggerInterface; +use Psr\Log\LoggerInterface; /** * Basic Implementation of LoggerAwareInterface. diff --git a/LoggerTrait.php b/src/LoggerTrait.php similarity index 100% rename from LoggerTrait.php rename to src/LoggerTrait.php diff --git a/NullLogger.php b/src/NullLogger.php similarity index 100% rename from NullLogger.php rename to src/NullLogger.php