libUTL++
SyslogStream.h
1 #pragma once
2 
4 
5 #if UTL_HOST_OS != UTL_OS_MINGW
6 
8 
9 #include <syslog.h>
10 #include <libutl/BufferedStream.h>
11 #include <libutl/String.h>
12 
14 
15 UTL_NS_BEGIN;
16 
18 
29 
32 {
35 
36 public:
43  SyslogStream(const String& ident, int facility, int level = int_t_max)
44  {
45  init();
46  open(ident, facility, level);
47  }
48 
55  void open(const String& ident, int facility, int level = int_t_max);
56 
58  virtual void close();
59 
61  int
63  {
64  return _facility;
65  }
66 
68  void
69  setFacility(int facility)
70  {
71  _facility = facility;
72  }
73 
75  int
77  {
78  return _level;
79  }
80 
82  void
83  setLevel(int level)
84  {
85  _level = level;
86  }
87 
88 protected:
89  virtual void clear();
90  virtual void overflow();
91  virtual void
93  {
94  ABORT();
95  }
96 
97 private:
98  void
99  init()
100  {
101  clear();
102  }
103  void
104  deInit()
105  {
106  close();
107  }
108  void clearSelf();
109 
110 private:
111  String _ident;
112  int _facility;
113  int _level;
114 };
115 
117 
118 UTL_NS_END;
119 
121 
122 #endif
int getFacility()
Get the facility.
Definition: SyslogStream.h:62
int getLevel()
Get the level.
Definition: SyslogStream.h:76
void deInit()
De-initialize UTL++.
void setLevel(int level)
Set the level.
Definition: SyslogStream.h:83
void setFacility(int facility)
Set the facility.
Definition: SyslogStream.h:69
#define UTL_CLASS_DECL(DC, BC)
Declaration of standard UTL++ functionality for a non-template class.
Definition: macros.h:688
Syslog stream.
Definition: SyslogStream.h:31
SyslogStream(const String &ident, int facility, int level=int_t_max)
Constructor.
Definition: SyslogStream.h:43
Character string.
Definition: String.h:31
const int_t int_t_max
Maximum int_t value.
#define ABORT()
Immediately terminates the program.
Definition: macros.h:59
#define UTL_CLASS_NO_COPY
Declare that a class cannot do copy().
Definition: macros.h:358
virtual void underflow()
Read from the underlying stream into the input buffer.
Definition: SyslogStream.h:92
Buffered stream.
void init()
Initialize UTL++.