Scroll to navigation

FBB::SyslogStream(3bobcat) Output Stream for Syslog FBB::SyslogStream(3bobcat)

NAME

FBB::SyslogStream - An output stream inserting syslog messages

SYNOPSIS

#include <bobcat/syslogstream>
 
Linking option: -lbobcat

DESCRIPTION

FBB::SyslogStream objects may be used as a std::ostream to write syslog messages using stream facilities.

NAMESPACE

FBB
 
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB.

INHERITS FROM

std::ostream

ENUMERATIONS

The following enumerations are defined in the namespace FBB:
Priority:
The values of this enumeration match the corresponding priority LOG_xxx values used with syslog(3):
o
EMERG:
 
system is unusable;
o
ALERT:
 
action must be taken immediately;
o
CRIT:
 
critical conditions;
o
ERR:
 
error conditions;
o
WARNING:
 
warning conditions;
o
NOTICE:
 
normal, but significant, condition;
o
INFO:
 
informational message;
o
DEBUG:
 
debug-level message;
 
Facility:
The values of this enumeration match the corresponding facility LOG_xxx values used with syslog(3):
o
AUTHPRIV:
 
security/authorization messages (private)
o
CRON:
 
clock daemon ( cron and at)
o
DAEMON:
 
other system daemons
o
KERN:
 
kernel messages
o
LOCAL0:
 
reserved for local use. LOCAL1 through LOCAL7 are available as well.
o
LPR:
 
line printer subsystem
o
MAIL:
 
mail subsystem
o
NEWS:
 
USENET news subsystem
o
SYSLOGBUF:
 
messages generated internally by syslogbufd
o
USER:
 
generic user-level messages
o
UUCP:
 
UUCP subsystem
 

CONSTRUCTOR

o
SyslogStream(char *ident, FBB::Priority priority = FBB::NOTICE, FBB::Facility facility = FBB::USER, int option = 0):
 
This Syslogstream() constructor initializes the streamstream. The ident parameter is usually the name of the program. Its contents are prepended to syslog messages. Use value 0 if no text needs to be prepended.
The priority parameter determines the importance of the message. By default FBB::NOTICE is used.
The facility parameter determines the type of program doing the logging. By default FBB::USER is used.
The option parameter may be used to specify various options (use the binary ` bitor’ (`|’) operator to combine options):
LOG_CONS: write directly to system console if there is an error while sending to system logger
 
LOG_NDELAY: open the connection immediately (normally, the con- nection is opened when the first message is logged)
 
LOG_PERROR: print to stderr as well
 
LOG__PID: include PID with each message
 
 
By default no options are used.
 
The copy constructor is not available.

MEMBER FUNCTIONS

All members of std::streamstream are available, as FBB::SyslogStream inherits from this class.
o
Priority defaultPriority() const:
 
Returns the default priority. I.e., the priority that will be used for the messages after inserting endl, unless altered by setDefaultPriority().
o
Priority priority() const:
 
Returns the next priority. I.e., the priority that will be used for the next message, unless altered by setPriority().
o
Priority setDefaultPriority(Priority priority):
 
Changes the default priority of the next syslog-message after inserting std::eoln. Initially, the priority is determined as the value passed to the constructor. The previously active default priority is returned.
o
Priority setPriority(Priority priority):
 
Changes the priority for the next syslog message (after std::eoln has been inserted). Subsequent messages will use the default priority again. The previously active priority setting is returned.
 

MANIPULATORS

The following set of manipulators are all defined as (static) members of the class FBB::SyslogStream. They may be inserted into an FBB::SyslogStream. Except for the last manipulator ( strerrno), they have the following characteristics in common:
o
They will change the priority of the messages that are subsequently inserted by the FBB::SyslogStream object.
o
When inserting multiple manipulators before the inserted message is flushed (e.g., using the ios::flush or the ios::endl manipulators) the last inserted FBB::SyslogStream manipulator will be used.
o
Nothing happens if the manipulators are not inserted into an FBB::SyslogStream object. Here are the available manipulators:
o
SyslogStream::alert:
 
Messages are inserted with priority LOG_ALERT.
o
SyslogStream::crit:
 
Message are inserted with priority LOG_CRIT.
o
SyslogStream::debug:
 
Messages are inserted with priority LOG_DEBUG.
o
SyslogStream::emerg:
 
Messages are inserted with priority LOG_EMERG.
o
SyslogStream::err:
 
Messages are inserted with priority LOG_ERR.
o
SyslogStream::info:
 
Messages are inserted with priority LOG_INFO.
o
SyslogStream::notice:
 
Messages are inserted with priority LOG_NOTICE.
o
SyslogStream::strerrno:
 
This manipulator inserts the textual interpretation of std::errno’s current value into a std::ostream. Note that the object into which the manipulator is inserted does not have to be a FBB::SyslogStream object.
o
SyslogStream::warning:
 
Messages are inserted with priority LOG_WARNING.
 

EXAMPLE

#include <bobcat/syslogstream>
using namespace std; using namespace FBB;
int main(int argc, char **argv) { SyslogStream sls(argv[0]);
sls << SyslogStream::debug << "Hello world" << endl; sls << SyslogStream::strerrno << endl; return 0; }
 

FILES

bobcat/syslogstream - defines the class interface

SEE ALSO

bobcat(7), openlog(3), syslog(3), syslogstream(3bobcat)

BUGS

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

DISTRIBUTION FILES

o
bobcat_3.01.00-x.dsc: detached signature;
o
bobcat_3.01.00-x.tar.gz: source archive;
o
bobcat_3.01.00-x_i386.changes: change log;
o
libbobcat1_3.01.00-x_*.deb: debian package holding the libraries;
o
libbobcat1-dev_3.01.00-x_*.deb: debian package holding the libraries, headers and manual pages;
o
http://sourceforge.net/projects/bobcat: public archive location;
 

BOBCAT

Bobcat is an acronym of `Brokken’s Own Base Classes And Templates’.

COPYRIGHT

This is free software, distributed under the terms of the GNU General Public License (GPL).

AUTHOR

Frank B. Brokken ( f.b.brokken@rug.nl).
2005-2012 libbobcat1-dev_3.01.00-x.tar.gz