wilon/exception

Better exception output & write log.

0.2.3 2017-09-27 03:32 UTC

This package is not auto-updated.

Last update: 2024-12-22 05:03:34 UTC


README

Packagist Packagist Release Packagist Downloads

Better exception output & write log. Like Laravel.

Installation & loading

php -v >=5.3.9 Run: composer require wilon/exception:~0.1

php -v >=5.5.9 Run: composer require wilon/exception

Bootstrap

    (new Wilon\Exception\Handler)->bootstrap();
    // Set error_reporting(-1) & Show debug.
    // Write log to ./exceptions.log

Better :

    $errorReporting = E_ALL ^ E_NOTICE;
    $showErrorInfo = true;

    (new Wilon\Exception\Handler)
        ->bootstrap($errorReporting, $showErrorInfo);

     // Set error_reporting(E_ALL ^ E_NOTICE) & Show debug.
     // Write log to ./exceptions.log .

Or more Settings:

    $loggerName = 'exceptions';
    $loggerFile = __DIR__ . '/exceptions.log';
    $errorReporting = E_ALL ^ E_NOTICE;
    $showErrorInfo = true;
    
    (new Wilon\Exception\Handler)
        ->setLogger($loggerName, $loggerFile)
        ->bootstrap($errorReporting, $showErrorInfo);

Funtion Desc

setLogger ( string $loggerName, string $loggerFile)

Set Monolog

  • string $loggerName

    $logger = new Logger($loggerName);

  • string $loggerFile

    $logger->pushHandler(new StreamHandler($loggerFile, Logger::WARNING));

bootstrap ( [ int $level [, boolean $show] )

Sets which PHP errors are reported

  • int $level

    The new error_reporting level.

  • string $show

    If is true, show debug.