source: WorldVistAEHR/trunk/r/MY_HEALTHEVET-MHV/MHVUL3.m@ 823

Last change on this file since 823 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 7.8 KB
Line 
1MHVUL3 ;WAS/GPM - MHV UTILITIES - LOGGING ; 3/17/06 12:03am [5/24/06 10:18am]
2 ;;1.0;My HealtheVet;**1**;Aug 23, 2005
3 ;;Per VHA Directive 2004-038, this routine should not be modified.
4 ;
5 Q
6 ; Utilities supporting user options for logging
7 ;
8LOGONO ; Turn on logging
9 N RESULT,DIR,DIRUT,DA,X,Y,DTM,%DT
10 D LOGINFOO
11 W !
12 D LOGINFO^MHVUL1(.RESULT)
13 I RESULT("DELETE")="" S RESULT("DELETE")=$$HTFM^XLFDT($H+30,1)
14 ;
15 ; If logging is already on prompt if want to change deletion date
16 I RESULT("STATE") D Q:$D(DIRUT)!'Y
17 . S DIR(0)="Y"
18 . S DIR("A",1)="Logging is already turned on."
19 . S DIR("A")="Reset deletion date"
20 . S DIR("?",1)="MHV application logging is already active."
21 . S DIR("?")="You may enter a new deletion date for the log."
22 . S DIR("B")="NO"
23 . D ^DIR
24 . Q
25 ;
26 ; Prompt for deletion date
27 K DIR,DIRUT,DA,X,Y
28 S DIR(0)="DA^"_DT_"::TX"
29 S DIR("A")="Log Deletion Date: "
30 S DIR("?",1)="Enter a future date to delete MHV application log."
31 S DIR("?",2)="After this date logging will automatically be stopped,"
32 S DIR("?")="and all log entries permanently deleted."
33 S DIR("B")=$$FMTE^XLFDT(RESULT("DELETE"),1)
34 D ^DIR Q:$D(DIRUT)
35 ;
36 D LOGON^MHVUL1(.RESULT,Y)
37 W !!,"MHV application logging switched on."
38 W !,"Log will be deleted on "_$$FMTE^XLFDT($P(RESULT,"^",2),1)_"."
39 Q
40 ;
41LOGSETO ; Set logging parameters
42 N RESULT,UPDATE,DIR,DIRUT,DA,X,Y,DTM,%DT,N,I
43 D LOGINFOO
44 W !
45 D LOGINFO^MHVUL1(.UPDATE)
46 ;
47 ; State ON/OFF
48 K DIR,DIRUT,DA,X,Y
49 S DIR(0)="SA^1:ON;0:OFF"
50 S DIR("A")="Logging: "
51 S DIR("?")="Enter ON or OFF"
52 S DIR("B")=$S(UPDATE("STATE"):"ON",1:"OFF")
53 D ^DIR
54 Q:$D(DIRUT)
55 S UPDATE("STATE")=Y
56 ;
57 ; Deletion Date
58 K DIR,DIRUT,DA,X,Y
59 S DIR(0)="DA^"_DT_"::TX"
60 S DIR("A")="Log Deletion Date: "
61 S DIR("?",1)="Enter a future date to delete MHV application log."
62 S DIR("?",2)="After this date logging will automatically be stopped,"
63 S DIR("?")="and all log entries permanently deleted."
64 S DIR("B")=$$FMTE^XLFDT(UPDATE("DELETE"))
65 D ^DIR Q:$D(DIRUT)
66 S UPDATE("DELETE")=Y
67 ;
68 ; Logging Level
69 K DIR,DIRUT,DA,X,Y
70 S DIR(0)="SA^E:ERROR;T:TRACE;N:NAMED;D:DEBUG"
71 S DIR("A")="Logging Level? "
72 S DIR("?",1)="Set logging level"
73 S DIR("?",2)="ERROR - only errors logged"
74 S DIR("?",3)="TRACE - Trace and errors logged"
75 S DIR("?",4)="NAMED - Named entries, trace and errors logged"
76 S DIR("?")="DEBUG - All entries logged"
77 S DIR("B")=UPDATE("LEVEL")
78 D ^DIR
79 Q:$D(DIRUT)
80 S UPDATE("LEVEL")=Y(0)
81 ;
82 ; Names
83 I UPDATE("LEVEL")="NAMED" D
84 . S N=UPDATE("NAMES")
85 . F I=2:1:$L(N,"^") S:$P(N,"^",I)'="" UPDATE("NAMES",$P(N,"^",I))=""
86 . F D Q:$D(DIRUT)
87 .. K DIR,DIRUT,DA,X,Y
88 .. S DIR(0)="FO^"
89 .. S DIR("A")="Entry name"
90 .. S DIR("A",1)=UPDATE("NAMES")
91 .. S DIR("?",1)="Enter names of entries to log"
92 .. S DIR("?")="Remove entries by prefixing with @"
93 .. S DIR("B")=""
94 .. D ^DIR
95 .. Q:$D(DIRUT)
96 .. I $E(Y)="@" K UPDATE("NAMES",$E(Y,2,$L(Y)))
97 .. E S UPDATE("NAMES",Y)=""
98 .. S UPDATE("NAMES")="^",N=""
99 .. F S N=$O(UPDATE("NAMES",N)) Q:N="" S UPDATE("NAMES")=UPDATE("NAMES")_N_"^"
100 .. Q
101 . Q
102 ;
103 ; Auto Purge ON/OFF
104 K DIR,DIRUT,DA,X,Y
105 S DIR(0)="SA^1:ON;0:OFF"
106 S DIR("A")="Auto Purge: "
107 S DIR("?")="Enter ON or OFF"
108 S DIR("B")=$S(UPDATE("AUTOPURGE"):"ON",1:"OFF")
109 D ^DIR
110 Q:$D(DIRUT)
111 S UPDATE("AUTOPURGE")=Y
112 ;
113 ; Days to Keep
114 I UPDATE("AUTOPURGE") D Q:$D(DIRUT)
115 . I 'UPDATE("DAYS") S UPDATE("DAYS")=7
116 . K DIR,DIRUT,DA,X,Y
117 . S DIR(0)="N^1:365"
118 . S DIR("A")="Days to Keep"
119 . S DIR("?")="Enter number of days to keep log entries"
120 . S DIR("B")=UPDATE("DAYS")
121 . D ^DIR
122 . S UPDATE("DAYS")=Y
123 . Q
124 ;
125 W !!,"New MHV Application Log Settings:"
126 D LOGINFOD(.UPDATE)
127 W !
128 S DIR(0)="Y"
129 S DIR("A")="Ok to proceed with update"
130 S DIR("?")="Update logging parameters with those shown?"
131 S DIR("B")="NO"
132 D ^DIR Q:$D(DIRUT)
133 I 'Y Q
134 ;
135 D LOGSET^MHVUL1(.RESULT,.UPDATE)
136 W !!,"Logging parameters updated"
137 D LOGINFOO
138 Q
139 ;
140LOGOFFO ;Turn off logging
141 N RESULT,DIR,DIRUT,DA,X,Y
142 D LOGINFOO
143 W !
144 D LOGINFO^MHVUL1(.RESULT)
145 ; Quit if logging is already off
146 I 'RESULT("STATE") W !,"Logging is already turned off." Q
147 S DIR(0)="Y"
148 S DIR("A")="Turn off logging"
149 S DIR("?")="Turn off MHV application logging."
150 S DIR("B")="NO"
151 D ^DIR Q:$D(DIRUT)
152 I 'Y Q
153 ;
154 D LOGOFF^MHVUL1(.RESULT)
155 W !!,"MHV application logging switched off."
156 W !,"Log will be deleted on "_$$FMTE^XLFDT($P(RESULT,"^",2),1)_"."
157 Q
158 ;
159LOGPRGO ; Purge log
160 N RESULT,DIR,DIRUT,DA,X,Y,DTM,%DT
161 D LOGINFOO
162 W !
163 ; Purge from date
164 S DIR(0)="D^:"_DT_":TX"
165 S DIR("A")="Purge From Date"
166 S DIR("?",1)="Enter a past date to purge MHV application log."
167 S DIR("?")="All log entries older than this date will be removed."
168 S DIR("B")=$$HTE^XLFDT($H-7,1)
169 D ^DIR Q:$D(DIRUT)
170 S DTM=Y
171 ;
172 ; Confirm Purge
173 K DIR,DIRUT,DA,X,Y
174 S DIR(0)="Y"
175 S DIR("A",1)="Log will be purged from "_$$FMTE^XLFDT(DTM)_"."
176 S DIR("A")="OK to proceed"
177 S DIR("?")="All log entries older than this date will be removed."
178 S DIR("B")="NO"
179 D ^DIR Q:$D(DIRUT)
180 Q:'Y
181 ;
182 D LOGPRG^MHVUL1(.RESULT,DTM)
183 W !!,"Log purged from "_$$FMTE^XLFDT($P(RESULT,"^",2),1)_"."
184 Q
185 ;
186LOGINFOO ; Display log information
187 N RESULT
188 D LOGINFO^MHVUL1(.RESULT)
189 W !!,"MHV Application Log Settings:"
190 D LOGINFOD(.RESULT)
191 Q
192 ;
193LOGINFOD(RESULT) ; Display log
194 W !," Log Creation Date: ",$$FMTE^XLFDT(RESULT("CREATED"))
195 W !," Log Deletion Date: ",$$FMTE^XLFDT(RESULT("DELETE"))
196 W !," Oldest Entry: ",$$FMTE^XLFDT(RESULT("OLDEST"))
197 W !," Newest Entry: ",$$FMTE^XLFDT(RESULT("NEWEST"))
198 W !," Logging: ",$S(RESULT("STATE"):"",1:"OFF")
199 I RESULT("STATE") D
200 . W RESULT("LEVEL")_" mode"
201 . I RESULT("LEVEL")="NAMED" W !,?16,"Names: ",RESULT("NAMES")
202 . Q
203 W !," Auto Purge: ",$S(RESULT("AUTOPURGE"):"",1:"OFF")
204 I RESULT("AUTOPURGE") W +RESULT("DAYS")," days"
205 Q
206 ;
207LOGSIZEO ; Display log size information
208 N RESULT
209 D LOGSIZE^MHVUL1(.RESULT)
210 W !!,"MHV Application Log Size:"
211 D LOGSIZED(.RESULT)
212 Q
213 ;
214LOGSIZED(RESULT) ; Display log size
215 W !," Number of Entries: ",RESULT("ENTRY COUNT")
216 W !," Number of Nodes: ",RESULT("NODE COUNT")
217 W !," Approx. size in KB: ",RESULT("BYTE COUNT")\1024
218 Q
219 ;
220LOGVIEWO ; View log
221 N LOG,CNT,DTM,J,ENTRY,RESULT,DIR,DIRUT,DTOUT,DUOUT,DA,X,Y,DTM
222 ; Use the browser if supported by emulation
223 I $$TEST^DDBRT D LOGBROWS^MHVUL2 Q
224 K ^TMP("MHV LOG SUMMARY",$J)
225 K ^TMP("MHV LOG DETAIL",$J)
226 D LOGSUM^MHVUL1(.LOG)
227 S CNT=$P(@LOG,"^",2)
228 I CNT<1 D LOGSUMD(LOG) Q
229 F D Q:$D(DIRUT)
230 . D LOGSUMD(LOG) Q:$D(DTOUT)!$D(DUOUT)
231 . K DIR,X,DIRUT
232 . I 'Y D Q:$D(DIRUT)
233 .. S DIR(0)="N^1:"_CNT
234 .. S DIR("A")="Select Entry"
235 .. S DIR("?")="Select an entry to display"
236 .. D ^DIR
237 .. Q
238 . ;
239 . S DTM=$P(@LOG@(Y),"^")
240 . S J=$P(@LOG@(Y),"^",2)
241 . D LOGDET^MHVUL1(.ENTRY,DTM,J)
242 . D LOGDETD(ENTRY)
243 . K @ENTRY
244 . Q
245 K ^TMP("MHV LOG SUMMARY",$J)
246 K ^TMP("MHV LOG DETAIL",$J)
247 Q
248 ;
249LOGSUMD(LOG) ; Display log summary
250 N CNT,DTM,J,N
251 W !!,"LOG SUMMARY"
252 W !,?5,"Entry",?12,"Timestamp",?37,"Job",?50,"Items"
253 S CNT=$P(@LOG,"^",2)
254 I CNT<1 W !!,?12,"EMPTY" Q
255 S Y=0
256 K DIRUT,DTOUT,DUOUT
257 F I=1:1:CNT D Q:Y!$D(DTOUT)!$D(DUOUT)
258 . I I#22=0 D Q:Y!$D(DTOUT)!$D(DUOUT)
259 .. K DIR,X,Y,DIRUT,DTOUT,DUOUT
260 .. S DIR(0)="NO^1:"_CNT
261 .. S DIR("A",1)="Press <RETURN> to see more, '^' to exit, OR"
262 .. S DIR("A")="Select Entry"
263 .. S DIR("?")="Select an entry to display"
264 .. D ^DIR
265 .. Q
266 . S DTM=$$FMTE^XLFDT(-$P(@LOG@(I),"^"))
267 . S J=$P(@LOG@(I),"^",2)
268 . S N=$P(@LOG@(I),"^",3)
269 . W !,?5,I,?12,DTM,?37,J,?50,N
270 . Q
271 Q
272 ;
273LOGDETD(ENTRY) ;Display log entry
274 N CNT,DTM,J,N
275 W !!,"LOG DETAIL"
276 S CNT=$P(@ENTRY,"^",2)
277 I CNT<1 W !,?12,"EMPTY" Q
278 W !,?12,"Timestamp",?37,"Job",?50,"Items",?60,"Nodes"
279 S DTM=$$FMTE^XLFDT(-$P(@ENTRY@(0),"^"))
280 S J=$P(@ENTRY@(0),"^",2)
281 S N=$P(@ENTRY@(0),"^",3)
282 W !,?12,DTM,?37,J,?50,N,?60,CNT
283 S J=3
284 F I=1:1:CNT D Q:$D(DIRUT)
285 . S J=($L(@ENTRY@(I))+5)\80+1+J
286 . I J>23 D Q:$D(DIRUT)
287 .. K DIR,X,Y,DIRUT
288 .. S DIR(0)="E"
289 .. D ^DIR
290 .. S J=($L(@ENTRY@(I))+5)\80+1
291 .. Q
292 . W !,?5,@ENTRY@(I)
293 . Q
294 ;
295 Q:$D(DIRUT)
296 K DIR,X,Y,DIRUT
297 S DIR(0)="E"
298 D ^DIR
299 Q
300 ;
Note: See TracBrowser for help on using the repository browser.