diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 190b4da..7ad749b 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -18,6 +18,7 @@ jobs: - "8.1" - "8.2" - "8.3" + - "8.4" steps: - name: Checkout diff --git a/.laminas-ci.json b/.laminas-ci.json index 82cd446..29216fa 100644 --- a/.laminas-ci.json +++ b/.laminas-ci.json @@ -1,6 +1,3 @@ { - "ignore_php_platform_requirements": { - "8.4": true - }, "backwardCompatibilityCheck": true } diff --git a/README.md b/README.md index 2ef25fa..6fe050d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # dot-log ![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-log) -![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-log/4.1.0) +![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-log/4.1.1) [![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-log)](https://github.com/dotkernel/dot-log/issues) [![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-log)](https://github.com/dotkernel/dot-log/network) diff --git a/composer.json b/composer.json index f9a8f45..c205fe4 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "require-dev": { "laminas/laminas-coding-standard": "^3.0", "phpunit/phpunit": "^10.2", - "vimeo/psalm": "^5.13" + "vimeo/psalm": "^6.0" }, "autoload": { "psr-4": { diff --git a/docs/book/v3/adding-config-provider.md b/docs/book/v3/adding-config-provider.md index e591844..d8e57ca 100644 --- a/docs/book/v3/adding-config-provider.md +++ b/docs/book/v3/adding-config-provider.md @@ -1,10 +1,11 @@ -# Adding The Config Provider +# Adding the ConfigProvider * In `config/config.php` add an entry for the config provider `\Dot\Log\ConfigProvider::class` - * Make sure it is added before with the Application-Specific components, eg.: + * Make sure it is added before with the Application-Specific components, e.g.: * `\Frontend\App\ConfigProvider.php` * `\Admin\App\ConfigProvider::class` * `\MyProject\ConfigProvider::class` etc. * Add the logger configuration in an autoload config file, e.g. you can create `config/autoload/logger.global.php`. Follow the `Configuring the writer(s)` chapter for a simple working example. -Note: `Dot\Log\ConfigProvider` has an abstract factory `LoggerAbstractServiceFactory::class` which corresponds to the alias, not the class name. Instead of requesting `Laminas\Log\Logger::class` from the container, use `dot-log.my_logger` (or just `my_logger` if using laminas-log). +> `Dot\Log\ConfigProvider` has an abstract factory `LoggerAbstractServiceFactory::class` which corresponds to the alias, not the class name. +> Instead of requesting `Laminas\Log\Logger::class` from the container, use `dot-log.my_logger` (or just `my_logger` if using laminas-log). diff --git a/docs/book/v3/configuring-writer.md b/docs/book/v3/configuring-writer.md index a9ed716..bde085e 100644 --- a/docs/book/v3/configuring-writer.md +++ b/docs/book/v3/configuring-writer.md @@ -2,13 +2,15 @@ Loggers must have at least one writer. -A writer is an object that inherits from `Laminas\Log\Writer\AbstractWriter`. A writer's responsibility is to record log data to a storage backend. (from laminas-log's writer documentation) +A writer is an object that inherits from `Laminas\Log\Writer\AbstractWriter`. +A writer's responsibility is to record log data to a storage backend. (from laminas-log's writer documentation). ## Writing to a file (stream) -You can separate logs into multiple files using writers and filters. For example *warnings.log*, *errors.log*, *all_messages.log*. +You can separate logs into multiple files using writers and filters. +For example *warnings.log*, *errors.log*, *all_messages.log*. -The following is the simplest example to write all log messages to `/log/dk.log` +The following is the simplest example to write all log messages to `/log/dk.log`: ```php return [ @@ -33,7 +35,8 @@ return [ * The `FileWriter` key is optional, otherwise the writers array would be enumerative instead of associative. * The `name` key is a developer-provided name for that writer, the writer name key is **mandatory**. -The `priority` key does not affect the errors that are written. It is a way to organize writers, for example: +The `priority` key does not affect the errors that are written. +It is a way to organize writers, for example: * 1 - FILE * 2 - SQL diff --git a/docs/book/v3/filtering-log-messages.md b/docs/book/v3/filtering-log-messages.md index 32c185f..5bb2112 100644 --- a/docs/book/v3/filtering-log-messages.md +++ b/docs/book/v3/filtering-log-messages.md @@ -90,7 +90,7 @@ return [ As in the writer configuration, the developer can optionally use keys for associating the filters with a name. -IMPORTANT NOTE: the operator for more important messages is `<=`, this is because the number representation is smaller for a more important message type. +> The operator for more important messages is `<=`, this is because the number representation is smaller for a more important message type. The filter added on the first writer is equivalent to not setting a filter, but it was added to illustrate the usage of the operator to explicitly allow all messages. diff --git a/docs/book/v3/formatting-messages.md b/docs/book/v3/formatting-messages.md index d995e0c..9d25ca4 100644 --- a/docs/book/v3/formatting-messages.md +++ b/docs/book/v3/formatting-messages.md @@ -1,6 +1,9 @@ # Formatting Messages -When using `dot-log` or `laminas-log`, the logged value is not limited to a string. Arrays can be logged as well. For better readability, these arrays can be serialized. Laminas Log provides String, XML, JSON and FirePHP formatting. +When using `dot-log` or `laminas-log`, the logged value is not limited to a string. +Arrays can be logged as well. +For better readability, these arrays can be serialized. +Laminas Log provides String, XML, JSON and FirePHP formatting. The formatter accepts following parameters: diff --git a/docs/book/v3/grouping-log-files-by-date.md b/docs/book/v3/grouping-log-files-by-date.md index 7437b4e..71c072a 100644 --- a/docs/book/v3/grouping-log-files-by-date.md +++ b/docs/book/v3/grouping-log-files-by-date.md @@ -9,4 +9,4 @@ Examples: * `log/dk-{Y}-{m}-{d}.log` will create a new log file each day (eg: log/dk-2021-01-01.log) * `log/dk-{Y}-{W}.log` will create a new log file each week (eg: log/dk-2021-10.log) -The full list of format specifiers is available [here](https://www.php.net/manual/en/datetime.format.php). +The full list of format specifiers is available in the [PHP docs for datetime formatting](https://www.php.net/manual/en/datetime.format.php). diff --git a/docs/book/v4/adding-config-provider.md b/docs/book/v4/adding-config-provider.md index 2e3ef2b..98abb06 100644 --- a/docs/book/v4/adding-config-provider.md +++ b/docs/book/v4/adding-config-provider.md @@ -7,4 +7,5 @@ * `\MyProject\ConfigProvider::class` etc. * Add the logger configuration in an autoload config file, e.g. you can create `config/autoload/logger.global.php`. Follow the `Configuring the writer(s)` chapter for a simple working example. -Note: `Dot\Log\ConfigProvider` has an abstract factory `LoggerAbstractServiceFactory::class` which corresponds to the alias, not the class name. Instead of requesting `Dot\Log\Logger::class` from the container, use `dot-log.my_logger`. +> `Dot\Log\ConfigProvider` has an abstract factory `LoggerAbstractServiceFactory::class` which corresponds to the alias, not the class name. +> Instead of requesting `Dot\Log\Logger::class` from the container, use `dot-log.my_logger`. diff --git a/docs/book/v4/configuring-writer.md b/docs/book/v4/configuring-writer.md index cf4b9a3..3b37d02 100644 --- a/docs/book/v4/configuring-writer.md +++ b/docs/book/v4/configuring-writer.md @@ -2,13 +2,15 @@ Loggers must have at least one writer. -A writer is an object that inherits from `Dot\Log\Writer\AbstractWriter`. A writer's responsibility is to record log data to a storage backend. +A writer is an object that inherits from `Dot\Log\Writer\AbstractWriter`. +A writer's responsibility is to record log data to a storage backend. ## Writing to a file (stream) -You can separate logs into multiple files using writers and filters. For example *warnings.log*, *errors.log*, *all_messages.log*. +You can separate logs into multiple files using writers and filters. +For example *warnings.log*, *errors.log*, *all_messages.log*. -The following is the simplest example to write all log messages to `/log/dk.log` +The following is the simplest example to write all log messages to `/log/dk.log`: ```php return [ @@ -33,7 +35,8 @@ return [ * The `FileWriter` key is optional, otherwise the writers array would be enumerative instead of associative. * The `name` key is a developer-provided name for that writer, the writer name key is **mandatory**. -The `priority` key does not affect the errors that are written. It is a way to organize writers. +The `priority` key does not affect the errors that are written. +It is a way to organize writers. The `priority` key is optional. diff --git a/docs/book/v4/filtering-log-messages.md b/docs/book/v4/filtering-log-messages.md index 914edf4..0276bf2 100644 --- a/docs/book/v4/filtering-log-messages.md +++ b/docs/book/v4/filtering-log-messages.md @@ -90,6 +90,6 @@ return [ As in the writer configuration, the developer can optionally use keys for associating the filters with a name. -IMPORTANT NOTE: the operator for more important messages is `<=`, this is because the number representation is smaller for a more important message type. +> The operator for more important messages is `<=`, this is because the number representation is smaller for a more important message type. The filter added on the first writer is equivalent to not setting a filter, but it was added to illustrate the usage of the operator to explicitly allow all messages. diff --git a/docs/book/v4/formatting-messages.md b/docs/book/v4/formatting-messages.md index 5d1c4bb..4b2771c 100644 --- a/docs/book/v4/formatting-messages.md +++ b/docs/book/v4/formatting-messages.md @@ -1,6 +1,9 @@ # Formatting Messages -When using `dot-log`, the logged value is not limited to a string. Arrays can be logged as well. For better readability, these arrays can be serialized. Dot Log provides String and JSON formatting. +When using `dot-log`, the logged value is not limited to a string. +Arrays can be logged as well. +For better readability, these arrays can be serialized. +DotLog provides String and JSON formatting. The formatter accepts following parameters: diff --git a/docs/book/v4/grouping-log-files-by-date.md b/docs/book/v4/grouping-log-files-by-date.md index 7437b4e..71c072a 100644 --- a/docs/book/v4/grouping-log-files-by-date.md +++ b/docs/book/v4/grouping-log-files-by-date.md @@ -9,4 +9,4 @@ Examples: * `log/dk-{Y}-{m}-{d}.log` will create a new log file each day (eg: log/dk-2021-01-01.log) * `log/dk-{Y}-{W}.log` will create a new log file each week (eg: log/dk-2021-10.log) -The full list of format specifiers is available [here](https://www.php.net/manual/en/datetime.format.php). +The full list of format specifiers is available in the [PHP docs for datetime formatting](https://www.php.net/manual/en/datetime.format.php). diff --git a/src/Formatter/Json.php b/src/Formatter/Json.php index 8afb4b1..9713567 100644 --- a/src/Formatter/Json.php +++ b/src/Formatter/Json.php @@ -33,7 +33,7 @@ public function format(iterable $event): string $event['timestamp'] = $event['timestamp']->format($this->getDateTimeFormat()); } - return json_encode( + return (string) json_encode( $event, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK | JSON_PRESERVE_ZERO_FRACTION );