Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI/Oil capture the last error on shutdown Event #75

Open
polmartinez opened this issue Sep 7, 2016 · 5 comments
Open

CLI/Oil capture the last error on shutdown Event #75

polmartinez opened this issue Sep 7, 2016 · 5 comments

Comments

@polmartinez
Copy link

Hi,
I can't capture a last error when execute refine command on oil.

in bootstrap.php

\Event::register('shutdown', function() {
    $e = error_get_last();
    // $e is null
});

In all of cases $e is empty when create an Exception on script.

It's possible capture the last error on oil -> refine call for logging?
Thanks

@WanWizard
Copy link
Contributor

error_get_last(); doesn't return exception information, only PHP errors. Fuel logs all errors and exceptions by default, is that not enough?

@polmartinez
Copy link
Author

it's not enough, I need to centralize errors (at least simple as returned error_get_last) in a function to log them externally, but some errors as in the following example are not logged:

class Queue_Logs extends \Tasks {

    public static function run() {
        throw new \Exception('Exception test');

executing php oil refine queue_logs

How I can get all errors (or at least the fatal) in this event:?
\Event::register('shutdown', function() {

@WanWizard
Copy link
Contributor

You can't. There is no PHP method to retrieve the last exception.

The proper way of doing this, is to make a Monolog handler and attach it to the log instance.

@polmartinez
Copy link
Author

OK, I want to extends \Core\Log for 1.8 and rewrite logger method for 1.5 version. Thanks

@WanWizard
Copy link
Contributor

Not sure you need to.If you get \Log::instance(), the monolog instance is returned, and you can add your own log handler too it. See https://github.com/Seldaek/monolog/blob/master/doc/02-handlers-formatters-processors.md for a log list of already available handlers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants