[go: up one dir, main page]

File: Slog.3cc

package info (click to toggle)
libcommoncpp2 1.0.13-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,740 kB
  • ctags: 2,860
  • sloc: cpp: 18,857; sh: 8,451; ansic: 1,546; makefile: 299; xml: 5
file content (295 lines) | stat: -rw-r--r-- 8,034 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
.TH "Slog" 3 "19 Jul 2003" "CommonC++" \" -*- nroff -*-
.ad l
.nh
.SH NAME
Slog \- The slog class is used to stream messages to the system's logging facility (syslogd). system logging facility class. 
.SH SYNOPSIS
.br
.PP
\fC#include <slog.h>\fP
.PP
.SS "Public Types"

.in +1c
.ti -1c
.RI "typedef enum Slog::Class \fBClass\fP"
.br
.ti -1c
.RI "typedef enum Slog::Level \fBLevel\fP"
.br
.ti -1c
.RI "enum \fBClass\fP { \fBclassSecurity\fP, \fBclassAudit\fP, \fBclassDaemon\fP, \fBclassUser\fP, \fBclassDefault\fP, \fBclassLocal0\fP, \fBclassLocal1\fP, \fBclassLocal2\fP, \fBclassLocal3\fP, \fBclassLocal4\fP, \fBclassLocal5\fP, \fBclassLocal6\fP, \fBclassLocal7\fP }"
.br
.ti -1c
.RI "enum \fBLevel\fP { \fBlevelEmergency\fP =  1, \fBlevelAlert\fP, \fBlevelCritical\fP, \fBlevelError\fP, \fBlevelWarning\fP, \fBlevelNotice\fP, \fBlevelInfo\fP, \fBlevelDebug\fP }"
.br
.in -1c
.SS "Public Methods"

.in +1c
.ti -1c
.RI "\fBSlog\fP (void)"
.br
.RI "\fIDefault (and only) constructor.\fP"
.ti -1c
.RI "virtual \fB~Slog\fP (void)"
.br
.ti -1c
.RI "void \fBclose\fP (void)"
.br
.ti -1c
.RI "void \fBopen\fP (const char *ident, \fBClass\fP grp=classUser)"
.br
.RI "\fI(re)opens the output stream.\fP"
.ti -1c
.RI "Slog & \fBoperator()\fP (const char *ident, \fBClass\fP grp=classUser, \fBLevel\fP level=levelError)"
.br
.RI "\fISets the log identifier, level, and class to use for subsequent output.\fP"
.ti -1c
.RI "Slog & \fBoperator()\fP (\fBLevel\fP level, \fBClass\fP grp=classDefault)"
.br
.RI "\fIChanges the log level and class to use for subsequent output.\fP"
.ti -1c
.RI "Slog & \fBoperator()\fP (void)"
.br
.RI "\fIDoes nothing except return *this.\fP"
.ti -1c
.RI "void \fBlevel\fP (\fBLevel\fP enable)"
.br
.RI "\fISets the logging level.\fP"
.ti -1c
.RI "void \fBclogEnable\fP (bool f=true)"
.br
.RI "\fIEnables or disables the echoing of the messages to clog in addition to the syslog daemon.\fP"
.ti -1c
.RI "Slog & \fBwarn\fP (void)"
.br
.ti -1c
.RI "Slog & \fBerror\fP (void)"
.br
.ti -1c
.RI "Slog & \fBdebug\fP (void)"
.br
.ti -1c
.RI "Slog & \fBemerg\fP (void)"
.br
.ti -1c
.RI "Slog & \fBalert\fP (void)"
.br
.ti -1c
.RI "Slog & \fBcritical\fP (void)"
.br
.ti -1c
.RI "Slog & \fBnotice\fP (void)"
.br
.ti -1c
.RI "Slog & \fBinfo\fP (void)"
.br
.in -1c
.SS "Protected Methods"

.in +1c
.ti -1c
.RI "int \fBoverflow\fP (int c)"
.br
.RI "\fIThis is the streambuf function that actually outputs the data to the device.\fP"
.in -1c
.SH "DETAILED DESCRIPTION"
.PP 
The slog class is used to stream messages to the system's logging facility (syslogd). system logging facility class.
.PP
A default \fCslog\fP object is used to avoid confusion with the native syslog facility and to imply a logical relationship to the C++ \fCclog()\fP.
.PP
The key difference is that the \fCslog\fP object sends it's output to the system logging daemon (typically syslogd) rather than through stderr. \fCslog\fP can be streamed with the \fC<<\fP operator just like \fCclog\fP; a default slog object is pre-initialized, and you stream character data to it.
.PP
The \fCslog\fP allows one to specify logging levels and other properties through the \fC()\fP operators. Hence, once can do:
.PP
\fC.nf

 slog('mydaemon', SLOG_DAEMON, SLOG_EMERGENCY) << I just died << endl; 
.fi
\fP
.PP
or things like:
.PP
\fC.nf

 slog('mydaemon', SLOG_DAEMON); 
 slog(SLOG_INFO) << 'daemon initalized' << endl; 
