Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- "8.1"
- "8.2"
- "8.3"
- "8.4"

steps:
- name: Checkout
Expand Down
3 changes: 0 additions & 3 deletions .laminas-ci.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"ignore_php_platform_requirements": {
"8.4": true
},
"backwardCompatibilityCheck": true
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
7 changes: 4 additions & 3 deletions docs/book/v3/adding-config-provider.md
Original file line number Diff line number Diff line change
@@ -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).
11 changes: 7 additions & 4 deletions docs/book/v3/configuring-writer.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/book/v3/filtering-log-messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
5 changes: 4 additions & 1 deletion docs/book/v3/formatting-messages.md
Original file line number Diff line number Diff line change
@@ -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:

Expand Down
2 changes: 1 addition & 1 deletion docs/book/v3/grouping-log-files-by-date.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
3 changes: 2 additions & 1 deletion docs/book/v4/adding-config-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
11 changes: 7 additions & 4 deletions docs/book/v4/configuring-writer.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand All @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion docs/book/v4/filtering-log-messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
5 changes: 4 additions & 1 deletion docs/book/v4/formatting-messages.md
Original file line number Diff line number Diff line change
@@ -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:

Expand Down
2 changes: 1 addition & 1 deletion docs/book/v4/grouping-log-files-by-date.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
2 changes: 1 addition & 1 deletion src/Formatter/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down