OpenAFS
OpenAFS distributed network file system
|
00001 /* 00002 * Copyright (C) 1998, 1989 Transarc Corporation - All rights reserved 00003 * 00004 * (C) COPYRIGHT IBM CORPORATION 1987, 1988 00005 * LICENSED MATERIALS - PROPERTY OF IBM 00006 * 00007 */ 00008 00009 #ifndef _OSI_LOG_H__ 00010 #define _OSI_LOG_H__ 1 00011 00012 #include "osi.h" 00013 #include "osisleep.h" 00014 #include "osibasel.h" 00015 #include "osistatl.h" 00016 #include "osifd.h" 00017 #include "osiqueue.h" 00018 00019 #define OSI_LOG_DEFAULTSIZE 1000 00020 #define OSI_LOG_STRINGSIZE 256 00021 #define OSI_LOG_MAXPARMS 5 /* max # of int parms */ 00022 00023 typedef struct osi_logEntry { 00024 size_t tid; /* thread ID */ 00025 unsigned long micros; /* microsecond-based time stamp */ 00026 char *formatp; /* format string */ 00027 size_t parms[OSI_LOG_MAXPARMS]; /* parms */ 00028 } osi_logEntry_t; 00029 00030 typedef struct osi_log { 00031 osi_queue_t q; /* queue of all logs */ 00032 char *namep; /* name */ 00033 long alloc; /* allocated size */ 00034 long nused; /* number currently in use */ 00035 long first; /* index of first entry */ 00036 Crit_Sec cs; /* use this, rather than a higher-level 00037 * lock, so we can log stuff from 00038 * osi lock pkg */ 00039 osi_logEntry_t *datap; /* data for the log */ 00040 int stringindex; /* where to put new strings */ 00041 int maxstringindex; /* size of string array */ 00042 char (*stringsp)[OSI_LOG_STRINGSIZE]; /* string array */ 00043 int enabled; /* true if enabled */ 00044 } osi_log_t; 00045 00046 typedef struct osi_logFD { 00047 osi_fd_t fd; /* FD header */ 00048 osi_log_t *logp; /* logp */ 00049 long first; /* first index at time we started */ 00050 long nused; /* nused at tiem we started */ 00051 long current; /* counter we're at */ 00052 } osi_logFD_t; 00053 00054 extern long osi_logSize; 00055 00056 extern osi_log_t *osi_LogCreate(char *, size_t); 00057 00058 extern void osi_LogFree(osi_log_t *); 00059 00060 extern void osi_LogAdd(osi_log_t *, char *, size_t, size_t, size_t, size_t, size_t); 00061 00062 extern void osi_DebugAdd(osi_log_t *, char *, size_t, size_t, size_t, size_t, size_t); 00063 00064 extern void osi_LogReset(osi_log_t *); 00065 00066 extern long osi_LogFDCreate(osi_fdType_t *, osi_fd_t **); 00067 00068 extern long osi_LogFDGetInfo(osi_fd_t *, osi_remGetInfoParms_t *); 00069 00070 extern long osi_LogFDClose(osi_fd_t *); 00071 00072 extern void osi_LogEnable(osi_log_t *); 00073 00074 extern void osi_LogDisable(osi_log_t *); 00075 00076 extern void osi_LogPanic(char *msgp, char *filep, size_t line); 00077 00078 extern void osi_LogPrint(osi_log_t *logp, FILE_HANDLE handle); 00079 00080 extern wchar_t *osi_LogSaveStringW(osi_log_t *logp, wchar_t *s); 00081 extern char *osi_LogSaveString(osi_log_t *logp, char *s); 00082 extern void osi_InitTraceOption(); 00083 extern void osi_LogEvent0(char *a,char *b); 00084 extern void osi_LogEvent(char *a,char *b,char *c,...); 00085 extern char *osi_HexifyString(char *s); 00086 00087 /* define macros */ 00088 #define osi_Log0(l,f) do { if ((l) && (l)->enabled) osi_LogAdd((l), (f), 0, 0, 0, 0, 0); } while(0) 00089 #define osi_Log1(l,f,a) do { if ((l) && (l)->enabled) osi_LogAdd((l), (f), (size_t) (a), 0, 0, 0, 0); } while(0) 00090 #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) 00091 #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) 00092 #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) 00093 #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) 00094 00095 #define osi_Debug0(l,f) osi_DebugAdd((l), (f), 0, 0, 0, 0, 0) 00096 #define osi_Debug1(l,f,a) osi_DebugAdd((l), (f), (size_t) (a), 0, 0, 0, 0) 00097 #define osi_Debug2(l,f,a,b) osi_DebugAdd((l), (f), (size_t) (a), (size_t) (b), 0, 0, 0) 00098 #define osi_Debug3(l,f,a,b,c) osi_DebugAdd((l), (f), (size_t) (a), (size_t) (b), (size_t) (c), 0, 0) 00099 #define osi_Debug4(l,f,a,b,c,d) osi_DebugAdd((l), (f), (size_t) (a), (size_t) (b), (size_t) (c), (size_t) (d), 0) 00100 #define osi_Debug5(l,f,a,b,c,d,e) osi_DebugAdd((l), (f), (size_t) (a), (size_t) (b), (size_t) (c), (size_t) (d), (size_t) (e)) 00101 00102 00103 00104 #ifdef DEBUG_VERBOSE 00105 #define DEBUG_EVENT1(a,b,c) {HANDLE h; char *ptbuf[1],buf[132];\ 00106 h = RegisterEventSource(NULL, a);\ 00107 sprintf(buf, b,c);\ 00108 ptbuf[0] = buf;\ 00109 ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0, (const char **)ptbuf, NULL);\ 00110 DeregisterEventSource(h);} 00111 #define DEBUG_EVENT0(a) {HANDLE h; char *ptbuf[1];\ 00112 h = RegisterEventSource(NULL, a);\ 00113 ptbuf[0] = "";\ 00114 ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0,(const char **) ptbuf, NULL);\ 00115 DeregisterEventSource(h);} 00116 #define DEBUG_EVENT2(a,b,c,d) {HANDLE h; char *ptbuf[1],buf[132];\ 00117 h = RegisterEventSource(NULL, a);\ 00118 sprintf(buf, b,c,d);\ 00119 ptbuf[0] = buf;\ 00120 ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0,(const char **) ptbuf, NULL);\ 00121 DeregisterEventSource(h);} 00122 #define DEBUG_EVENT3(a,b,c,d,e) {HANDLE h; char *ptbuf[1],buf[132];\ 00123 h = RegisterEventSource(NULL, a);\ 00124 sprintf(buf, b,c,d,e);\ 00125 ptbuf[0] = buf;\ 00126 ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0,(const char **)ptbuf, NULL);\ 00127 DeregisterEventSource(h);} 00128 #define DEBUG_EVENT4(a,b,c,d,e,f) {HANDLE h; char *ptbuf[1],buf[132];\ 00129 h = RegisterEventSource(NULL, a);\ 00130 sprintf(buf, b,c,d,e,f);\ 00131 ptbuf[0] = buf;\ 00132 ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0,(const char **) ptbuf, NULL);\ 00133 DeregisterEventSource(h);} 00134 #define DEBUG_EVENT5(a,b,c,d,e,f,g) {HANDLE h; char *ptbuf[1],buf[132];\ 00135 h = RegisterEventSource(NULL, a);\ 00136 sprintf(buf, b,c,d,e,f,g);\ 00137 ptbuf[0] = buf;\ 00138 ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0,(const char **) ptbuf, NULL);\ 00139 DeregisterEventSource(h);} 00140 #define DEBUG_EVENT6(a,b,c,d,e,f,g,h) {HANDLE h; char *ptbuf[1],buf[132];\ 00141 h = RegisterEventSource(NULL, a);\ 00142 sprintf(buf,b,c,d,e,f,g,h);\ 00143 ptbuf[0] = buf;\ 00144 ReportEvent(h, EVENTLOG_INFORMATION_TYPE, 0, 0, NULL, 1, 0,(const char **) ptbuf, NULL);\ 00145 DeregisterEventSource(h);} 00146 #else 00147 #define DEBUG_EVENT0(a) 00148 #define DEBUG_EVENT1(a,b,c) 00149 #define DEBUG_EVENT2(a,b,c,d) 00150 #define DEBUG_EVENT3(a,b,c,d,e) 00151 #define DEBUG_EVENT4(a,b,c,d,e,f) 00152 #define DEBUG_EVENT5(a,b,c,d,e,f,g) 00153 #define DEBUG_EVENT6(a,b,c,d,e,f,g,h) 00154 #endif 00155 00156 #endif /* _OSI_LOG_H__ */