modified CliController to use ErrorStream conf var and separate logging by LOGGING/PROFILER settings
This commit is contained in:
@ -24,7 +24,7 @@ class CliController
|
||||
protected function __construct()
|
||||
{
|
||||
ErrorHandler::init();
|
||||
$this->error_stream = fopen('php://stderr', 'rw');
|
||||
$this->error_stream = Config::get('ErrorStream');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -51,11 +51,20 @@ class CliController
|
||||
}
|
||||
$cli_class->run();
|
||||
if (Config::get('PROFILER')) {
|
||||
echo PHP_EOL . Profiler::getInstance()->getCli();
|
||||
$profile = Profiler::getInstance()->getCli();
|
||||
if (Config::get('LOGGING')) {
|
||||
Logger::getInstance()->log($profile);
|
||||
} else {
|
||||
echo $profile;
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
fwrite($this->error_stream, PHP_EOL . 'Error: ' . $e->getMessage() . PHP_EOL);
|
||||
fwrite($this->error_stream, PHP_EOL . 'Stack trace: ' . PHP_EOL . $e->getTraceAsString() . PHP_EOL);
|
||||
$code = $e->getCode();
|
||||
if ($e instanceof ErrorException) {
|
||||
$code = $e->getSeverity();
|
||||
}
|
||||
file_put_contents($this->error_stream, PHP_EOL . 'Error ' . '#' . $code . ': ' . $e->getMessage() . PHP_EOL, FILE_APPEND);
|
||||
file_put_contents($this->error_stream, PHP_EOL . 'Stack trace: ' . PHP_EOL . $e->getTraceAsString() . PHP_EOL, FILE_APPEND);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user