Bincimap 2.0.16
Easy Imapping
Loading...
Searching...
No Matches
syslogdevice.cc
Go to the documentation of this file.
1
7#include "syslogdevice.h"
8#include <string>
9
10#include <syslog.h>
11
12using namespace ::std;
13using namespace ::Binc;
14
15//------------------------------------------------------------------------
16string SyslogDevice::ident;
17
18//------------------------------------------------------------------------
19SyslogDevice::SyslogDevice(int f, const char *i, int o, int fa)
20 : IODevice(f), option(o), facility(fa), priority(LOG_INFO)
21{
22 ident = i;
23 openlog(ident.c_str(), option, facility);
24}
25
26//------------------------------------------------------------------------
28{
29 closelog();
30}
31
32//------------------------------------------------------------------------
33string SyslogDevice::service(void) const
34{
35 return "log";
36}
37
38//------------------------------------------------------------------------
40{
41 return true;
42}
43
44//------------------------------------------------------------------------
46{
47 return false;
48}
49
50//------------------------------------------------------------------------
52{
53 string out;
54 string::const_iterator i = outputBuffer.str().begin();
55 string::const_iterator ie = outputBuffer.str().end();
56
57 for (; i != ie; ++i) {
58 if (*i == '\n') {
59 syslog(priority, out.c_str(), out.size());
60 out = "";
61 } else if (*i != '\r')
62 out += *i;
63 }
64
65 if (out != "") syslog(priority, out.c_str(), out.size());
66
68 return WriteDone;
69}
70
71//------------------------------------------------------------------------
73{
74 return false;
75}
const std::string & str(void) const
Definition: convert.cc:58
void clear(void)
Definition: convert.cc:64
The IODevice class provides a framework for reading and writing to device.
Definition: iodevice.h:31
BincStream outputBuffer
Definition: iodevice.h:340
bool waitForRead(void) const
Definition: syslogdevice.cc:45
bool waitForWrite(void) const
Definition: syslogdevice.cc:39
WriteResult write(void)
Definition: syslogdevice.cc:51
std::string service(void) const
Definition: syslogdevice.cc:33
bool fillInputBuffer(void)
Definition: syslogdevice.cc:72
Definition: bincimapd.cc:9
Declaration of the SyslogDevice class.