如果PHP达到执行超时,如何记录?

How is it possible to log when/if PHP exceed max_execution_time and execution is terminated?

I already have these two functions

register_shutdown_function(function(){
    if($error = error_get_last()){
        switch($error['type']){
            case E_ERROR:
            case E_CORE_ERROR:
            case E_COMPILE_ERROR:
                $message = $error['message'].' '.$error['file'].'('.$error['line'].')';
                if(class_exists('Log')){
                    Log::write($message, 'fatal', true, true);
                }
                if(ENV != ENV_PROD){
                    echo $message;
                }
                break;
        }
    }
});

set_error_handler(function(int $errno, string $errstr, string $errfile, int $errline){
    switch($errno){
        case E_WARNING:
        case E_PARSE:
        case E_NOTICE:
            $message = "$errstr $errfile($errline)
".(new Error)->getTraceAsString();
            if(class_exists('Log')){
                Log::write($message, 'warning', true, true);
            }
            if(ENV != ENV_PROD){
                echo $message;
            }
            break;
    }
});