Skip to content

Commit 0c46abe

Browse files
authored
Merge pull request #37 from dotkernel/issue-36
Issue #36: Upgraded `dot-log` to `4.x`. Prepare package for version `4.x`.
2 parents 48e8c89 + a0929b9 commit 0c46abe

File tree

11 files changed

+111
-25
lines changed

11 files changed

+111
-25
lines changed

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# dot-errorhandler
22

3-
Logging Error Handler for DotKernel
3+
Error Logging Handler for DotKernel
44

55
![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-errorhandler)
6-
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-errorhandler/3.3.2)
6+
![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-errorhandler/4.0.0)
77

88
[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-errorhandler)](https://github.com/dotkernel/dot-errorhandler/issues)
99
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-errorhandler)](https://github.com/dotkernel/dot-errorhandler/network)
1010
[![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-errorhandler)](https://github.com/dotkernel/dot-errorhandler/stargazers)
1111
[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-errorhandler)](https://github.com/dotkernel/dot-errorhandler/blob/3.0/LICENSE)
1212

13-
[![Build Static](https://github.com/dotkernel/dot-errorhandler/actions/workflows/static-analysis.yml/badge.svg?branch=3.0)](https://github.com/dotkernel/dot-errorhandler/actions/workflows/static-analysis.yml)
14-
[![codecov](https://codecov.io/gh/dotkernel/dot-errorhandler/branch/3.0/graph/badge.svg?token=0KIJARS5RS)](https://codecov.io/gh/dotkernel/dot-errorhandler)
13+
[![Build Static](https://github.com/dotkernel/dot-errorhandler/actions/workflows/continuous-integration.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/dot-errorhandler/actions/workflows/continuous-integration.yml)
14+
[![codecov](https://codecov.io/gh/dotkernel/dot-errorhandler/branch/4.0/graph/badge.svg?token=0KIJARS5RS)](https://codecov.io/gh/dotkernel/dot-errorhandler)
1515

1616
[![SymfonyInsight](https://insight.symfony.com/projects/cf1f8d89-f230-4157-bc8b-7cce20c75454/big.svg)](https://insight.symfony.com/projects/cf1f8d89-f230-4157-bc8b-7cce20c75454)
1717

@@ -78,7 +78,6 @@ use Dot\ErrorHandler\ErrorHandlerInterface;
7878
use Custom\MyErrorHandler;
7979
use Custom\MyErrorHandlerFactory;
8080

81-
8281
return [
8382
'dependencies' => [
8483
'factories' => [

SECURITY.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
## Supported Versions
44

5-
6-
| Version | Supported | PHP Version |
7-
|---------|--------------------|-----------------------------------------------------------------------------------------------------------------------|
5+
| Version | Supported | PHP Version |
6+
|---------|--------------------|------------------------------------------------------------------------------------------------------------------|
7+
| 4.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-errorhandler/4.0.0) |
88
| 3.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-errorhandler/3.3.2) |
9-
| <= 2.x | :x: | |
10-
9+
| <= 2.x | :x: | |
1110

1211
## Reporting Potential Security Issues
1312

@@ -27,7 +26,6 @@ release prior to any public exposure; this helps protect the project's
2726
users, and provides them with a chance to upgrade and/or update in order to
2827
protect their applications.
2928

30-
3129
## Policy
3230

3331
If we verify a reported security vulnerability, our policy is:

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"require": {
2929
"php": "~8.2.0 || ~8.3.0",
30-
"dotkernel/dot-log": "^3.4",
30+
"dotkernel/dot-log": "^4.0.2",
3131
"laminas/laminas-diactoros": "^3.3",
3232
"laminas/laminas-stratigility": "^3.11",
3333
"mezzio/mezzio": "^3.19",

config/log.global.php.dist

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
<?php
22

3-
use Laminas\Log\Formatter\Json;
4-
use Laminas\Log\Logger;
5-
63
return [
74
'dot_log' => [
85
'loggers' => [
96
'default_logger' => [
107
'writers' => [
118
'FileWriter' => [
129
'name' => 'stream',
13-
'priority' => Logger::ALERT,
10+
'priority' => \Dot\Log\Logger::ALERT,
1411
'options' => [
1512
'stream' => __DIR__ . '/../../log/error-log-{Y}-{m}-{d}.log',
1613
// explicitly log all messages
@@ -19,12 +16,12 @@ return [
1916
'name' => 'priority',
2017
'options' => [
2118
'operator' => '>=',
22-
'priority' => Logger::EMERG,
19+
'priority' => \Dot\Log\Logger::EMERG,
2320
],
2421
],
2522
],
2623
'formatter' => [
27-
'name' => Json::class,
24+
'name' => \Dot\Log\Formatter\Json::class,
2825
],
2926
],
3027
],

docs/book/v4/configuration.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Configuration
2+
3+
Register `dot-errorhandler` in you project by adding `Dot\ErrorHandler\ConfigProvider::class` to your configuration aggregator (to `config/config.php` for example),
4+
and add `\Dot\ErrorHandler\ErrorHandlerInterface::class` (to `config/pipeline.php` for example) **as the outermost layer of the middleware** to catch all Exceptions
5+
6+
- Configure the error handler as shown below
7+
8+
config/autoload/error-handling.global.php
9+
10+
```php
11+
<?php
12+
13+
use Dot\ErrorHandler\ErrorHandlerInterface;
14+
use Dot\ErrorHandler\LogErrorHandler;
15+
use Dot\ErrorHandler\ErrorHandler;
16+
17+
return [
18+
'dependencies' => [
19+
'aliases' => [
20+
ErrorHandlerInterface::class => LogErrorHandler::class,
21+
]
22+
23+
],
24+
'dot-errorhandler' => [
25+
'loggerEnabled' => true,
26+
'logger' => 'dot-log.default_logger'
27+
]
28+
];
29+
```
30+
31+
A configuration example for the default logger can be found in `config/log.global.php.dist`.
32+
33+
When declaring the `ErrorHandlerInterface` alias you can choose whether to log or not:
34+
35+
- for the simple Zend Expressive handler user `ErrorHandler`
36+
- for logging use `LogErrorHandler`
37+
38+
The class `Dot\ErrorHandler\ErrorHandler` is the same as the Zend Expressive error handling class
39+
the only difference being the removal of the `final` statement for making extension possible.
40+
41+
The class `Dot\ErrorHandler\LogErrorHandler` is `Dot\ErrorHandler\ErrorHandler` with
42+
added logging support.
43+
44+
As a note: both `LogErrorHandler` and `ErrorHandler` have factories declared in the
45+
package's `ConfigProvider`. If you need a custom ErrorHandler it must have a factory
46+
declared in the config, as in the example.
47+
48+
Example:
49+
50+
```php
51+
<?php
52+
53+
use Dot\ErrorHandler\ErrorHandlerInterface;
54+
use Custom\MyErrorHandler;
55+
use Custom\MyErrorHandlerFactory;
56+
57+
58+
return [
59+
'dependencies' => [
60+
'factories' => [
61+
MyErrorHandler::class => MyCustomHandlerFactory::class,
62+
],
63+
64+
'aliases' => [
65+
ErrorHandlerInterface::class => MyErrorHandler::class,
66+
]
67+
68+
],
69+
'dot-errorhandler' => [
70+
'loggerEnabled' => true,
71+
'logger' => 'dot-log.default_logger'
72+
]
73+
];
74+
```
75+
76+
Config examples can be found in this project's `config` directory.

docs/book/v4/installation.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Installation
2+
3+
Install `dotkernel/dot-errorhandler` by executing the following Composer command:
4+
5+
composer require dotkernel/dot-errorhandler

docs/book/v4/overview.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Overview
2+
3+
`dot-errorhandler` is DotKernel's logging error handler, providing two options:
4+
5+
- `Dot\ErrorHandler\ErrorHandler`, same as the Zend Expressive error handling class with the only difference being the removal of the `final` statement for making extension possible
6+
- `Dot\ErrorHandler\LogErrorHandler` adds logging support to the default `ErrorHandler` class

mkdocs.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@ docs_dir: docs/book
22
site_dir: docs/html
33
extra:
44
project: Packages
5-
current_version: v3
5+
current_version: v4
66
versions:
7+
- v4
78
- v3
89
nav:
910
- Home: index.md
11+
- v4:
12+
- Overview: v4/overview.md
13+
- Installation: v4/installation.md
14+
- Configuration: v4/configuration.md
1015
- v3:
1116
- Overview: v3/overview.md
1217
- Installation: v3/installation.md
1318
- Configuration: v3/configuration.md
1419
site_name: dot-errorhandler
15-
site_description: "DotKernel's logging error handler"
20+
site_description: "DotKernel's error logging handler"
1621
repo_url: "https://github.com/dotkernel/dot-errorhandler"
1722
plugins:
1823
- search

src/LogErrorHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace Dot\ErrorHandler;
66

7+
use Dot\Log\LoggerInterface;
78
use ErrorException;
8-
use Laminas\Log\LoggerInterface;
99
use Laminas\Stratigility\Middleware\ErrorResponseGenerator;
1010
use Psr\Http\Message\ResponseInterface;
1111
use Psr\Http\Message\ServerRequestInterface;

src/LogErrorHandlerFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace Dot\ErrorHandler;
66

7+
use Dot\Log\LoggerInterface;
78
use InvalidArgumentException;
8-
use Laminas\Log\LoggerInterface;
99
use Mezzio\Middleware\ErrorResponseGenerator;
1010
use Psr\Container\ContainerExceptionInterface;
1111
use Psr\Container\ContainerInterface;

0 commit comments

Comments
 (0)