Commit | Line | Data |
---|---|---|
2596a09e WJ |
1 | /* logger.h - logging routines */ |
2 | ||
3 | /* | |
4 | * $Header: /f/osi/h/RCS/logger.h,v 7.4 91/02/22 09:24:46 mrose Interim $ | |
5 | * | |
6 | * | |
7 | * $Log: logger.h,v $ | |
8 | * Revision 7.4 91/02/22 09:24:46 mrose | |
9 | * Interim 6.8 | |
10 | * | |
11 | * Revision 7.3 90/12/23 18:41:49 mrose | |
12 | * update | |
13 | * | |
14 | * Revision 7.2 90/11/21 11:32:07 mrose | |
15 | * sun | |
16 | * | |
17 | * Revision 7.1 90/07/01 21:03:49 mrose | |
18 | * pepsy | |
19 | * | |
20 | * Revision 7.0 89/11/23 21:55:48 mrose | |
21 | * Release 6.0 | |
22 | * | |
23 | */ | |
24 | ||
25 | /* | |
26 | * NOTICE | |
27 | * | |
28 | * Acquisition, use, and distribution of this module and related | |
29 | * materials are subject to the restrictions of a license agreement. | |
30 | * Consult the Preface in the User's Manual for the full terms of | |
31 | * this agreement. | |
32 | * | |
33 | */ | |
34 | ||
35 | ||
36 | #ifndef _LOGGER_ | |
37 | #define _LOGGER_ | |
38 | ||
39 | #include "manifest.h" | |
40 | ||
41 | /* \f */ | |
42 | ||
43 | typedef struct ll_struct { | |
44 | char *ll_file; /* path name to logging file */ | |
45 | ||
46 | char *ll_hdr; /* text to put in opening line */ | |
47 | char *ll_dhdr; /* dynamic header - changes */ | |
48 | ||
49 | int ll_events; /* interesting events */ | |
50 | #define LLOG_NONE 0 | |
51 | #define LLOG_FATAL 0x01 /* fatal errors */ | |
52 | #define LLOG_EXCEPTIONS 0x02 /* exceptional events */ | |
53 | #define LLOG_NOTICE 0x04 /* informational notices */ | |
54 | #define LLOG_PDUS 0x08 /* PDU printing */ | |
55 | #define LLOG_TRACE 0x10 /* program tracing */ | |
56 | #define LLOG_DEBUG 0x20 /* full debugging */ | |
57 | #define LLOG_ALL 0xff | |
58 | #define LLOG_MASK \ | |
59 | "\020\01FATAL\02EXCEPTIONS\03NOTICE\04PDUS\05TRACE\06DEBUG" | |
60 | ||
61 | int ll_syslog; /* interesting events to send to syslog */ | |
62 | /* takes same values as ll_events */ | |
63 | ||
64 | int ll_msize; /* max size for log, in Kbytes */ | |
65 | ||
66 | int ll_stat; /* assorted switches */ | |
67 | #define LLOGNIL 0x00 | |
68 | #define LLOGCLS 0x01 /* keep log closed, except when writing */ | |
69 | #define LLOGCRT 0x02 /* create log if necessary */ | |
70 | #define LLOGZER 0x04 /* truncate log when limits reached */ | |
71 | #define LLOGERR 0x08 /* log closed due to (soft) error */ | |
72 | #define LLOGTTY 0x10 /* also log to stderr */ | |
73 | #define LLOGHDR 0x20 /* static header allocated */ | |
74 | #define LLOGDHR 0x40 /* dynamic header allocated */ | |
75 | ||
76 | int ll_fd; /* file descriptor */ | |
77 | } LLog; | |
78 | ||
79 | /* \f */ | |
80 | ||
81 | #define SLOG(lp,event,what,args) \ | |
82 | if (lp -> ll_events & (event)) { \ | |
83 | (void) ll_log (lp, event, what, "%s", ll_preset args); \ | |
84 | } \ | |
85 | else | |
86 | ||
87 | #ifndef LLOG | |
88 | #define LLOG(lp,event,args) SLOG (lp, event, NULLCP, args) | |
89 | #endif | |
90 | ||
91 | #ifdef DEBUG | |
92 | #define DLOG(lp,event,args) SLOG (lp, event, NULLCP, args) | |
93 | #else | |
94 | #define DLOG(lp,event,args) | |
95 | #endif | |
96 | ||
97 | ||
98 | #ifdef DEBUG | |
99 | ||
100 | #ifdef PEPSY_VERSION | |
101 | ||
102 | #ifdef __STDC__ | |
103 | ||
104 | #define PLOGP(lp,args,pe,text,rw) \ | |
105 | if ((lp) -> ll_events & LLOG_PDUS) { \ | |
106 | pvpdu (lp, print_##args##_P, pe, text, rw); \ | |
107 | } \ | |
108 | else | |
109 | ||
110 | #define PLOG(lp,fnx,pe,text,rw) \ | |
111 | if ((lp) -> ll_events & LLOG_PDUS) { \ | |
112 | pvpdu (lp, fnx##_P, pe, text, rw); \ | |
113 | } \ | |
114 | else | |
115 | ||
116 | #else | |
117 | ||
118 | #define PLOGP(lp,args,pe,text,rw) \ | |
119 | if ((lp) -> ll_events & LLOG_PDUS) { \ | |
120 | pvpdu (lp, print_/* */args/* */_P, pe, text, rw); \ | |
121 | } \ | |
122 | else | |
123 | ||
124 | #define PLOG(lp,fnx,pe,text,rw) \ | |
125 | if ((lp) -> ll_events & LLOG_PDUS) { \ | |
126 | pvpdu (lp, fnx/* */_P, pe, text, rw); \ | |
127 | } \ | |
128 | else | |
129 | ||
130 | #endif | |
131 | ||
132 | #else /* !PEPSY_VERSION */ | |
133 | ||
134 | #define PLOG(lp,fnx,pe,text,rw) \ | |
135 | if ((lp) -> ll_events & LLOG_PDUS) { \ | |
136 | vpdu (lp, fnx, pe, text, rw); \ | |
137 | } \ | |
138 | else | |
139 | ||
140 | #endif /* !PEPSY_VERSION */ | |
141 | ||
142 | #ifdef lint | |
143 | #undef PLOGP | |
144 | ||
145 | #define PLOGP(lp,args,pe,text,rw) \ | |
146 | if ((lp) -> ll_events & LLOG_PDUS) { \ | |
147 | _pvpdu (lp, pe, text, rw); \ | |
148 | } \ | |
149 | else | |
150 | ||
151 | #define pvpdu(lp,cookie,pe,text,rw) \ | |
152 | _pvpdu(lp, pe, text, rw) | |
153 | #endif | |
154 | ||
155 | #else /* !DEBUG */ | |
156 | #define PLOG(lp,fnx,pe,text,rw) | |
157 | #define PLOGP(lp,args,pe,text,rw) | |
158 | #endif | |
159 | ||
160 | ||
161 | int ll_open (); | |
162 | int ll_log (), _ll_log (); | |
163 | int ll_close (); | |
164 | ||
165 | void ll_hdinit (); | |
166 | void ll_dbinit (); | |
167 | ||
168 | int ll_printf (); | |
169 | int ll_sync (); | |
170 | ||
171 | char *ll_preset (); | |
172 | ||
173 | int ll_check (); | |
174 | ||
175 | int ll_defmhdr (); | |
176 | IFP ll_setmhdr (); | |
177 | #endif |