class logbuf

A streambuffer, logging via syslog More...

Definition#include <log.h>
Inheritsstreambuf (unknown) [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods


Detailed Description

A streambuffer, logging via syslog

logbuf can be used, if you want to use syslog for logging but don't want to change all your nice C++-style output statements in your code.

Here is an example showing the usage of logbuf:


	openlog("myDaemon", LOG_CONS|LOG_PID, LOG_DAEMON);
	logbuf ebuf(LOG_ERR, 2);
	ostream lerr(&ebuf);

	... some code ...

	lerr << "Whoops, got an error" << endl;

The second optional argument of the constructor can be used to switch the output destination between syslog and some file. If it is omitted or set to -1, logging can be switched on or off. The initial state is on.

 logbuf (int level, int fd = -1)

logbuf

Constructs a new instance.

Parameters:
levelThe log level for this instance. see syslog(3) for symbolic names to use.
fdAn optional file descriptor to use if switched off.

void  setOn (bool on)

setOn

Switches loggin on or off.

Parameters:
onThe desired state.

void  setLevel (int level)

setLevel

Modifies the loglevel of this instance.

Parameters:
levelThe new loglevel.

bool  on ()

on

Retrieve the current state.

Returns: The current state.

int  level ()

level

Retrieves the current loglevel.

Returns: The current loglevel.

int  overflow (int c = EOF)

overflow

Called by the associated ostream to write a character. Stores the character in a buffer and calls syslog(level, buffer) whenever a LF is seen.


Generated by: felfert on floh.fe.think on Tue Feb 4 11:27:30 2003, using kdoc 2.0a54.