Skip to content

Commit

Permalink
improve exception logging in production
Browse files Browse the repository at this point in the history
  • Loading branch information
WanWizard committed Jan 24, 2018
1 parent 0cfa059 commit 815f28c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions classes/command.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public static function init($args)
// Respect the group options
\Cli::option('group') and $command .= ' --group '.\Cli::option('group');
\Cli::option('exclude-group') and $command .= ' --exclude-group '.\Cli::option('exclude-group');

// Respect the testsuite options
\Cli::option('testsuite') and $command .= ' --testsuite '.\Cli::option('testsuite');

Expand Down Expand Up @@ -333,9 +333,12 @@ public static function init($args)

protected static function print_exception(\Exception $ex)
{
logger(\Fuel::L_ERROR, $ex->getMessage());
// create the error message, log and display it
$msg = $ex->getCode().' - '.$ex->getMessage().' in '.$ex->getFile().' on line '.$ex->getLine();
logger(\Fuel::L_ERROR, $msg);
\Cli::error('Uncaught exception '.get_class($ex).': '.$msg);

\Cli::error('Uncaught exception '.get_class($ex).': '.$ex->getMessage());
// print a trace if not in production, don't want to spoil external logging
if (\Fuel::$env != \Fuel::PRODUCTION)
{
\Cli::error('Callstack: ');
Expand All @@ -344,6 +347,7 @@ protected static function print_exception(\Exception $ex)
\Cli::beep();
\Cli::option('speak') and `say --voice="Trinoids" "{$ex->getMessage()}"`;

// print any previous exception(s) too...
if (($previous = $ex->getPrevious()) != null)
{
\Cli::error('');
Expand Down

0 comments on commit 815f28c

Please sign in to comment.