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
|
includefile(include/header)
COMMENT(manpage, section, releasedate, archive, short name)
manpage(FBB::SyslogBuf)(3bobcat)(_CurYrs_)(libbobcat-dev__CurVers_)
(Stream Buffer for Syslog)
manpagename(FBB::SyslogBuf)(A streambuf object inserting syslog messages)
manpagesynopsis()
bf(#include <bobcat/syslogbuf>)nl()
Linking option: tt(-lbobcat)
manpagedescription()
Addresses of bf(FBB::SyslogBuf) objects can be passed as
bf(std::streambuf) addresses to tt(std::ostream) objects to write messages to
the syslog daemon 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)
tt(FBB::EoiBuf) and thus from tt(std::streambuf)
manpagesection(ENUMERATIONS)
The following enumerations are defined in the namespace bf(FBB):
bf(Priority):
The values of this enumeration match the corresponding priority
bf(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;
)
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
bf(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(CONSTRUCTOR)
itemization(
itb(SyslogBuf(string const &ident = "",
FBB::Priority priority = FBB::NOTICE,
FBB::Facility facility = FBB::USER,
int option = 0))
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)(3bobcat) manipulator. 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::streambuf) are available, as bf(FBB::SyslogBuf)
inherits from this class.
itemization(
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 eoi())
If the bf(SyslogStream)'s internal buffer is not empty it is flushed to
the syslog daemon. Thereafer bf(closelog)(3) is called. Instead
of using this member the tt(eoi) manipulator can also be used.
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(void reset(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 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(MANIPULATOR)
itemization(
itb(FBB::eoi)
The tt(eoi) manipulator can be inserted into the tt(ostream) instead
of calling the tt(SyslogBuf::end) member. It performs the same actions as
the tt(eoi) member. If inserted into a plain tt(std::ostream) nothing
happens.
)
manpagesection(EXAMPLE)
See also bf(syslogstream)(3bobcat)
verb(
#include <iostream>
#include <bobcat/syslogstream>
using namespace std;
using namespace FBB;
int main(int argc, char **argv)
{
ostream sls(new SyslogBuf(argv[0]));
sls << SyslogStream::debug << "Hello world" << flush <<
SyslogStream::strerrno << endl;
}
)
manpagefiles()
em(bobcat/syslogbuf) - defines the class interface
manpageseealso()
bf(bobcat)(7), bf(closelog)(3), bf(openlog)(3), bf(rsyslogd)(8)
bf(syslog)(3), bf(syslogstream)(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)
|