logger/errorhandling

Errorhandling extension for PSR-3 compatible loggers

0.2 2021-08-07 21:40 UTC

This package is auto-updated.

Last update: 2024-12-08 04:35:24 UTC


README

Scrutinizer Code Quality Build Status Latest Stable Version License

Errorhandling extension for PSR-3 compatible loggers

Why should I care?

CoreErrorHandlers helps you getting every type of problem in your logging-channels.

How does it work?

CoreErrorHandlers uses most of PHP's capabilities to capture notices, warnings, errors, exceptions and even fatal errors in most situations and redirect them to user-defined PSR-3 compatible logging channels.

Typically you would end up having something like this:

use Logger\CoreErrorHandlers;
// ...
CoreErrorHandlers::enableExceptionsForErrors();
CoreErrorHandlers::registerAssertionHandler($logger, LogLevel::DEBUG);
CoreErrorHandlers::registerExceptionHandler($logger);
CoreErrorHandlers::registerFatalErrorHandler($logger);

This will register trigger-callback-functions for asserts, exceptions and fatal errors. It also registers exception-handlers for every notice, warning and error.

Note: You need to run the registration-process on every run. Yes, I think you already got it, but just in case: Any problems only get caught if the registration was already made at the time the problem occurs.