XWBDLOG ;ISF/RWF - Debug Logging for Broker ;12/08/2004 08:54
;;1.1;RPC BROKER;**35**;Mar 28, 1997
Q
;
;Setup the log, Clear the log location.
LOGSTART(RTN) ;Clear the debug log
Q:'$G(XWBDEBUG)
K ^XTMP("XWBLOG"_$J)
S ^XTMP("XWBLOG"_$J,0)=$$HTFM^XLFDT($$HADD^XLFDT($H,7))_"^"_$$DT^XLFDT
S ^XTMP("XWBLOG"_$J,.1)=0
D LOG("Log start: "_$$HTE^XLFDT($H)),LOG(RTN)
Q
LOG(MSG) ;Record Debug Info
Q:'$G(XWBDEBUG)
N CNT
S CNT=1+$G(^XTMP("XWBLOG"_$J,.1)),^(.1)=CNT,^(CNT)=$E($H_"^"_MSG,1,255)
Q
;
;
VIEW ;View log files
N DIRUT,XWB,DIR,IX,X,CON
D HOME^%ZIS
W !,"Log Files"
S XWB="XWBLOG",CON=""
F S XWB=$O(^XTMP(XWB)) Q:XWB'["XWBLOG" D
. D V1(.XWB)
. I $$WAIT(.CON) S:CON=3 XWB="XWC"
. Q
Q
;
V1(XWB) ;View one log
N IX,X,CNT
S IX=.9,X=$G(^XTMP(XWB,IX)),CON=0,CNT=+$G(^XTMP(XWB,.1))
Q:CNT<1
W !!,"Log from Job ",$E(XWB,7,99)," ",CNT," Lines"
F S IX=$O(^XTMP(XWB,IX)) Q:'$L(IX) S X=^XTMP(XWB,IX) D VL1(IX,X)
Q
;
VL1(J,K) ;Write a line
I $Y'<IOSL,$$WAIT(.CON) S IX="A" S:CON=3 XWB="XWC" Q
Q:'$D(^XTMP(XWB,IX))
N H,D,T,I
S H=$P($$HTE^XLFDT($P(K,"^"),"2S"),"@",2)_" = "
S D=$P(K,"^",2,99),K=D
I D?.E1C.E D
. S D=""
. F I=1:1:$L(K) S T=$A(K,I),D=D_$S(T>31:$E(K,I),1:"\"_$E((1000+T),3,4))
S T=$L(H)
F W !,H,?T,$E(D,1,68) S H="",D=$E(D,69,999) Q:'$L(D)
Q
;
WAIT(CON) ;continue/kill/exit
S DIR("?")="Enter RETURN to continue, Next for next log, Kill to remove log, Exit to quit log view."
S DIR("A")="Return to continue, Next log, Exit: "
S DIR(0)="SAB^1:Continue;2:Next;3:Exit;4:Kill",DIR("B")="Continue"
D ^DIR
S CON=+Y
I Y=4 D K1(XWB,0) H 1
I Y=1 W @IOF
Q Y>1
;
K1(REF,S) ;Kill one
I REF["XWBLOG" K ^XTMP(REF)
I 'S W !,"Log "_REF_" deleted."
Q
;
KILLALL ;KILL ALL LOG Entries
N DIR,XWB
S DIR(0)="Y",DIR("A")="Remove all XWB log entries",DIR("B")="No"
D ^DIR Q:Y'=1
S XWB="XWBLOG"
F S XWB=$O(^XTMP(XWB)) Q:XWB'["XWBLOG" D K1(XWB,1)
W !,"Done"
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HXWBDLOG 1974 printed Oct 16, 2024@18:37:47 Page 2
XWBDLOG ;ISF/RWF - Debug Logging for Broker ;12/08/2004 08:54
+1 ;;1.1;RPC BROKER;**35**;Mar 28, 1997
+2 QUIT
+3 ;
+4 ;Setup the log, Clear the log location.
LOGSTART(RTN) ;Clear the debug log
+1 if '$GET(XWBDEBUG)
QUIT
+2 KILL ^XTMP("XWBLOG"_$JOB)
+3 SET ^XTMP("XWBLOG"_$JOB,0)=$$HTFM^XLFDT($$HADD^XLFDT($HOROLOG,7))_"^"_$$DT^XLFDT
+4 SET ^XTMP("XWBLOG"_$JOB,.1)=0
+5 DO LOG("Log start: "_$$HTE^XLFDT($HOROLOG))
DO LOG(RTN)
+6 QUIT
LOG(MSG) ;Record Debug Info
+1 if '$GET(XWBDEBUG)
QUIT
+2 NEW CNT
+3 SET CNT=1+$GET(^XTMP("XWBLOG"_$JOB,.1))
SET ^(.1)=CNT
SET ^(CNT)=$EXTRACT($HOROLOG_"^"_MSG,1,255)
+4 QUIT
+5 ;
+6 ;
VIEW ;View log files
+1 NEW DIRUT,XWB,DIR,IX,X,CON
+2 DO HOME^%ZIS
+3 WRITE !,"Log Files"
+4 SET XWB="XWBLOG"
SET CON=""
+5 FOR
SET XWB=$ORDER(^XTMP(XWB))
if XWB'["XWBLOG"
QUIT
Begin DoDot:1
+6 DO V1(.XWB)
+7 IF $$WAIT(.CON)
if CON=3
SET XWB="XWC"
+8 QUIT
End DoDot:1
+9 QUIT
+10 ;
V1(XWB) ;View one log
+1 NEW IX,X,CNT
+2 SET IX=.9
SET X=$GET(^XTMP(XWB,IX))
SET CON=0
SET CNT=+$GET(^XTMP(XWB,.1))
+3 if CNT<1
QUIT
+4 WRITE !!,"Log from Job ",$EXTRACT(XWB,7,99)," ",CNT," Lines"
+5 FOR
SET IX=$ORDER(^XTMP(XWB,IX))
if '$LENGTH(IX)
QUIT
SET X=^XTMP(XWB,IX)
DO VL1(IX,X)
+6 QUIT
+7 ;
VL1(J,K) ;Write a line
+1 IF $Y'<IOSL
IF $$WAIT(.CON)
SET IX="A"
if CON=3
SET XWB="XWC"
QUIT
+2 if '$DATA(^XTMP(XWB,IX))
QUIT
+3 NEW H,D,T,I
+4 SET H=$PIECE($$HTE^XLFDT($PIECE(K,"^"),"2S"),"@",2)_" = "
+5 SET D=$PIECE(K,"^",2,99)
SET K=D
+6 IF D?.E1C.E
Begin DoDot:1
+7 SET D=""
+8 FOR I=1:1:$LENGTH(K)
SET T=$ASCII(K,I)
SET D=D_$SELECT(T>31:$EXTRACT(K,I),1:"\"_$EXTRACT((1000+T),3,4))
End DoDot:1
+9 SET T=$LENGTH(H)
+10 FOR
WRITE !,H,?T,$EXTRACT(D,1,68)
SET H=""
SET D=$EXTRACT(D,69,999)
if '$LENGTH(D)
QUIT
+11 QUIT
+12 ;
WAIT(CON) ;continue/kill/exit
+1 SET DIR("?")="Enter RETURN to continue, Next for next log, Kill to remove log, Exit to quit log view."
+2 SET DIR("A")="Return to continue, Next log, Exit: "
+3 SET DIR(0)="SAB^1:Continue;2:Next;3:Exit;4:Kill"
SET DIR("B")="Continue"
+4 DO ^DIR
+5 SET CON=+Y
+6 IF Y=4
DO K1(XWB,0)
HANG 1
+7 IF Y=1
WRITE @IOF
+8 QUIT Y>1
+9 ;
K1(REF,S) ;Kill one
+1 IF REF["XWBLOG"
KILL ^XTMP(REF)
+2 IF 'S
WRITE !,"Log "_REF_" deleted."
+3 QUIT
+4 ;
KILLALL ;KILL ALL LOG Entries
+1 NEW DIR,XWB
+2 SET DIR(0)="Y"
SET DIR("A")="Remove all XWB log entries"
SET DIR("B")="No"
+3 DO ^DIR
if Y'=1
QUIT
+4 SET XWB="XWBLOG"
+5 FOR
SET XWB=$ORDER(^XTMP(XWB))
if XWB'["XWBLOG"
QUIT
DO K1(XWB,1)
+6 WRITE !,"Done"
+7 QUIT