.TH "FBB::SyslogBuf" "3bobcat" "2005\-2020" "libbobcat\-dev_5\&.07\&.00" "Stream Buffer for Syslog" .PP .SH "NAME" FBB::SyslogBuf \- A streambuf object inserting syslog messages .PP .SH "SYNOPSIS" \fB#include \fP .br Linking option: \fI\-lbobcat\fP .PP .SH "DESCRIPTION" Addresses of \fBFBB::SyslogBuf\fP objects can be passed as \fBstd::streambuf\fP addresses to \fIstd::ostream\fP objects to write messages to the syslog daemon using stream facilities\&. .PP Multiple separate insertions can be used to create a single syslog message: the message is only sent to the syslog daemon after receiving a \fIflush\fP command (e\&.g\&., after inserting \fIstd::flush\fP or \fIstd::endl\fP)\&. Non\-printable characters (like \fI\(cq\&\en\(cq\&\fP) show up in the syslog message as octal values, preceded by \fI#\fP (e\&.g\&., \fI#012\fP for \fI\(cq\&\en\(cq\&\fP)\&. The newline normally inserted by \fIstd::endl\fP is ignored: \fBSyslogStream\fP objects interpret \fIstd::endl\fP like \fIstd::flush\fP\&. .PP One series of insertions may contain multiple \fIstd::endl\fP or \fIstd::flush\fP 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 \fBSyslogStream\fP\(cq\&s internal buffer is cleared\&. .PP .SH "NAMESPACE" \fBFBB\fP .br All constructors, members, operators and manipulators, mentioned in this man\-page, are defined in the namespace \fBFBB\fP\&. .PP .SH "INHERITS FROM" \fIFBB::EoiBuf\fP and thus from \fIstd::streambuf\fP .PP .SH "ENUMERATIONS" .PP The following enumerations are defined in the namespace \fBFBB\fP: .PP \fBPriority\fP: .PP The values of this enumeration match the corresponding priority \fBLOG_xxx\fP values used with \fBsyslog\fP(3): .IP o \fBEMERG\fP: .br system is unusable; .IP o \fBALERT\fP: .br action must be taken immediately; .IP o \fBCRIT\fP: .br critical conditions; .IP o \fBERR\fP: .br error conditions; .IP o \fBWARNING\fP: .br warning conditions; .IP o \fBNOTICE\fP: .br normal, but significant, condition; .IP o \fBINFO\fP: .br informational message; .IP o \fBDEBUG\fP: .br debug\-level message; .PP \fBPriorityType\fP: .PP This enumeration has two values fine\-tuning the type of messages that are actually processed by the syslog daemon: .IP o \fBSINGLE\fP: .br Only messages of the priority specified at the \fIsetMask\fP call are processed by the syslog daemon; .IP o \fBUPTO\fP: .br Messages of priority \fIEMERG\fP up to the the priority specified at the \fIsetMask\fP call are processed by the syslog daemon; By default, the syslog daemon processes all messages it receives\&. .PP \fBFacility\fP: .PP The values of this enumeration match the corresponding facility \fBLOG_xxx\fP values used with \fBsyslog\fP(3): .IP o \fBAUTHPRIV\fP: .br security/authorization messages (private) .IP o \fBCRON\fP: .br clock daemon (\fIcron\fP and \fIat\fP) .IP o \fBDAEMON\fP: .br other system daemons .IP o \fBKERN\fP: .br kernel messages .IP o \fBLOCAL0\fP: .br reserved for local use\&. \fBLOCAL1\fP through \fBLOCAL7\fP are available as well\&. .IP o \fBLPR\fP: .br line printer subsystem .IP o \fBMAIL\fP: .br mail subsystem .IP o \fBNEWS\fP: .br \fIUSENET\fP news subsystem .IP o \fBSYSLOGBUF\fP: .br messages generated internally by \fIsyslogbufd\fP .IP o \fBUSER\fP: .br generic user\-level messages .IP o \fBUUCP\fP: .br UUCP subsystem .PP .SH "CONSTRUCTOR" .IP o \fBSyslogBuf(string const &ident = \(dq\&\(dq\&, FBB::Priority priority = FBB::NOTICE, FBB::Facility facility = FBB::USER, int option = 0)\fP: .br The \fIident\fP parameter is usually the name of the program\&. Its content are prepended to syslog messages\&. .IP The \fIpriority\fP parameter determines the default importance of the message sent to the syslog daemon\&. By default messages are sent to the syslog daemon with priority \fBFBB::NOTICE\fP\&. Syslog messages may be given different priority by inserting a \fBSyslogStream\fP(3bobcat) manipulator\&. The priority set at construction time may also be modified using the \fIsetPriority\fP and \fIsetDefaultPriority\fP members\&. .IP Which messages actually appear in log facilities is not determined by the messages\(cq\& priorities, but by syslog\(cq\&s \fIlog mask\fP\&. The log mask can be set by the static member \fIsetMask\fP (see below)\&. .IP The \fIfacility\fP parameter determines the type of program doing the logging\&. By default \fBFBB::USER\fP is used\&. .IP The \fIoption\fP parameter may be used to specify various options (use the binary `\fIbitor\fP\(cq\& (`\fI|\fP\(cq\&) operator to combine options): .IP \fBLOG_CONS\fP: write directly to system console if there is an error while sending to system logger .br \fBLOG_NDELAY\fP: open the connection immediately (normally, the con\- nection is opened when the first message is logged) .br \fBLOG_PERROR\fP: print to stderr as well .br \fBLOG__PID\fP: include PID with each message .br .IP By default no options are used\&. .PP Copy and move constructors (and assignment operators) are not available\&. .PP .SH "MEMBER FUNCTIONS" .PP All members of \fBstd::streambuf\fP are available, as \fBFBB::SyslogBuf\fP inherits from this class\&. .PP .IP o \fBPriority defaultPriority() const\fP: .br Returns the current default priority\&. I\&.e\&., the priority that will be used for the messages after inserting \fIendl\fP or \fIflush\fP\&. .IP o \fBvoid eoi()\fP: .br If the \fBSyslogStream\fP\(cq\&s internal buffer is not empty it is flushed to the syslog daemon\&. Thereafer \fBcloselog\fP(3) is called\&. Instead of using this member the \fIeoi\fP manipulator can also be used\&. .IP o \fBPriority priority() const\fP: .br Returns the next priority\&. I\&.e\&., the priority that will be used for the next message that is sent to the syslog daemon\&. .IP o \fBvoid reset(string const &ident, FBB::Priority priority = FBB::NOTICE, FBB::Facility facility = FBB::USER, int option = 0)\fP: .br Redefines the current identifier, priority, facility and options that are used when sending messages to the syslog daemon\&. If the \fBSyslogStream\fP\(cq\&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 \fIopen\fP\&. .IP o \fBPriority setDefaultPriority(Priority priority)\fP: .br Changes the default priority of the next message that is sent to the syslog daemon after inserting \fIstd::eoln\fP or \fIstd::flush\fP\&. The previously active default priority is returned\&. .IP o \fBPriority setPriority(Priority priority)\fP: .br Changes the priority for the next message that is sent to the syslog daemon after inserting \fIstd::eoln\fP or \fIstd::flush\fP\&. Subsequent messages will again use the default priority\&. The previously active priority setting is returned\&. .PP .SH "MANIPULATOR" .IP o \fBFBB::eoi\fP: .br The \fIeoi\fP manipulator can be inserted into the \fIostream\fP instead of calling the \fISyslogBuf::end\fP member\&. It performs the same actions as the \fIeoi\fP member\&. If inserted into a plain \fIstd::ostream\fP nothing happens\&. .PP .SH "EXAMPLE" See also \fBsyslogstream\fP(3bobcat) .PP .nf #include #include using namespace std; using namespace FBB; int main(int argc, char **argv) { ostream sls(new SyslogBuf(argv[0])); sls << SyslogStream::debug << \(dq\&Hello world\(dq\& << flush << SyslogStream::strerrno << endl; } .fi .PP .SH "FILES" \fIbobcat/syslogbuf\fP \- defines the class interface .PP .SH "SEE ALSO" \fBbobcat\fP(7), \fBcloselog\fP(3), \fBopenlog\fP(3), \fBrsyslogd\fP(8) \fBsyslog\fP(3), \fBsyslogstream\fP(3bobcat) .PP .SH "BUGS" The constructor\(cq\&s \fIoption\fP parameter is an \fIint\fP\&. Because of this, \fIint\fP values rather than enumeration values are passed to the constructor\&. It is the responsibility of the programmer to pass defined option values only\&. .PP .SH "BOBCAT PROJECT FILES" .PP .IP o \fIhttps://fbb\-git\&.gitlab\&.io/bobcat/\fP: gitlab project page; .IP o \fIbobcat_5\&.07\&.00\-x\&.dsc\fP: detached signature; .IP o \fIbobcat_5\&.07\&.00\-x\&.tar\&.gz\fP: source archive; .IP o \fIbobcat_5\&.07\&.00\-x_i386\&.changes\fP: change log; .IP o \fIlibbobcat1_5\&.07\&.00\-x_*\&.deb\fP: debian package containing the libraries; .IP o \fIlibbobcat1\-dev_5\&.07\&.00\-x_*\&.deb\fP: debian package containing the libraries, headers and manual pages; .PP .SH "BOBCAT" Bobcat is an acronym of `Brokken\(cq\&s Own Base Classes And Templates\(cq\&\&. .PP .SH "COPYRIGHT" This is free software, distributed under the terms of the GNU General Public License (GPL)\&. .PP .SH "AUTHOR" Frank B\&. Brokken (\fBf\&.b\&.brokken@rug\&.nl\fP)\&. .PP