/** * Call a logger from an Error constant and an error message * * @param int $level From E_* constants * @param string $message The error's error message * @return void */ static final function callErrorLogger($level, $message) { if (is_null(static::$errorLoggerInstance)) { static::$errorLoggerInstance = new self(); } static::$errorLoggerInstance->{static::$errorLoggerInstance->errorToLogLevel($level)}($message); }
/** * Registers $this::$hander method as `set_error_handler` * * @param string $handler Method to use for reporting errors * @param int $level Error reporting level to use. */ public function __construct($handler = null, $level = null) { set_error_handler([$this, (is_string($handler) and method_exists($this, $handler)) ? $handler : 'reportError'], is_int($level) ? $level : error_reporting()); if (is_null(static::$errorLoggerInstance)) { static::$errorLoggerInstance = $this; } }