Update NEWS for 1.6.22
[pkg-k5-afs_openafs.git] / src / WINNT / client_osi / osilog.h
blob00ba7188283083e16b7e7a6bffd79236be012314
1 /*
2 * Copyright (C) 1998, 1989 Transarc Corporation - All rights reserved
4 * (C) COPYRIGHT IBM CORPORATION 1987, 1988
5 * LICENSED MATERIALS - PROPERTY OF IBM
7 */
9 #ifndef _OSI_LOG_H__
10 #define _OSI_LOG_H__ 1
12 #include "osi.h"
13 #include "osisleep.h"
14 #include "osibasel.h"
15 #include "osistatl.h"
16 #include "osifd.h"
17 #include "osiqueue.h"
19 #define OSI_LOG_DEFAULTSIZE 1000
20 #define OSI_LOG_STRINGSIZE 256
21 #define OSI_LOG_MAXPARMS 5 /* max # of int parms */
23 typedef struct osi_logEntry {
24 size_t tid; /* thread ID */
25 unsigned long micros; /* microsecond-based time stamp */
26 char *formatp; /* format string */
27 size_t parms[OSI_LOG_MAXPARMS]; /* parms */
28 } osi_logEntry_t;
30 typedef struct osi_log {
31 osi_queue_t q; /* queue of all logs */
32 char *namep; /* name */
33 long alloc; /* allocated size */
34 long nused; /* number currently in use */
35 long first; /* index of first entry */
36 Crit_Sec cs; /* use this, rather than a higher-level
37 * lock, so we can log stuff from
38 * osi lock pkg */
39 osi_logEntry_t *datap; /* data for the log */
40 int stringindex; /* where to put new strings */
41 int maxstringindex; /* size of string array */
42 char (*stringsp)[OSI_LOG_STRINGSIZE]; /* string array */
43 int enabled; /* true if enabled */
44 } osi_log_t;
46 typedef struct osi_logFD {
47 osi_fd_t fd; /* FD header */
48 osi_log_t *logp; /* logp */
49 long first; /* first index at time we started */
50 long nused; /* nused at tiem we started */
51 long current; /* counter we're at */
52 } osi_logFD_t;
54 extern long osi_logSize;
56 extern osi_log_t *osi_LogCreate(char *, size_t);
58 extern void osi_LogFree(osi_log_t *);
60 extern void osi_LogAdd(osi_log_t *, char *, size_t, size_t, size_t, size_t, size_t);
62 extern void osi_LogReset(osi_log_t *);
64 extern long osi_LogFDCreate(osi_fdType_t *, osi_fd_t **);
66 extern long osi_LogFDGetInfo(osi_fd_t *, osi_remGetInfoParms_t *);
68 extern long osi_LogFDClose(osi_fd_t *);
70 extern void osi_LogEnable(osi_log_t *);
72 extern void osi_LogDisable(osi_log_t *);
74 extern void osi_LogPanic(char *msgp, char *filep, size_t line);
76 extern void osi_LogPrint(osi_log_t *logp, FILE_HANDLE handle);
78 extern wchar_t *osi_LogSaveStringW(osi_log_t *logp, wchar_t *s);
79 extern char *osi_LogSaveString(osi_log_t *logp, char *s);
80 extern void osi_InitTraceOption();
81 extern void osi_LogEvent0(char *a,char *b);
82 extern void osi_LogEvent(char *a,char *b,char *c,...);
83 extern char *osi_HexifyString(char *s);
85 /* define macros */
86 #define osi_Log0(l,f) do { if ((l) && (l)->enabled) osi_LogAdd((l), (f), 0, 0, 0, 0, 0); } while(0)
87 #define osi_Log1(l,f,a) do { if ((l) && (l)->enabled) osi_LogAdd((l), (f), (size_t) (a), 0, 0, 0, 0); } while(0)
88 #define osi_Log2(l,f,a,b) do { if ((l) && (l)->enabled) osi_LogAdd((l), (f), (size_t) (a), (size_t) (b), 0, 0, 0); } while(0)
89 #define osi_Log3(l,f,a,b,c) do { if ((l) && (l)->enabled) osi_LogAdd((l), (f), (size_t) (a), (size_t) (b), (size_t) (c), 0, 0); } while(0)
90 #define osi_Log4(l,f,a,b,c,d) do { if ((l) && (l)->enabled) osi_LogAdd((l), (f), (size_t) (a), (size_t) (b), (size_t) (c), (size_t) (d), 0); } while(0)
91 #define osi_Log5(l,f,a,b,c,d,e) do { if ((l) && (l)->enabled) osi_LogAdd((l), (f), (size_t) (a), (size_t) (b), (size_t) (c), (size_t) (d), (size_t) (e)); } while(0)
93 #ifdef DEBUG_VERBOSE
94 #define DEBUG_EVENT1(a,b,c) {HANDLE h; char *ptbuf[1],buf[132];\
95 h = RegisterEventSource(NULL, a);\
96 sprintf(buf, b,c);\
97 ptbuf[0] = buf;\
98 ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL);\
99 DeregisterEventSource(h);}
100 #define DEBUG_EVENT0(a) {HANDLE h; char *ptbuf[1];\
101 h = RegisterEventSource(NULL, a);\
102 ptbuf[0] = "";\
103 ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0,(const char **) ptbuf, NULL);\
104 DeregisterEventSource(h);}
105 #define DEBUG_EVENT2(a,b,c,d) {HANDLE h; char *ptbuf[1],buf[132];\
106 h = RegisterEventSource(NULL, a);\
107 sprintf(buf, b,c,d);\
108 ptbuf[0] = buf;\
109 ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0,(const char **) ptbuf, NULL);\
110 DeregisterEventSource(h);}
111 #define DEBUG_EVENT3(a,b,c,d,e) {HANDLE h; char *ptbuf[1],buf[132];\
112 h = RegisterEventSource(NULL, a);\
113 sprintf(buf, b,c,d,e);\
114 ptbuf[0] = buf;\
115 ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0,(const char **)ptbuf, NULL);\
116 DeregisterEventSource(h);}
117 #define DEBUG_EVENT4(a,b,c,d,e,f) {HANDLE h; char *ptbuf[1],buf[132];\
118 h = RegisterEventSource(NULL, a);\
119 sprintf(buf, b,c,d,e,f);\
120 ptbuf[0] = buf;\
121 ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0,(const char **) ptbuf, NULL);\
122 DeregisterEventSource(h);}
123 #define DEBUG_EVENT5(a,b,c,d,e,f,g) {HANDLE h; char *ptbuf[1],buf[132];\
124 h = RegisterEventSource(NULL, a);\
125 sprintf(buf, b,c,d,e,f,g);\
126 ptbuf[0] = buf;\
127 ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0,(const char **) ptbuf, NULL);\
128 DeregisterEventSource(h);}
129 #define DEBUG_EVENT6(a,b,c,d,e,f,g,h) {HANDLE h; char *ptbuf[1],buf[132];\
130 h = RegisterEventSource(NULL, a);\
131 sprintf(buf,b,c,d,e,f,g,h);\
132 ptbuf[0] = buf;\
133 ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0,(const char **) ptbuf, NULL);\
134 DeregisterEventSource(h);}
135 #else
136 #define DEBUG_EVENT0(a)
137 #define DEBUG_EVENT1(a,b,c)
138 #define DEBUG_EVENT2(a,b,c,d)
139 #define DEBUG_EVENT3(a,b,c,d,e)
140 #define DEBUG_EVENT4(a,b,c,d,e,f)
141 #define DEBUG_EVENT5(a,b,c,d,e,f,g)
142 #define DEBUG_EVENT6(a,b,c,d,e,f,g,h)
143 #endif
145 #endif /* _OSI_LOG_H__ */