From 9f6816d3b1f5999e44a38b874c38a6e92d03c6f6 Mon Sep 17 00:00:00 2001 From: Julien Rosset Date: Fri, 9 Jun 2023 12:48:48 +0200 Subject: [PATCH] Add test --- composer.json | 17 +++++++++--- src/ExtendedMonolog/LogDirectoryHandler.php | 9 ++++++- tests/logs/.gitignore | 2 ++ tests/test.php | 29 +++++++++++++++++++++ 4 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 tests/logs/.gitignore create mode 100644 tests/test.php diff --git a/composer.json b/composer.json index 82a745d..395d962 100644 --- a/composer.json +++ b/composer.json @@ -2,18 +2,29 @@ "name": "jrosset/extendedmonolog", "description": "Some extensions for Monolog", "keywords": [ ], + "type": "library", + + "config": { + "sort-packages": true + }, + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, "minimum-stability": "stable", - "require": { + "require": { "php": "^7.4 || ^8.0", "jrosset/exceptionhelper": "^1.0", "jrosset/lasterrorexception": "^1.0", "monolog/monolog": "^2.9" }, "autoload": { - "psr-4": { + "psr-4": { "jrosset\\": "src/" - } + }, + "exclude-from-classmap": [ "tests/" ] }, "readme": "README.md", diff --git a/src/ExtendedMonolog/LogDirectoryHandler.php b/src/ExtendedMonolog/LogDirectoryHandler.php index 974028b..30edb78 100644 --- a/src/ExtendedMonolog/LogDirectoryHandler.php +++ b/src/ExtendedMonolog/LogDirectoryHandler.php @@ -29,7 +29,14 @@ class LogDirectoryHandler extends StreamHandler { * * @throws Throwable If an error occurs */ - public function __construct (string $dirPath, $level = Logger::DEBUG, int $historyNumberOfDays = 30, bool $bubble = true, ?int $filePermission = null, bool $useLocking = false) { + public function __construct ( + string $dirPath, + $level = Logger::DEBUG, + int $historyNumberOfDays = 30, + bool $bubble = true, + ?int $filePermission = null, + bool $useLocking = false + ) { $dirPath = $dirPath . DIRECTORY_SEPARATOR; $this->normalizeDirectory($dirPath, $historyNumberOfDays); diff --git a/tests/logs/.gitignore b/tests/logs/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/tests/logs/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/tests/test.php b/tests/test.php new file mode 100644 index 0000000..b8c08c6 --- /dev/null +++ b/tests/test.php @@ -0,0 +1,29 @@ +info('START'); + + throw new RuntimeException('An unexpected error occurs'); + + /** @noinspection PhpUnreachableStatementInspection */ + $logger->info('END'); +} +catch (Throwable $exception) { + $logger->exception(Logger::ERROR, $exception); +} \ No newline at end of file