用LOG记录程式执行过程
用LOG记录程式执行过程
Ø 现场情况说明
如果遇到程式有时会发生的问题或者想要检测程式执行的速度,可采用追加日志的方法检测出问题点
Ø 方法
#程式开头定义module变量
DEFINE g_logfile STRING DEFINE g_logdate STRING DEFINE ch base.Channel DEFINE g_logcont STRING |
#程式MAIN函数中开始建立文件,注意路径和文件名,路径一般是在临时文件夹中
#文件名如下的例子是年月日+时间的,这样每个程式运行一次会产生一个,
#如果仅仅加年月日,当天程式的日志会保留最后一次程式跑的日志,其他会覆盖掉
LET g_logdate=YEAR(CURRENT) USING "####",MONTH(CURRENT) USING "&&",DAY(CURRENT) USING "&&" LET g_logfile="/u1/out/axrp330-",g_logdate,".log" LET ch=base.Channel.create() CALL ch.setDelimiter("") CALL ch.openFile(g_logfile,"w") CALL ch.writeLine("program start") |
#在程式任何需要加日志的地方增加如下所示的日志记录
LET g_logcont="--FOREACH p330_cs start time:"||TIME(CURRENT)||" 笔数:"||l_cjp||"--" CALL ch.writeLine(g_logcont) |
#标志程式结束
CALL ch.writeLine("program end") |