forked from dotkernel/dot-errorhandler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request dotkernel#37 from dotkernel/issue-36
Issue dotkernel#36: Upgraded `dot-log` to `4.x`. Prepare package for version `4.x`.
- Loading branch information
Showing
11 changed files
with
111 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Configuration | ||
|
||
Register `dot-errorhandler` in you project by adding `Dot\ErrorHandler\ConfigProvider::class` to your configuration aggregator (to `config/config.php` for example), | ||
and add `\Dot\ErrorHandler\ErrorHandlerInterface::class` (to `config/pipeline.php` for example) **as the outermost layer of the middleware** to catch all Exceptions | ||
|
||
- Configure the error handler as shown below | ||
|
||
config/autoload/error-handling.global.php | ||
|
||
```php | ||
<?php | ||
|
||
use Dot\ErrorHandler\ErrorHandlerInterface; | ||
use Dot\ErrorHandler\LogErrorHandler; | ||
use Dot\ErrorHandler\ErrorHandler; | ||
|
||
return [ | ||
'dependencies' => [ | ||
'aliases' => [ | ||
ErrorHandlerInterface::class => LogErrorHandler::class, | ||
] | ||
|
||
], | ||
'dot-errorhandler' => [ | ||
'loggerEnabled' => true, | ||
'logger' => 'dot-log.default_logger' | ||
] | ||
]; | ||
``` | ||
|
||
A configuration example for the default logger can be found in `config/log.global.php.dist`. | ||
|
||
When declaring the `ErrorHandlerInterface` alias you can choose whether to log or not: | ||
|
||
- for the simple Zend Expressive handler user `ErrorHandler` | ||
- for logging use `LogErrorHandler` | ||
|
||
The class `Dot\ErrorHandler\ErrorHandler` is the same as the Zend Expressive error handling class | ||
the only difference being the removal of the `final` statement for making extension possible. | ||
|
||
The class `Dot\ErrorHandler\LogErrorHandler` is `Dot\ErrorHandler\ErrorHandler` with | ||
added logging support. | ||
|
||
As a note: both `LogErrorHandler` and `ErrorHandler` have factories declared in the | ||
package's `ConfigProvider`. If you need a custom ErrorHandler it must have a factory | ||
declared in the config, as in the example. | ||
|
||
Example: | ||
|
||
```php | ||
<?php | ||
|
||
use Dot\ErrorHandler\ErrorHandlerInterface; | ||
use Custom\MyErrorHandler; | ||
use Custom\MyErrorHandlerFactory; | ||
|
||
|
||
return [ | ||
'dependencies' => [ | ||
'factories' => [ | ||
MyErrorHandler::class => MyCustomHandlerFactory::class, | ||
], | ||
|
||
'aliases' => [ | ||
ErrorHandlerInterface::class => MyErrorHandler::class, | ||
] | ||
|
||
], | ||
'dot-errorhandler' => [ | ||
'loggerEnabled' => true, | ||
'logger' => 'dot-log.default_logger' | ||
] | ||
]; | ||
``` | ||
|
||
Config examples can be found in this project's `config` directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Installation | ||
|
||
Install `dotkernel/dot-errorhandler` by executing the following Composer command: | ||
|
||
composer require dotkernel/dot-errorhandler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Overview | ||
|
||
`dot-errorhandler` is DotKernel's logging error handler, providing two options: | ||
|
||
- `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 | ||
- `Dot\ErrorHandler\LogErrorHandler` adds logging support to the default `ErrorHandler` class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters