第九章 使用 ^%ZSTART 和 ^%ZSTOP 例程自定义启动和停止行为 - 启用 %ZSTART 和 %ZSTOP
迪丽瓦拉
2024-05-30 13:46:53
0

文章目录

  • 第九章 使用 ^%ZSTART 和 ^%ZSTOP 例程自定义启动和停止行为 - 启用 %ZSTART 和 %ZSTOP
  • 启用 `%ZSTART` 和 `%ZSTOP`
  • 调试 `^%ZSTART` 和 `^%ZSTOP`
  • 删除 `%ZSTART` 和 `^%ZSTOP`
  • 示例
    • `^%ZSSUtil` 例子

第九章 使用 ^%ZSTART 和 ^%ZSTOP 例程自定义启动和停止行为 - 启用 %ZSTART 和 %ZSTOP

启用 %ZSTART%ZSTOP

一旦例程被设计、开发、编译并准备好进行测试,就可以通过管理门户启用各个入口点。通过依次选择“系统管理”、“配置”、“其他设置”和“启动设置”导航到“启动设置”页面,然后编辑相应的个人设置:

  • SystemStart, SystemHalt

  • ProcessStart, ProcessHalt

  • JobStart, JobHalt

  • CallinStart, CallinHalt

要停用一个或多个入口点,请使用相同的过程,但将值更改为 false

调试 ^%ZSTART^%ZSTOP

在最终环境中调试 ^%ZSTART^%ZSTOP 的机会非常有限。如果发生错误,错误将写入操作员消息日志,这是运行这些例程时的当前设备。该文件是 messages.log,位于 Manager 的目录中。

该消息指示失败的原因和检测到错误的位置。这可能与程序逻辑或流程中实际发生错误的地方不同。开发人员应该从提供的信息中推断出错误的性质和位置,或者修改例程以便将来的测试提供更多关于错误性质的证据。

删除 %ZSTART^%ZSTOP

强烈建议在删除例程之前通过管理门户禁用入口点选项。如果门户警告需要重启 IRIS 才能生效,请在继续之前执行此操作。这保证在删除入口点时不会执行任何入口点。

请记住,^%ZSTART^%ZSTOP(以及任何支持例程)是永久存储的。要删除它们的所有痕迹,请通过管理门户删除它们。

示例

以下示例演示了用于跟踪系统活动的简单日志。它显示了 ^%ZSTART^%ZSTOP 的示例,为方便起见,这两个示例都使用了第三个示例例程 ^%ZSSUtil 的子例程。

^%ZSSUtil 例子

该例程有两个公共入口点。将一行写入操作员消息日志文件。另一个将名称-值对列表写入本地日志文件。这两个文件都位于管理器的目录中,该目录由类中 %Library.FileManagerDirectory() 方法返回。

%ZSSUtil ;; this routine packages a set of subroutines; used by the %ZSTART and %ZSTOP entry points;; does not do anything if invoked directlyquit#define Empty ""
#define OprLog 1WriteConsole(LineText) PUBLIC ;; write the line to the messages log; by default the file messages.log in the MGR directorynew SaveIO; save the current device and open the operator console; set up error handling to cope with errors; there is little to do if an error happensset SaveIO = $IOset $ZTRAP = "WriteConsoleExit"open $$$OprLoguse $$$OprLog; we do not need an "!" for line termination; because each WRITE statement becomes its; own console record (implicit end of line)write LineText; restore the previous io deviceclose $$$OprLog; pick up here in case of an error
WriteConsoleExit ;set $ZTRAP = ""use SaveIOquitWriteLog(rtnname, entryname, items) PUBLIC ;; write entries into the log file; the log is presumed to be open as; the default output device;; rtnname: distinguishes between ZSTART & ZSTOP; entryname: the name of the entry point we came from; items: a $LIST of name-value pairsnew ThisIO, ThisLognew i, DataString; preserve the existing $IO device reference; set up error handling to cope with errors; there is little to do if an error happensset ThisIO = $IOset $ZTRAP = "WriteLogExit"; construct the name of the file; use the month and day as part of the name so that; it will create a separate log file each dayset ThisLog = "ZSS"_ "-"_ $EXTRACT($ZDATE($HOROLOG, 3), 6, 10)_".log"; and change $IO to point to our fileopen ThisLog:"AWS":0use ThisLog; now loop over the items writing one line per item pairfor i = 1 : 2 : $LISTLENGTH(items){set DataString = $LISTGET(items, i, "*MISSING*")if ($LISTGET(items, (i + 1), $$$Empty) '= $$$Empty){set DataString = DataString_ ": "_ $LISTGET(items, (i + 1))}write $ZDATETIME($HOROLOG, 3, 1),?21, rtnname,?28, entryname,?35, DataString, !}; stop using the log file and switch $IO back; to the value saved on entryclose $IO; pick up here in case of an error
WriteLogExit ;set $ZTRAP = ""use ThisIOquit

相关内容