public static function register(LoggerInterface $logger = null, ErrorConfig $cfg = null) {
            self::$registered = true;

            /**
             * To allow easy extending.
             *
             * @var self $handler
             */
            $class = get_called_class();
            $handler = new $class($logger, $cfg);

            self::$lastRegisteredHandler = &$handler;

            set_error_handler([$handler, 'handle'], $handler->getErrorReporting());

            return $handler;
        }