Comments (5)
Whoops can easily be integrated with a logger, using a custom handler. Here's a pretty simple example:
$whoops = new Whoops\Run;
// Add some handlers
$whoops->pushHandler(new Whoops\Handler\PrettyPageHandler);
$whoops->pushHandler(new Whoops\Handler\JsonResponseHandler);
// Setup Monolog, for example:
$logger = new Monolog\Logger;
$logger->pushHandler(new Monolog\Handler\StreamHandler("/my/exception.log"));
// Place our custom handler in front of the others, capturing exceptions
// and logging them, then passing the exception on to the other handlers:
$whoops->pushHandler(function ($exception, $inspector, $run) use($logger) {
$logger->addError($exception->getMessage());
});
from whoops.
@filp the handlers are called in reverse of the order they are added?
from whoops.
@unstoppablecarl That's correct! The idea is to follow the natural structure of an application, where the base/framework has a chance to add the base handlers, and the user/module/component code is able to add more granular behaviors.
from whoops.
@filp your code (#62 (comment)) doesn't work anymore with Monolog 2. Could you update that?
from whoops.
@maicol07, that’s a comment that’s over 6 years old. :-)
Try pushing the logger handler above the other handlers.
from whoops.
Related Issues (20)
- Occasional errors with zlib.output_compression = On HOT 1
- Catch php.ini warnings HOT 2
- Getting PHP Parse error when running the package in PHP 5.6.40 version HOT 6
- A way to add extra information HOT 4
- 2.14.4 Contains syntax not compatible with PHP ^5.5.9 HOT 2
- Adding an additional member variable and getter to PrettyPageHandler HOT 1
- Paystack_public_key
- Search logos HOT 3
- ArrayAccess Return Type issue HOT 1
- Is it able to run with swoole? HOT 1
- How to get exception? HOT 1
- E_NOTICE & E_WARNING just showing as plain text HOT 1
- PrettyPageHandler: make first frame with comments active on page load HOT 5
- Current line highlight does not work HOT 1
- Bug report. HOT 3
- PHP Fatal error: Uncaught Error: Call to a member function getFrameFilters() on null in vendor/filp/whoops/src/Whoops/Handler/PlainTextHandler.php:285 HOT 2
- Whoops \ Exception \ ErrorException (E_WARNING) Undefined variable $configuration
- PrettyPageHandler to html not working HOT 1
- Links in frame comments not legible (WCAG AA)
- Send http code based on Exception type or some other rule HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from whoops.