public static function enable($mode = null, string $logDirectory = null, string $email = null): void
    {
        if ($mode !== null || self::$productionMode === null) {
            self::$mode = $mode;

            if (\is_bool($mode)) {
                self::$productionMode = $mode;
            }
        }

        // logging configuration
        if ($email !== null) {
            self::$email = $email;
        }

        if ($logDirectory) {
            if (!preg_match('#([a-z]+:)?[/\\\\]#Ai', $logDirectory)) {
                self::exceptionHandler(new \RuntimeException('Logging directory must be absolute path.'));
            } elseif (!is_dir(self::$logDirectory)) {
                self::exceptionHandler(new \RuntimeException("Logging directory '" . $logDirectory . "' is not found."));
            }

            self::$logDirectory = $logDirectory;
        }

        if (self::$enabled) {
            return;
        }

        self::$reserved = \str_repeat('t', 30000);
        self::$obLevel = \ob_get_level();

        // php configuration
        if (self::$iniSet = \function_exists('\ini_set')) {
            \ini_set('html_errors', '0');
            \ini_set('log_errors', '0');
        }

        \error_reporting(E_ALL);

        \register_shutdown_function([__CLASS__, 'shutdownHandler']);
        \set_exception_handler([__CLASS__, 'exceptionHandler']);
        \set_error_handler([__CLASS__, 'errorHandler']);

        self::$enabled = true;
        self::$enabledTime = \microtime(true);
    }