libutil++  1.9.3
 All Classes Functions Variables
LogFormat.h
1 /*
2 ** libutil++
3 ** $Id: LogFormat.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__LogFormat_H__
10 #define __libutilxx__sella__util__LogFormat_H__
11 
12 #include "../../common.h"
13 #include "../Exception.h"
14 
15 #include <syslog.h>
16 #include <sys/time.h>
17 
18 #include <string>
19 
20 #define DEFAULTSTAMPFORMAT "%Y-%m-%d+%H:%M:%S"
21 
22 namespace sella {
23  namespace util {
24  class LogFormat;
25  class Log;
26  }
27 }
28 
30  friend class Log;
31 
32  public:
33  static const std::string DefaultStampFormat; /* %Y-%m-%d+%H:%M:%S */
34 
35  LogFormat(const std::string &stamp = DefaultStampFormat, bool micro = true) throw ();
36  virtual ~LogFormat() { };
37 
38  virtual sella::util::LogFormat* clone(void) const throw () = 0;
39 
40  protected:
41  virtual const std::string format(int priority, const char *stamp, const char *func, const char *file, int line, const sella::Exception &e, const char *message) throw () = 0;
42  virtual const std::string format(int priority, const char *stamp, const char *func, const char *file, int line, const char *message) throw () = 0;
43  virtual const std::string format(int priority, const char *stamp, const char *func, const char *file, int line, const char *option, const char *message) throw () = 0;
44 
45  std::string format(const struct timeval &stamp) throw ();
46 
47  protected:
48  std::string stamp;
49  bool micro;
50 };
51 
52 #endif
53 
54 /*
55 ** vim: noet ts=3 sw=3
56 */