37class SyslogStream :
public std::streambuf {
47 SyslogStream() : _level( LOG_DEBUG ) { };
51 openlog(
"iipsrv", LOG_NDELAY | LOG_PID, LOG_USER );
55 void close(){ closelog(); };
60 syslog( _level,
"%s", _buf.c_str() );
67 int_type overflow( int_type c ){
68 if( c == traits_type::eof() ) sync();
69 else _buf +=
static_cast<char>(c);
85 SyslogStream _syslogStream;
89 std::ofstream _fstream;
114 void open(
const std::string& file ){
118 if( file ==
"syslog" ){
120 this->rdbuf( &_syslogStream );
121 _syslogStream.open();
127 _fstream.open( file.c_str(), ios_base::app );
128 std::streambuf *buffer = _fstream.rdbuf();
129 this->rdbuf( buffer );
141 _syslogStream.close();
154 std::string
types =
"file";
Logger class - handles ofstreams and syslog.
Definition: Logger.h:79
std::string types()
Provide a list of available logging types.
Definition: Logger.h:153
Logger()
Constructor - derived from std::ostream.
Definition: Logger.h:104
~Logger()
Destructor - close our logging stream.
Definition: Logger.h:108
void open(const std::string &file)
Open our logging output.
Definition: Logger.h:114
void close()
Close depending on type.
Definition: Logger.h:137