libutil++  1.9.3
 All Classes Functions Variables
Log.h
1 /*
2 ** libutil++
3 ** $Id: Log.h 1653 2016-02-28 19:54:59Z sella $
4 ** Copyright (c) 2011-2016 Digital Genesis, LLC. All Rights Reserved.
5 ** Released under the LGPL Version 2.1 License.
6 ** http://www.digitalgenesis.com
7 */
8 
9 #ifndef __libutilxx__sella__util__Log_H__
10 #define __libutilxx__sella__util__Log_H__
11 
12 #include "../../common.h"
13 #include "LogFormat.h"
14 #include "SimpleLogFormat.h"
15 #include "LogException.h"
16 #include "../Exception.h"
17 
18 #include <memory>
19 
20 #include <syslog.h>
21 #include <stdint.h>
22 #include <pthread.h>
23 
24 #include <string>
25 #include <unordered_set>
26 #include <list>
27 #include <vector>
28 
29 #ifndef LOG_INSTANCE
30  #define LOG_INSTANCE (*libutilxx__log)
31  #define AUTO_LOG_INSTANCE
32 #endif
33 
34 /* NOTE: User may define LOG_INSTANCE before including <libutil++/sella/util/Log.h>
35  *
36  * Example:
37  *
38  * #define LOG_INSTANCE (*logger)
39  * #include <libutil++/sella/util/Log.h>
40  * using namespace sella::util;
41  * Log::shared logger = Log::shared_ptr("prog_name", LOG_LOCAL0, Log::WithStderrOption);
42  *
43  * Examples:
44  *
45  * Print informational log message.
46  * INFO("Hello %d", 10);
47  *
48  * Print a warning only once per X seconds.
49  * time_t next = 0;
50  * while (true) { WARNING_TIME(next, 5, "Print every 5 seconds"); * }
51  *
52  * Print a conditional warning only once per X seconds.
53  * time_t next = 0;
54  * while (true) { WARNING_IF_TIME((5 > 2), next, 5, "Print every 5 seconds"); * }
55  *
56  * Print a log message when traceoption 'foobar' is set.
57  * SET_TRACE("foobar");
58  * TRACE("foobar", "Hello");
59  *
60 */
61 
62 #define TRACE(option, format, ...) (((LOG_INSTANCE).isTraceOption(option)) ? ((LOG_INSTANCE).trace(option, __func__, __FILE__, __LINE__, format, ##__VA_ARGS__)) : false )
63 #define LOG(facility, level, format, ...) ((LOG_INSTANCE).write(facility, level, __func__, __FILE__, __LINE__, format, ##__VA_ARGS__))
64 #define LOG2(level, format, ...) ((LOG_INSTANCE).write(level, __func__, __FILE__, __LINE__, format, ##__VA_ARGS__))
65 #define EXCEPTION(e, format, ...) ((LOG_INSTANCE).write(LOG_ALERT, __func__, __FILE__, __LINE__, e, format, ##__VA_ARGS__))
66 
67 #define SET_TRACE(option) ((LOG_INSTANCE).setTraceOption(option, true))
68 #define SET_TRACE2(option, on) ((LOG_INSTANCE).setTraceOption(option, on))
69 #define UNSET_TRACE(option) ((LOG_INSTANCE).setTraceOption(option, false))
70 #define IS_TRACE(option) ((LOG_INSTANCE).isTraceOption(option))
71 #define HAS_TRACE() ((LOG_INSTANCE).hasTraceOptions()
72 #define CLEAR_TRACE() ((LOG_INSTANCE).clearTraceOptions())
73 
74 #define SET_IDENTIFIER(identifier) ((LOG_INSTANCE).setIdentifier(identifier))
75 #define SET_FACILITY(facility) ((LOG_INSTANCE).setFacility(facility))
76 #define SET_OPTION(option) ((LOG_INSTANCE).setOption(option))
77 #define SET_FORMAT(format) ((LOG_INSTANCE).setFormat(format))
78 #define SET_LOGMASK(mask) ((LOG_INSTANCE).setLogMask(mask))
79 #define SET_LOGSIZE(size) ((LOG_INSTANCE).setLogSize(size))
80 
81 #define DO_PRAGMA(x) _Pragma(#x)
82 
83 #ifdef NDEBUG
84  #define DEBUG_FLAG 0 /* Compiler will optimize out. */
85  #define TODO(x)
86  #define FIXME(x)
87 #else
88  #define DEBUG_FLAG 1
89  #define TODO(x) DO_PRAGMA(message("TODO: " #x))
90  #define FIXME(x) DO_PRAGMA(message("FIXME: " #x))
91 #endif
92 
93 #define HERE(x) do { if (DEBUG_FLAG) LOG2(LOG_INFO, "HERE: " #x); } while (0)
94 #define MARK do { if (DEBUG_FLAG) LOG2(LOG_INFO, "MARK: %s() %s:%d", __func__, __FILE__, __LINE__); } while (0)
95 
96 #define DTRACE(option, format, ...) ((DEBUG_FLAG && (LOG_INSTANCE).isTraceOption(option)) ? ((LOG_INSTANCE).trace(option, __func__, __FILE__, __LINE__, format, ##__VA_ARGS__)) : false )
97 
98 #define DLOG(format, ...) do { if (DEBUG_FLAG) LOG2(LOG_DEBUG, format, ##__VA_ARGS__); } while (0)
99 #define DLOG_IF(format, ...) do { if (DEBUG_FLAG) LOG2_IF(LOG_DEBUG, format, ##__VA_ARGS__); } while (0)
100 #define DLOG_EVERY_N(cnt, format, ...) do { if (DEBUG_FLAG) LOG2_EVERY_N(cnt, LOG_DEBUG, format, ##__VA_ARGS__); } while (0)
101 #define DLOG_IF_EVERY_N(cond, cnt, format, ...) do { if (DEBUG_FLAG) LOG2_IF_EVERY_N((cond), cnt, LOG_DEBUG, format, ##__VA_ARGS__); } while (0)
102 #define DLOG_FIRST_N(cnt, format, ...) do { if (DEBUG_FLAG) LOG2_FIRST_N(cnt, LOG_DEBUG, format, ##__VA_ARGS__); } while (0)
103 #define DLOG_IF_FIRST_N(cond, cnt, format, ...) do { if (DEBUG_FLAG) LOG2_IF_FIRST_N((cond), cnt, LOG_DEBUG, format, ##__VA_ARGS__); } while (0)
104 
105 #define EMERGENCY(format, ...) LOG2(LOG_EMERG, format, ##__VA_ARGS__)
106 #define ALERT(format, ...) LOG2(LOG_ALERT, format, ##__VA_ARGS__)
107 #define CRITICAL(format, ...) LOG2(LOG_CRIT, format, ##__VA_ARGS__)
108 #define ERROR(format, ...) LOG2(LOG_ERR, format, ##__VA_ARGS__)
109 #define WARNING(format, ...) LOG2(LOG_WARNING, format, ##__VA_ARGS__)
110 #define NOTICE(format, ...) LOG2(LOG_NOTICE, format, ##__VA_ARGS__)
111 #define INFO(format, ...) LOG2(LOG_INFO, format, ##__VA_ARGS__)
112 #define DEBUG(format, ...) LOG2(LOG_DEBUG, format, ##__VA_ARGS__)
113 
114 #define EMERGENCY_IF(cond, format, ...) LOG2_IF((cond), LOG_EMERG, format, ##__VA_ARGS__)
115 #define ALERT_IF(cond, format, ...) LOG2_IF((cond), LOG_ALERT, format, ##__VA_ARGS__)
116 #define CRITICAL_IF(cond, format, ...) LOG2_IF((cond), LOG_CRIT, format, ##__VA_ARGS__)
117 #define ERROR_IF(cond, format, ...) LOG2_IF((cond), LOG_ERR, format, ##__VA_ARGS__)
118 #define WARNING_IF(cond, format, ...) LOG2_IF((cond), LOG_WARNING, format, ##__VA_ARGS__)
119 #define NOTICE_IF(cond, format, ...) LOG2_IF((cond), LOG_NOTICE, format, ##__VA_ARGS__)
120 #define INFO_IF(cond, format, ...) LOG2_IF((cond), LOG_INFO, format, ##__VA_ARGS__)
121 #define DEBUG_IF(cond, format, ...) LOG2_IF((cond), LOG_DEBUG, format, ##__VA_ARGS__)
122 
123 #define EMERGENCY_TIME(next, sec, format, ...) LOG2_TIME(next, sec, LOG_EMERG, format, ##__VA_ARGS__)
124 #define ALERT_TIME(next, sec, format, ...) LOG2_TIME(next, sec, LOG_ALERT, format, ##__VA_ARGS__)
125 #define CRITICAL_TIME(next, sec, format, ...) LOG2_TIME(next, sec, LOG_CRIT, format, ##__VA_ARGS__)
126 #define ERROR_TIME(next, sec, format, ...) LOG2_TIME(next, sec, LOG_ERR, format, ##__VA_ARGS__)
127 #define WARNING_TIME(next, sec, format, ...) LOG2_TIME(next, sec, LOG_WARNING, format, ##__VA_ARGS__)
128 #define NOTICE_TIME(next, sec, format, ...) LOG2_TIME(next, sec, LOG_NOTICE, format, ##__VA_ARGS__)
129 #define INFO_TIME(next, sec, format, ...) LOG2_TIME(next, sec, LOG_INFO, format, ##__VA_ARGS__)
130 #define DEBUG_TIME(next, sec, format, ...) LOG2_TIME(next, sec, LOG_DEBUG, format, ##__VA_ARGS__)
131 
132 #define EMERGENCY_IF_TIME(next, sec, format, ...) LOG2_IF_TIME((cond), next, sec, LOG_EMERG, format, ##__VA_ARGS__)
133 #define ALERT_IF_TIME(next, sec, format, ...) LOG2_IF_TIME((cond), next, sec, LOG_ALERT, format, ##__VA_ARGS__)
134 #define CRITICAL_IF_TIME(next, sec, format, ...) LOG2_IF_TIME((cond), next, sec, LOG_CRIT, format, ##__VA_ARGS__)
135 #define ERROR_IF_TIME(next, sec, format, ...) LOG2_IF_TIME((cond), next, sec, LOG_ERR, format, ##__VA_ARGS__)
136 #define WARNING_IF_TIME(next, sec, format, ...) LOG2_IF_TIME((cond), next, sec, LOG_WARNING, format, ##__VA_ARGS__)
137 #define NOTICE_IF_TIME(next, sec, format, ...) LOG2_IF_TIME((cond), next, sec, LOG_NOTICE, format, ##__VA_ARGS__)
138 #define INFO_IF_TIME(next, sec, format, ...) LOG2_IF_TIME((cond), next, sec, LOG_INFO, format, ##__VA_ARGS__)
139 #define DEBUG_IF_TIME(next, sec, format, ...) LOG2_IF_TIME((cond), next, sec, LOG_DEBUG, format, ##__VA_ARGS__)
140 
141 #define EMERGENCY_EVERY_N(cnt, format, ...) LOG2_EVERY_N(cnt, LOG_EMERG, format, ##__VA_ARGS__)
142 #define ALERT_EVERY_N(cnt, format, ...) LOG2_EVERY_N(cnt, LOG_ALERT, format, ##__VA_ARGS__)
143 #define CRITICAL_EVERY_N(cnt, format, ...) LOG2_EVERY_N(cnt, LOG_CRIT, format, ##__VA_ARGS__)
144 #define ERROR_EVERY_N(cnt, format, ...) LOG2_EVERY_N(cnt, LOG_ERR, format, ##__VA_ARGS__)
145 #define WARNING_EVERY_N(cnt, format, ...) LOG2_EVERY_N(cnt, LOG_WARNING, format, ##__VA_ARGS__)
146 #define NOTICE_EVERY_N(cnt, format, ...) LOG2_EVERY_N(cnt, LOG_NOTICE, format, ##__VA_ARGS__)
147 #define INFO_EVERY_N(cnt, format, ...) LOG2_EVERY_N(cnt, LOG_INFO, format, ##__VA_ARGS__)
148 #define DEBUG_EVERY_N(cnt, format, ...) LOG2_EVERY_N(cnt, LOG_DEBUG, format, ##__VA_ARGS__)
149 
150 #define EMERGENCY_IF_EVERY_N(cond, cnt, format, ...) LOG2_IF_EVERY_N((cond), cnt, LOG_EMERG, format, ##__VA_ARGS__)
151 #define ALERT_IF_EVERY_N(cond, cnt, format, ...) LOG2_IF_EVERY_N((cond), cnt, LOG_ALERT, format, ##__VA_ARGS__)
152 #define CRITICAL_IF_EVERY_N(cond, cnt, format, ...) LOG2_IF_EVERY_N((cond), cnt, LOG_CRIT, format, ##__VA_ARGS__)
153 #define ERROR_IF_EVERY_N(cond, cnt, format, ...) LOG2_IF_EVERY_N((cond), cnt, LOG_ERR, format, ##__VA_ARGS__)
154 #define WARNING_IF_EVERY_N(cond, cnt, format, ...) LOG2_IF_EVERY_N((cond), cnt, LOG_WARNING, format, ##__VA_ARGS__)
155 #define NOTICE_IF_EVERY_N(cond, cnt, format, ...) LOG2_IF_EVERY_N((cond), cnt, LOG_NOTICE, format, ##__VA_ARGS__)
156 #define INFO_IF_EVERY_N(cond, cnt, format, ...) LOG2_IF_EVERY_N((cond), cnt, LOG_INFO, format, ##__VA_ARGS__)
157 #define DEBUG_IF_EVERY_N(cond, cnt, format, ...) LOG2_IF_EVERY_N((cond), cnt, LOG_DEBUG, format, ##__VA_ARGS__)
158 
159 #define EMERGENCY_FIRST_N(cnt, format, ...) LOG2_FIRST_N(cnt, LOG_EMERG, format, ##__VA_ARGS__)
160 #define ALERT_FIRST_N(cnt, format, ...) LOG2_FIRST_N(cnt, LOG_ALERT, format, ##__VA_ARGS__)
161 #define CRITICAL_FIRST_N(cnt, format, ...) LOG2_FIRST_N(cnt, LOG_CRIT, format, ##__VA_ARGS__)
162 #define ERROR_FIRST_N(cnt, format, ...) LOG2_FIRST_N(cnt, LOG_ERR, format, ##__VA_ARGS__)
163 #define WARNING_FIRST_N(cnt, format, ...) LOG2_FIRST_N(cnt, LOG_WARNING, format, ##__VA_ARGS__)
164 #define NOTICE_FIRST_N(cnt, format, ...) LOG2_FIRST_N(cnt, LOG_NOTICE, format, ##__VA_ARGS__)
165 #define INFO_FIRST_N(cnt, format, ...) LOG2_FIRST_N(cnt, LOG_INFO, format, ##__VA_ARGS__)
166 #define DEBUG_FIRST_N(cnt, format, ...) LOG2_FIRST_N(cnt, LOG_DEBUG, format, ##__VA_ARGS__)
167 
168 #define EMERGENCY_IF_FIRST_N(cond, cnt, format, ...) LOG2_IF_FIRST_N((cond), cnt, LOG_EMERG, format, ##__VA_ARGS__)
169 #define ALERT_IF_FIRST_N(cond, cnt, format, ...) LOG2_IF_FIRST_N((cond), cnt, LOG_ALERT, format, ##__VA_ARGS__)
170 #define CRITICAL_IF_FIRST_N(cond, cnt, format, ...) LOG2_IF_FIRST_N((cond), cnt, LOG_CRIT, format, ##__VA_ARGS__)
171 #define ERROR_IF_FIRST_N(cond, cnt, format, ...) LOG2_IF_FIRST_N((cond), cnt, LOG_ERR, format, ##__VA_ARGS__)
172 #define WARNING_IF_FIRST_N(cond, cnt, format, ...) LOG2_IF_FIRST_N((cond), cnt, LOG_WARNING, format, ##__VA_ARGS__)
173 #define NOTICE_IF_FIRST_N(cond, cnt, format, ...) LOG2_IF_FIRST_N((cond), cnt, LOG_NOTICE, format, ##__VA_ARGS__)
174 #define INFO_IF_FIRST_N(cond, cnt, format, ...) LOG2_IF_FIRST_N((cond), cnt, LOG_INFO, format, ##__VA_ARGS__)
175 #define DEBUG_IF_FIRST_N(cond, cnt, format, ...) LOG2_IF_FIRST_N((cond), cnt, LOG_DEBUG, format, ##__VA_ARGS__)
176 
177 #define LOG_IF(cond, facility, level, format, ...) ((cond) && LOG(facility, level, format, ##__VA_ARGS__))
178 #define LOG2_IF(cond, level, format, ...) ((cond) && LOG2(level, format, ##__VA_ARGS__))
179 #define LOG_TIME(next, sec, level, format, ...) ((LOG_INSTANCE).isTime(next, sec) && LOG(level, format, ##__VA_ARGS__))
180 #define LOG2_TIME(next, sec, level, format, ...) ((LOG_INSTANCE).isTime(next, sec) && LOG2(level, format, ##__VA_ARGS__))
181 #define LOG_IF_TIME(next, sec, level, format, ...) ((cond) && (LOG_INSTANCE).isTime(next, sec) && LOG(level, format, ##__VA_ARGS__))
182 #define LOG2_IF_TIME(next, sec, level, format, ...) ((cond) && (LOG_INSTANCE).isTime(next, sec) && LOG2(level, format, ##__VA_ARGS__))
183 #define LOG_EVERY_N(cnt, level, format, ...) ((LOG_INSTANCE).incEveryN(cnt) && LOG(level, format, ##__VA_ARGS__))
184 #define LOG2_EVERY_N(cnt, level, format, ...) ((LOG_INSTANCE).incEveryN(cnt) && LOG2(level, format, ##__VA_ARGS__))
185 #define LOG_IF_EVERY_N(cond, cnt, level, format, ...) ((cond) && (LOG_INSTANCE).incEveryN(cnt) && LOG(level, format, ##__VA_ARGS__))
186 #define LOG2_IF_EVERY_N(cond, cnt, level, format, ...) ((cond) && (LOG_INSTANCE).incEveryN(cnt) && LOG2(level, format, ##__VA_ARGS__))
187 #define LOG_FIRST_N(cnt, level, format, ...) ((LOG_INSTANCE).incFirstN(cnt) && LOG(level, format, ##__VA_ARGS__))
188 #define LOG2_FIRST_N(cnt, level, format, ...) ((LOG_INSTANCE).incFirstN(cnt) && LOG2(level, format, ##__VA_ARGS__))
189 #define LOG_IF_FIRST_N(cond, cnt, level, format, ...) ((cond) && (LOG_INSTANCE).incFirstN(cnt) && LOG(level, format, ##__VA_ARGS__))
190 #define LOG2_IF_FIRST_N(cond, cnt, level, format, ...) ((cond) && (LOG_INSTANCE).incFirstN(cnt) && LOG2(level, format, ##__VA_ARGS__))
191 
192 #define TRACE_IF(cond, option, format, ...) ((cond) && TRACE(option, format, ##__VA_ARGS__))
193 #define TRACE_TIME(next, sec, option, format, ...) ((LOG_INSTANCE).isTime(next, sec) && TRACE(option, format, ##__VA_ARGS__))
194 #define TRACE_IF_TIME(cond, next, sec, option, format, ...) ((cond) && (LOG_INSTANCE).isTime(next, sec) && TRACE(option, format, ##__VA_ARGS__))
195 
196 namespace sella {
197  namespace util {
198  class Log;
199  }
200 }
201 
203  public:
204  typedef std::shared_ptr<Log> shared;
205  typedef Log *ptr;
206  typedef std::unordered_set<std::string> option_set;
207 
208  public:
209  static const int FACILITY_AUTH = LOG_AUTH;
210  static const int FACILITY_AUTHPRIV = LOG_AUTHPRIV;
211  static const int FACILITY_CRON = LOG_CRON;
212  static const int FACILITY_DAEMON = LOG_DAEMON;
213  static const int FACILITY_FTP = LOG_FTP;
214  static const int FACILITY_KERN = LOG_KERN;
215  static const int FACILITY_LOCAL0 = LOG_LOCAL0;
216  static const int FACILITY_LOCAL1 = LOG_LOCAL1;
217  static const int FACILITY_LOCAL2 = LOG_LOCAL2;
218  static const int FACILITY_LOCAL3 = LOG_LOCAL3;
219  static const int FACILITY_LOCAL4 = LOG_LOCAL4;
220  static const int FACILITY_LOCAL5 = LOG_LOCAL5;
221  static const int FACILITY_LOCAL6 = LOG_LOCAL6;
222  static const int FACILITY_LOCAL7 = LOG_LOCAL7;
223  static const int FACILITY_LPR = LOG_LPR;
224  static const int FACILITY_MAIL = LOG_MAIL;
225  static const int FACILITY_NEWS = LOG_NEWS;
226  static const int FACILITY_SYSLOG = LOG_SYSLOG;
227  static const int FACILITY_USER = LOG_USER;
228  static const int FACILITY_UUCP = LOG_UUCP;
229 
230  static const int LEVEL_EMERGENCY = LOG_EMERG;
231  static const int LEVEL_ALERT = LOG_ALERT;
232  static const int LEVEL_CRITICAL = LOG_CRIT;
233  static const int LEVEL_ERROR = LOG_ERR;
234  static const int LEVEL_WARNING = LOG_WARNING;
235  static const int LEVEL_NOTICE = LOG_NOTICE;
236  static const int LEVEL_INFO = LOG_INFO;
237  static const int LEVEL_DEBUG = LOG_DEBUG;
238 
239  static const char* LABEL_EMERGENCY;
240  static const char* LABEL_ALERT;
241  static const char* LABEL_CRITICAL;
242  static const char* LABEL_ERROR;
243  static const char* LABEL_WARNING;
244  static const char* LABEL_NOTICE;
245  static const char* LABEL_INFO;
246  static const char* LABEL_DEBUG;
247 
248  static const int DefaultOption = (LOG_CONS|LOG_NDELAY|LOG_NOWAIT|LOG_PID);
249  static const int WithStderrOption = (LOG_CONS|LOG_NDELAY|LOG_NOWAIT|LOG_PID|LOG_PERROR);
250  static const int DefaultLogMask = LOG_UPTO(LOG_DEBUG);
251  static const size_t DefaultLogSize = 1022; /* syslog() call getting sick with large strings. */
252 
253  public:
254  static Log::shared& instance(const std::string &identifier = std::string());
255 
256  public:
257  Log(const std::string &identifier, int facility, int option = DefaultOption, int mask = DefaultLogMask, const LogFormat &format = SimpleLogFormat(), size_t size = DefaultLogSize) throw (LogException);
258  Log(const std::string &file, const LogFormat &format = SimpleLogFormat(), size_t size = DefaultLogSize) throw (LogException);
259 
260  Log(const Log &other) throw ();
261  virtual ~Log() throw ();
262 
263  static const Log::shared shared_ptr(const std::string &identifier, int facility, int option = DefaultOption, int mask = DefaultLogMask, const LogFormat &format = SimpleLogFormat(), size_t size = DefaultLogSize) throw (LogException);
264  static const Log::shared shared_ptr(const std::string &file, const LogFormat &format = SimpleLogFormat(), size_t size = DefaultLogSize) throw (LogException);
265  public:
266  Log& operator=(const Log &other) throw ();
267 
268  public:
269  static const char* priority(int level) throw ();
270 
271  void setIdentifier(const std::string &identifier = std::string()) throw ();
272  void setFacility(int facility) throw ();
273  void setOption(int option = DefaultOption) throw ();
274  void setFormat(const LogFormat &format) throw ();
275 
276  void setLogLevel(int level, bool on = true) throw ();
277  int setLogMask(int mask) throw (); /* Must use LOG_MASK() or LOG_UPTO() to pass mask value. */
278  void setLogSize(size_t size = DefaultLogSize) throw ();
279  int getLogMask(void) throw ();
280  bool isLogMask(int level) throw ();
281  size_t getLogSize(void) throw ();
282 
283  void setTraceOption(const std::string &option, bool on = true) throw (); /* Setting to 'all' enbles all. */
284  void setTraceOption(const std::vector<std::string> &options, bool on = true) throw (); /* Allows SET_TRACE() to accept vector. */
285  void setTraceOption(const std::list<std::string> &options, bool on = true) throw (); /* Allows SET_TRACE() to accept list */
286  void setTraceOptions(const std::vector<std::string> &options, bool on = true) throw ();
287  void setTraceOptions(const std::list<std::string> &options, bool on = true) throw ();
288  bool isTraceOption(const char *option) throw ();
289  bool isTraceOption(const std::string &option) throw ();
290  bool isTraceOption(const std::vector<std::string> &options) throw ();
291  bool isTraceOption(const std::list<std::string> &options) throw ();
292  bool hasTraceOptions(void) throw ();
293  void clearTraceOptions(void) throw ();
294 
295  bool isTime(time_t &next, int sec) throw ();
296  bool incEveryN(uint64_t n) throw ();
297  bool incFirstN(uint64_t n) throw ();
298  void resetEveryN(void) throw ();
299 
300  bool trace(const char *option, const char *func, const char *file, int line, const char *format, ...) throw ();
301  bool trace(std::string &option, const char *func, const char *file, int line, const char *format, ...) throw ();
302  bool trace(const char *option, const char *func, const char *file, int line, const std::string &format, ...) throw ();
303  bool trace(std::string &option, const char *func, const char *file, int line, const std::string &format, ...) throw ();
304 
305  bool trace(const std::vector<std::string> &options, const char *func, const char *file, int line, const char *format, ...) throw ();
306  bool trace(const std::vector<std::string> &options, const char *func, const char *file, int line, const std::string &format, ...) throw ();
307  bool trace(const std::list<std::string> &options, const char *func, const char *file, int line, const char *format, ...) throw ();
308  bool trace(const std::list<std::string> &options, const char *func, const char *file, int line, const std::string &format, ...) throw ();
309 
310  bool write(int facility, int level, const char *func, const char *file, int line, const sella::Exception &e, const std::string &format, ...) throw ();
311  bool write(int facility, int level, const char *func, const char *file, int line, const std::string &format, ...) throw ();
312 
313  bool write(int level, const char *func, const char *file, int line, const sella::Exception &e) throw ();
314  bool write(int level, const char *func, const char *file, int line, const sella::Exception &e, const std::string &format, ...) throw ();
315  bool write(int level, const char *func, const char *file, int line, const std::string &format, ...) throw ();
316 
317  bool write(int facility, int level, const char *func, const char *file, int line, const sella::Exception &e, const char *format, ...) throw ();
318  bool write(int facility, int level, const char *func, const char *file, int line, const char *format, ...) throw ();
319 
320  bool write(int level, const char *func, const char *file, int line, const sella::Exception &e, const char *format, ...) throw ();
321  bool write(int level, const char *func, const char *file, int line, const char *format, ...) throw ();
322 
323  private:
324  inline void resize(std::string &text) throw ();
325 
326  uint64_t &references;
327  uint64_t &everyN;
328 
329  std::string identifier;
330  int facility;
331  int option;
332 
333  LogFormat *format;
334  bool syslog;
335  int syslogMask;
336  size_t size;
337 
338  option_set traceOptions;
339  bool allTraceOptions;
340 
341  pthread_spinlock_t mutex;
342 };
343 
344 #ifdef AUTO_LOG_INSTANCE
345  extern sella::util::Log::shared libutilxx__log;
346 #endif
347 
348 #endif
349 
350 /*
351 ** vim: noet ts=3 sw=3
352 */