.fi
\fP
.PP
The intent is to be as common-place and as convenient to use as the stderr based clog facility found in C++, and this is especially useful for C++ daemons.
.PP
The \fCstd::flush\fP manipulator doesn't work. Either the \fCstd::endl\fP or \fCstd::ends\fP manipulators must be used to cause the output to be sent to the daemon.
.PP
When this class is used on a system that doesn't have the syslog headers (i.e. a non-posix win32 box), the output goes to the a file with the same name as the syslog identifier string with '.log' appended to it. If the identifier string ends in '.exe', the '.exe' is removed before the '.log' is appened. (e.g. the identifier foo.exe will generate a log file named foo.log)
.PP
\fBAuthor: \fP
.in +1c
David Sugar <dyfet@ostel.com> 
.br
Minor docs & hacks by Jon Little <littlej@arlut.utexas.edu> 
.PP
.SH "MEMBER TYPEDEF DOCUMENTATION"
.PP 
.SS "typedef enum Slog::Class  Slog::Class"
.PP
.SS "typedef enum Slog::Level  Slog::Level"
.PP
.SH "MEMBER ENUMERATION DOCUMENTATION"
.PP 
.SS "enum Slog::Class"
.PP
\fBEnumeration values: \fP
.in +1c
.TP
\fB\fI\fIclassSecurity\fP \fP\fP
.TP
\fB\fI\fIclassAudit\fP \fP\fP
.TP
\fB\fI\fIclassDaemon\fP \fP\fP
.TP
\fB\fI\fIclassUser\fP \fP\fP
.TP
\fB\fI\fIclassDefault\fP \fP\fP
.TP
\fB\fI\fIclassLocal0\fP \fP\fP
.TP
\fB\fI\fIclassLocal1\fP \fP\fP
.TP
\fB\fI\fIclassLocal2\fP \fP\fP
.TP
\fB\fI\fIclassLocal3\fP \fP\fP
.TP
\fB\fI\fIclassLocal4\fP \fP\fP
.TP
\fB\fI\fIclassLocal5\fP \fP\fP
.TP
\fB\fI\fIclassLocal6\fP \fP\fP
.TP
\fB\fI\fIclassLocal7\fP \fP\fP

.SS "enum Slog::Level"
.PP
\fBEnumeration values: \fP
.in +1c
.TP
\fB\fI\fIlevelEmergency\fP \fP\fP
.TP
\fB\fI\fIlevelAlert\fP \fP\fP
.TP
\fB\fI\fIlevelCritical\fP \fP\fP
.TP
\fB\fI\fIlevelError\fP \fP\fP
.TP
\fB\fI\fIlevelWarning\fP \fP\fP
.TP
\fB\fI\fIlevelNotice\fP \fP\fP
.TP
\fB\fI\fIlevelInfo\fP \fP\fP
.TP
\fB\fI\fIlevelDebug\fP \fP\fP

.SH "CONSTRUCTOR & DESTRUCTOR DOCUMENTATION"
.PP 
.SS "Slog::Slog (void)"
.PP
Default (and only) constructor.
.PP
The default log level is set to SLOG_DEBUG. There is no default log facility set. One should be set before attempting any output. This is done by the \fC\fBopen()\fP\fP or the \fC\fBoperator()(const char *, Class, Level)\fP\fP functions. 
.SS "virtual Slog::~Slog (void)\fC [virtual]\fP"
.PP
.SH "MEMBER FUNCTION DOCUMENTATION"
.PP 
.SS "Slog& Slog::alert (void)\fC [inline]\fP"
.PP
.SS "void Slog::clogEnable (bool f = true)\fC [inline]\fP"
.PP
Enables or disables the echoing of the messages to clog in addition to the syslog daemon.
.PP
This is enabled by the default class constructor. 
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIf\fP\fP
true to enable, false to disable clog output 
.SS "void Slog::close (void)"
.PP
.SS "Slog& Slog::critical (void)\fC [inline]\fP"
.PP
.SS "Slog& Slog::debug (void)\fC [inline]\fP"
.PP
.SS "Slog& Slog::emerg (void)\fC [inline]\fP"
.PP
.SS "Slog& Slog::error (void)\fC [inline]\fP"
.PP
.SS "Slog& Slog::info (void)\fC [inline]\fP"
.PP
.SS "void Slog::level (\fBLevel\fP enable)\fC [inline]\fP"
.PP
Sets the logging level.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIenable\fP\fP
is the logging level to use for further output 
.SS "Slog& Slog::notice (void)\fC [inline]\fP"
.PP
.SS "void Slog::open (const char * ident, \fBClass\fP grp = classUser)"
.PP
(re)opens the output stream.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIident\fP\fP
The identifier portion of the message sent to the syslog daemon. 
.TP
\fB\fIgrp\fP\fP
The log facility the message is sent to 
.SS "Slog& Slog::operator() (void)"
.PP
Does nothing except return *this.
.PP
.SS "Slog& Slog::operator() (\fBLevel\fP level, \fBClass\fP grp = classDefault)"
.PP
Changes the log level and class to use for subsequent output.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIlevel\fP\fP
The log level of the message 
.TP
\fB\fIgrp\fP\fP
The log facility the message is sent to 
.SS "Slog& Slog::operator() (const char * ident, \fBClass\fP grp = classUser, \fBLevel\fP level = levelError)"
.PP
Sets the log identifier, level, and class to use for subsequent output.
.PP
\fBParameters: \fP
.in +1c
.TP
\fB\fIident\fP\fP
The identifier portion of the message 
.TP
\fB\fIgrp\fP\fP
The log facility the message is sent to 
.TP
\fB\fIlevel\fP\fP
The log level of the message 
.SS "int Slog::overflow (int c)\fC [protected]\fP"
.PP
This is the streambuf function that actually outputs the data to the device.
.PP
Since all output should be done with the standard ostream operators, this function should never be called directly. 
.SS "Slog& Slog::warn (void)\fC [inline]\fP"
.PP


.SH "AUTHOR"
.PP 
Generated automatically by Doxygen for CommonC++ from the source code.