美文网首页js css html
第十一章 使用 ^%ZSTART 和 ^%ZSTOP 例程自定义

第十一章 使用 ^%ZSTART 和 ^%ZSTOP 例程自定义

作者: Cache技术分享 | 来源:发表于2023-03-09 07:15 被阅读0次

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

^%ZSTART

该例程包含 IRIS 实际调用的入口点。它使用刚刚描述的 ^%ZSSUtil 的服务。所有入口点的行为大致相同,它们在日志中放置一些信息。 SYSTEM 入口点比其他入口点稍微复杂一些。它还将信息放在操作员消息日志中。

%ZSTART ; User startup routine.

#define ME "ZSTART"
#define BgnSet "Start"
#define Empty ""

    ; cannot be invoked directly
    quit

SYSTEM ;
    ; InterSystems IRIS starting
    new EntryPoint, Items

     set EntryPoint = "SYSTEM"

     ; record the fact we got started in the messages log
     do WriteConsole^%ZSSUtil((EntryPoint
                               _ "^%"
                               _ $$$ME
                               _ " called @ "
                               _ $ZDATETIME($HOROLOG, 3)))

    ; log the data accumulate results
     set Items = $LISTBUILD($$$BgnSet, $ZDATETIME($HOROLOG, 3),
                           "Job", $JOB,
                           "Computer", ##class(%SYS.System).GetNodeName(),
                           "Version", $ZVERSION,
                           "StdIO", $PRINCIPAL,
                           "Namespace", $NAMESPACE,
                           "CurDirPath", ##class(%File).ManagerDirectory(),
                           "CurNSPath", ##class(%File).NormalizeDirectory(""),
                           "CurDevName", $System.Process.CurrentDevice(),
                           "JobType", $System.Process.JobType(),
                           "JobStatus", $ZHEX($ZJOB),
                           "StackFrames", $STACK,
                           "AvailStorage", $STORAGE,
                           "UserName", $System.Process.UserName())
    do WriteLog^%ZSSUtil($$$ME, EntryPoint, Items)

    quit
LOGIN ;
    ; a user logs into InterSystems IRIS
    new EntryPoint, Items

    set EntryPoint = "LOGIN"
     set Items = $LISTBUILD($$$BgnSet, $ZDATETIME($HOROLOG, 3))
    do WriteLog^%ZSSUtil($$$ME, EntryPoint, Items)
    quit

JOB ;
    ; JOB'd process begins
    new EntryPoint, Items

     set EntryPoint = "JOB"
     set Items = $LISTBUILD($$$BgnSet, $ZDATETIME($HOROLOG, 3))
    do WriteLog^%ZSSUtil($$$ME, EntryPoint, Items)
    quit

CALLIN ;
    ; a process enters via CALLIN interface
    new EntryPoint, Items

     set EntryPoint = "CALLIN"
     set Items = $LISTBUILD($$$BgnSet, $ZDATETIME($HOROLOG, 3))
    do WriteLog^%ZSSUtil($$$ME, EntryPoint, Items)
    quit

以下是每个标签的说明:

^%ZSTART

此例程以Quit命令开始,因此如果将其作为例程调用,而不是在其入口点之一正确开始执行,则它是良性的。

此例程还为自己的名称、起始字符串和空字符串定义命名常量(作为宏)。

SYSTEM^%ZSTART

此子例程构造一个由调用例程名称、入口点以及调用日期和时间组成的字符串。然后它调用WriteConsole^%ZSSUtil将其放入操作员消息日志中。

然后,它构造一个它希望显示的名称-值对的列表。它将其传递给WriteLog^%ZSSUtil以放置到本地日志文件中。然后它返回给它的调用者。

LOGIN^%ZSTART, JOB^%ZSTART, and CALLIN^%ZSTART

这些子例程不会在操作员消息日志中放置任何信息。相反,他们构建了一个简短的项目列表,足以识别它们被调用,然后使用 WriteLog^%ZSSUtil来记录它。

^%ZSTOP

该例程包含 IRIS 实际调用的入口点,它使用 ^%ZSSUtil 中的子例程。此示例类似于 ^%ZSTART 的示例。有关详细信息,请参阅上一节。

%ZSTOP ; User shutdown routine.

#define ME "ZSTOP"
#define EndSet "End"
#define Empty ""

    ; cannot be invoked directly
    quit

SYSTEM ; InterSystems IRIS stopping
    new EntryPoint

    set EntryPoint = "SYSTEM"
    ; record termination in the messages log
    do WriteConsole^%ZSSUtil((EntryPoint
        _ "^%"
        _ $$$ME
        _ " called @ "
        _ $ZDATETIME($HOROLOG, 3)))
    ; write the standard log information
    do Logit(EntryPoint, $$$ME)
    quit

LOGIN ; a user logs out of InterSystems IRIS
    new EntryPoint

    set EntryPoint = "LOGIN"
    do Logit(EntryPoint, $$$ME)
    quit

JOB ; JOB'd process exits.
    new EntryPoint

    set EntryPoint = "JOB"
    do Logit(EntryPoint, $$$ME)
    quit

CALLIN ; process exits via CALLIN interface.
    new EntryPoint

    set EntryPoint = "CALLIN"
    do Logit(EntryPoint, $$$ME)
    quit

Logit(entrypoint, caller) PRIVATE ;
    ; common logging for exits

    new items

    set items = $LISTBUILD($$$EndSet, $ZDATETIME($HOROLOG, 3))
    do WriteLog^%ZSSUtil(caller, entrypoint, items)
    quit

相关文章

网友评论

    本文标题:第十一章 使用 ^%ZSTART 和 ^%ZSTOP 例程自定义

    本文链接:https://www.haomeiwen.com/subject/vcdaldtx.html