|
plptools
|
A streambuffer, logging via syslog. More...
#include <log.h>


Public Member Functions | |
| logbuf (int loglevel, int fd) | |
| Constructs a new instance. More... | |
| void | useSyslog () |
| Write logs using syslog. More... | |
| void | useFileDescriptor () |
| Write logs to the file descriptor passed in the constructor. More... | |
| void | setLevel (int newlevel) |
| Modifies the loglevel of this instance. More... | |
| int | overflow (int c=EOF) |
| Called by the associated ostream to write a character. More... | |
Private Attributes | |
| char * | ptr |
| Pointer to next char in buffer. More... | |
| unsigned int | len |
| Current length of buffer. More... | |
| int | _level |
| The log level to use with syslog. More... | |
| int | _fd |
| File descriptor to use when switched off. More... | |
| bool | _use_syslog |
| Log flag. More... | |
| char | buf [1024] |
| The internal buffer for holding messages. More... | |
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;
Logging can be toggled between using syslog and writing to a file (see useSyslog and useFileDescriptor).
| logbuf::logbuf | ( | int | loglevel, |
| int | fd | ||
| ) |
| int logbuf::overflow | ( | int | c = EOF | ) |
|
inline |
|
inline |
|
inline |
|
private |
|
private |