File: syslogstream.yo

package info (click to toggle)
bobcat 6.02.02-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 13,960 kB
  • sloc: cpp: 18,954; fortran: 5,617; makefile: 2,787; sh: 659; perl: 401; ansic: 26
file content (288 lines) | stat: -rw-r--r-- 11,471 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
includefile(include/header)

COMMENT(manpage, section, releasedate, archive, short name)
manpage(FBB::SyslogStream)(3bobcat)(_CurYrs_)(libbobcat-dev__CurVers_)
                    (Output Stream for Syslog)

manpagename(FBB::SyslogStream)(An output stream inserting syslog messages)

manpagesynopsis()
    bf(#include <bobcat/syslogstream>)nl()
    Linking option: tt(-lbobcat)

manpagedescription()
    bf(FBB::SyslogStream) objects may be used as a tt(std::ostream) to write
syslog messages using stream facilities.

Multiple separate insertions can be used to create a single syslog message:
the message is only sent to the syslog daemon after receiving a tt(flush)
command (e.g., after inserting tt(std::flush) or tt(std::endl)). Non-printable
characters (like tt('\n')) show up in the syslog message as octal values,
preceded by tt(#) (e.g., tt(#012) for tt('\n')). The newline normally inserted
by tt(std::endl) is ignored: bf(SyslogStream) objects interpret tt(std::endl)
like tt(std::flush).

One series of insertions may contain multiple tt(std::endl) or tt(std::flush)
manipulators. At each of these manipulators a new message is sent to the
syslog daemon, containing all info that has so far been buffered. After
sending a message to the syslog daemon, the bf(SyslogStream)'s internal buffer
is cleared.

includefile(include/namespace)

manpagesection(INHERITS FROM)
    bf(std::ostream)

manpagesection(ENUMERATIONS)

    The following enumerations are defined in the namespace bf(FBB):

    bf(Priority):

        The values of this enumeration match the corresponding priority
tt(LOG_xxx) values used with bf(syslog)(3):
    itemization(
    itb(EMERG)
        system is unusable;
    itb(ALERT)
        action must be taken immediately;
    itb(CRIT)
        critical conditions;
    itb(ERR)
        error conditions;
    itb(WARNING)
        warning conditions;
    itb(NOTICE)
        normal, but significant, condition;
    itb(INFO)
        informational message;
    itb(DEBUG)
        debug-level message;
    )
    The tt(setMask) member (see below) can be used to select which type of
messages will actually be processed by the syslog daemon.

    bf(PriorityType):

        This enumeration has two values fine-tuning the type of messages that
are actually processed by the syslog daemon:
    itemization(
    itb(SINGLE)
        Only messages of the priority specified at the tt(setMask) call are
processed by the syslog daemon;
    itb(UPTO)
        Messages of priority tt(EMERG) up to the the priority specified at the
tt(setMask) call are processed by the syslog daemon;
    )
    By default, the syslog daemon processes all messages it receives.


    bf(Facility):

        The values of this enumeration match the corresponding facility
tt(LOG_xxx) values used with bf(syslog)(3):
    itemization(
    itb(AUTHPRIV)
        security/authorization messages (private)
    itb(CRON)
        clock daemon (tt(cron) and tt(at))
    itb(DAEMON)
        other system daemons
    itb(KERN)
        kernel messages
    itb(LOCAL0)
        reserved for local use. bf(LOCAL1) through bf(LOCAL7) are
        available as well.
    itb(LPR)
        line printer subsystem
    itb(MAIL)
        mail subsystem
    itb(NEWS)
        tt(USENET) news subsystem
    itb(SYSLOGBUF)
        messages generated internally by tt(syslogbufd)
    itb(USER)
        generic user-level messages
    itb(UUCP)
        UUCP subsystem
    )

manpagesection(CONSTRUCTORS)
    itemization(
    itb(SyslogStream(string const &ident = "",
                FBB::Priority priority = FBB::NOTICE,
                FBB::Facility facility = FBB::USER,
                int option = 0))
        This constructor initializes a bf(SyslogStream) object.  The
tt(ident) parameter is usually the name of the program. Its content are
prepended to syslog messages.

The tt(priority) parameter determines the default importance of the message
sent to the syslog daemon. By default messages are sent to the syslog daemon
with priority bf(FBB::NOTICE). Syslog messages may be given different priority
by inserting a bf(SyslogStream) manipulator (see below). The priority set at
construction time may also be modified using the tt(setPriority) and
tt(setDefaultPriority) members.

Which messages actually appear in log facilities is not determined by
the messages' priorities, but by syslog's em(log mask). The log mask can be
set by the static member tt(setMask) (see below).

The tt(facility) parameter determines the type of program doing the
logging. By default bf(FBB::USER) is used.

    The tt(option) parameter may be used to specify various options (use the
binary `tt(bitor)' (`tt(|)') operator to combine options):

       bf(LOG_CONS):
              write directly to system console  if  there  is  an
              error while sending to system logger nl()
       bf(LOG_NDELAY):
              open the connection immediately (normally, the con-
              nection is opened when the first message is logged) nl()
       bf(LOG_PERROR):
              print to stderr as well nl()
       bf(LOG__PID):
              include PID with each message nl()

    By default no options are used.
    )

    Copy and move constructors (and assignment operators) are not available.

manpagesection(MEMBER FUNCTIONS)

     All members of bf(std::ostream) are available, as bf(FBB::SyslogStream)
inherits from this class.

    itemization(
    itb(void close())
       If the bf(SyslogStream)'s internal buffer is not empty it is flushed to
        the syslog daemon. Thereafer bf(closelog)(3) is called.
    itb(Priority defaultPriority() const)
       Returns the current default priority. I.e., the priority that will be
        used for the messages after inserting tt(endl) or tt(flush).
    itb(void open(string const &ident,
                FBB::Priority priority = FBB::NOTICE,
                FBB::Facility facility = FBB::USER,
                int option = 0))
       Redefines the current identifier, priority, facility and options that
        are used when sending messages to the syslog daemon. If the
        bf(SyslogStream)'s internal buffer is not empty it is first flushed to
        the syslog daemon using the identifier, priority and options that were
        active just before calling tt(open).
    itb(Priority priority() const)
       Returns the next priority. I.e., the priority that will be used for
        the next message that is sent to the syslog daemon.
    itb(Priority setDefaultPriority(Priority priority))
       Changes the default priority of the next message that is sent to the
        syslog daemon after inserting tt(std::eoln) or
        tt(std::flush). The previously active default priority is
        returned.
    itb(Priority setPriority(Priority priority)) Changes the priority for the
        next message that is sent to the syslog daemon after inserting
        tt(std::eoln) or tt(std::flush). Subsequent messages will again use
        the default priority. The previously active priority setting is
        returned.
    )

manpagesection(STATIC MEMBER FUNCTIONS)

    itemization(
    itb(Priority setMask(Priority priority, PriorityMask upTo))
       Syslog messages of (if tt(upTo) equals tt(SINGLE)) or up to (if
        tt(upTo) equals tt(UPTO)) the indicated priority are processed by the
        syslog daemon.
    itb(Priority setMask(Priority priority, Priority ...priorities))
       Syslog messages of the priorities passed to tt(setMask) are processed
        by the syslog daemon. At least one priority must be specified.
    itb(Facility stoF(std::string const &name, Facility facility = USER))
       Returns the facility matching the name of the facility provided by
        tt(name). Facility matching is performed case insensitively. E.g., if
        tt(name) contains tt(daemon), facility tt(FBB::DAEMON) is returned. If
        tt(name) does not match any facility name then the value of this
        function's second argument is returned. The function's name (tt(stoF))
        was used in analogy of the various tt(sto...) conversion functions
        that were made available by the bf(C++11) standard.
    itb(Priority stoP(std::string const &name, Priority priority = NOTICE))
       Returns the priority matching the name of the priority provided by
        tt(name). Priority matching is performed case insensitively. E.g., if
        tt(name) contains tt(emerg), priority tt(FBB::EMERG) is returned. If
        tt(name) does not match any priority name then the value of this
        function's second argument is returned. The function's name (tt(stoP))
        was used in analogy of the various tt(sto...) conversion functions
        that were made available by the bf(C++11) standard.
    )

manpagesection(MANIPULATORS)

    The following set of manipulators are all defined as (static) members.
They may be inserted into an bf(FBB::SyslogStream) object. Except for the last
manipulator (tt(strerrno)), they have the following characteristics in common:
    itemization(
    it() They change the priority of the messages that are subsequently
inserted by the bf(FBB::SyslogStream) object, thus acting like a separate
tt(setPriority) call.
    it() When inserting multiple manipulators before the inserted message is
flushed (e.g., using the tt(std::flush) or the tt(std::endl) manipulators) the
last inserted bf(FBB::SyslogStream) manipulator will be used.
    it() If the manipulators are not inserted into an
bf(FBB::SyslogStream) object (but in another tt(std::ostream) type of object)
then they perform no action.
    )

    Here are the available manipulators:
    itemization(
    itb(SyslogStream::alert)
        Messages are inserted with priority bf(FBB::ALERT).
    itb(SyslogStream::crit)
        Message are inserted with priority bf(FBB::CRIT).
    itb(SyslogStream::debug)
        Messages are inserted with priority bf(FBB::DEBUG).
    itb(SyslogStream::emerg)
        Messages are inserted with priority bf(FBB::EMERG).
    itb(SyslogStream::err)
        Messages are inserted with priority bf(FBB::ERR).
    itb(SyslogStream::info)
        Messages are inserted with priority bf(FBB::INFO).
    itb(SyslogStream::notice)
        Messages are inserted with priority bf(FBB::NOTICE).
    itb(SyslogStream::strerrno)
       This manipulator inserts the textual interpretation of tt(std::errno)'s
        current value into a tt(std::ostream). Note that, different from the
        other manipulators, the object into which this manipulator is inserted
        does not have to be a bf(FBB::SyslogStream) object.
    itb(SyslogStream::warning)
        Messages are inserted with priority bf(FBB::WARNING).
    )

manpagesection(EXAMPLE)
    verb(
#include <bobcat/syslogstream>

using namespace std;
using namespace FBB;

int main(int argc, char **argv)
{
    SyslogStream sls(argv[0]);

    sls << SyslogStream::debug << "Hello world" << flush <<
           SyslogStream::strerrno << endl;
}
    )

manpagefiles()
    em(bobcat/syslogstream) - defines the class interface

manpageseealso()
    bf(bobcat)(7), bf(closelog)(3), bf(openlog)(3), bf(rsyslogd)(8),
        bf(syslog)(3), bf(syslogbuf)(3bobcat)

manpagebugs()
    The constructor's tt(option) parameter is an tt(int). Because of this,
tt(int) values rather than enumeration values are passed to the
constructor. It is the responsibility of the programmer to pass defined option
values only.

includefile(include/trailer)