当前位置: 首页 > 后端技术 > PHP

AsfPHP扩展框架警告模块介绍

时间:2023-03-29 16:37:22 PHP

1.什么是警告?预警可以理解为我们日常生活中的体检。不管大家贫富,健康的身体是事业和生活的基础。我们将项目的健康状况与“1”进行比较。项目的N个子功能/子模块,比如登录模块,注册模块,都是“1”后的“0”。如果项目出现问题(比如HttpStatusCode502,页面或界面响应慢),这意味着前面的“1”已经不存在了,即使后面还有更多的“0”,没有意义。2、预警能起到什么作用?用医学术语来表达,包括三个方面:早发现病先治、早治疗早诊断、及时治疗。支持的配置项和配置详情请看这里>>>获取StartAsfPHP扩展框架内置了预警机制。预警范围包括两个方面,每个方面包括两种不同的预警处理方式。PHP脚本执行异常预警FatalErrorWarningNoticeStrictDeprecatedUnknownErrorE_PARSEE_WARNINGE_NOTICEE_STRICTE_DEPRECATEDE_OTHERSE_ERRORE_USER_WARNINGE_USER_NOTICE---E_CORE_ERRORE_CORE_WARNING----E_COMPILE_ERRORE_COMPILE_WARNING----E_USER_ERRORE_RECOVERABLE_ERROR----PHP脚本执行时间耗时预警(非CLI模式下)配置项类型默认值(秒)含义asf.dispathcer.timeout.max_script_timedouble1.0scripttimeoutwarningasf.dispathcer.timeout.max_db_timedouble0.1SQLtimeoutwarningasf.dispathcer.timeout.max_cache_timedouble0.1NoSQLtimeoutwarningasf.dispathcer.timeout.max_curl_timedouble0.1CURLtimeoutwarning4.LocalloggingschemeDemoLocalloggingsolution,supportsLogBuffer,performanceindicatorspleaserefertohere>>>GetStart4.1PHPscriptexecutionexceptionwarninglogformatspecificationpleaserefertohere>>>GetStart[dongshuang@box3/data/www/box3.cn/public]$catindex.phparray('root_path'=>dirname(__DIR__).'/apps','log_path'=>'/data/logs',/*logstoragedirectory,writepermission*/'dispatcher'=>['log'=>['err'=>1]/*open*/]));$app=newApp($configs);$app->run();4.1.1/data/logs/Asf_Err_Log样本[dongshuang@box3/data/logs]$tailfAsf_Err_Log2019-02-2216:01:11Asia/Shanghai|注意事项|28984|注意:未定义变量:bin/data/www/box3.cn/apps/Bootstrap.phponline212019-02-2216:01:11Asia/Shanghai|警告|31486|Warning:include(test.php):failedtoopenstream:Nosuchfileordirectoryin/data/www/box3.cn/apps/Bootstrap.phponline202019-02-2216:02:24亚洲/上海|错误|4137|FatalError:Asf\Application::run()NomethodlistaactioninDeviceServicein/data/www/box3.cn/public/index.phponline23Stacktrace:##settled_uri=/v1/device/lista#0/data/www/box3.cn/public/index.php(23):Asf\Application->run()#1{main}4.2PHP脚执行时间写入时间预警[dongshuang@box3/data/www/box3.cn/public]$catindex.phparray('root_path'=>dirname(__DIR__).'/apps','log_path'=>'/数据/日志',/*日志存放目录,写入权限*/'dispatcher'=>['log'=>['timeout'=>1]/*打开*/]));$app=newApp($configs);$app->run();4.2.1/data/logs/Asf_Timeout_Log示例[dongshuang@box3/data/logs]$tailfAsf_Timeout_Log2019-02-2509:06:48UTC|信息|26026|127.0.0.1:6379Redis::set(110)执行速度太慢0.201406sec2019-02-2509:06:48UTC|信息|26026|127.0.0.1:6379Redis::get(111)执行速度太慢0.201349sec2019-02-2509:06:48UTC|信息|26026|/index/redisexecutingtooslow1.008510sec5.函数回调(可调用)方案Demo5.1PHP脚本执行异常警告[dongshuang@box3/data/www/box3.cn/public]$catindex.phparray('root_path'=>目录名(__DIR__).'/apps',));$app=新应用程序($configs);$app->setErrorHandler('myErrorHandler');$app->run();5.1.1异常警告-结果示例int(999)string(33)"FatalError:Class'ck'notfound"string(53)"/data/www/box3.cn/apps/api/services/Index.php"int(42)5.2PHP脚本执行时间耗时警告[dongshuang@box3/data/www/box3.cn/public]$catindex.phparray('root_path'=>dirname(__DIR__).'/apps',));$app=newApp($configs);$app->setTimeoutHandler('myTimeoutHandler');$app->run();5.2.1耗时警告-结果示例int(976)string(44)"/index/redis执行速度太慢0.508643秒”VI。asf警告错误号段说明6.1《异常预警》错误号段990~999errno=999,含义:FatalError(框架会有效拦截异常信息,防止服务器信息泄露)errno=998,含义:Warningerrno=997,表示含义:noticeerrno=996,表示意思:Stricterrno=995,表示意思:Deprecatederrno=994,表示意思:UnknownError6.2《超时预警》errornumberrange970~989errno=970,表示意思:MySQLsingleSQL执行timeexceedsthepresetthresholderrno=971,meaning:Redis单条NoSQL执行时间超过预设阈值errno=972,meaning:memcachedThesingleNoSQLexecutiontimeexceededthepresetthresholderrno=973,meaning:PgSQLThesingleSQLexecutiontimeexceededthepresetthresholderrno=974,meaning:SQLiteThesingleSQLexecutiontimeexceededthepresetthresholderrno=975,意思是:CURLrequesttimeexceedsthepresetthresholderrno=976,表示:脚本完整生命周期的请求时间超过预设阈值,继续开放更多功能如果您在使用过程中有任何问题,请联系我们。当然,我们也可以聊点更好玩的^_^