EPICS ARCHIVER V4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
MsgLogger.h
1 // -*- c++ -*-
2 #ifndef __MSG_LOGGER_H__
3 #define __MSG_LOGGER_H__
4 
5 // system
6 #include <stdio.h>
7 #include <stdlib.h>
8 
9 // tools
10 #include "tools/GenericException.h"
11 #include "tools/AutoFilePtr.h"
12 #include "tools/NoCopy.h"
13 
28 class MsgLogger
29 {
30 public:
41  MsgLogger(const char *filename = 0);
42 
47  virtual ~MsgLogger();
48 
53  void log(const char *format, va_list ap)
54  __attribute__ ((format (printf, 2, 0)));
55 
56 protected:
57 
59  static MsgLogger *TheMsgLogger;
60 
62  static void createDefaultLogger();
63 
65  static void deleteDefaultLogger();
66 
70  MsgLogger *prev_logger;
71 
73  friend void LOG_MSG(const char *format, va_list ap);
74 
76  AutoFilePtr f;
77 
81  virtual void print(const char *s);
82 private:
83  PROHIBIT_DEFAULT_COPY(MsgLogger);
84 };
85 
86 void LOG_MSG(const char *format, va_list ap);
87 
88 void LOG_MSG(const char *format, ...)
89  __attribute__ ((format (printf, 1, 2)));
90 
91 #define LOG_ASSERT(e) \
92  if (! (e)) \
93  { \
94  LOG_MSG("\nASSERT '%s' FAILED:\n%s (%d)\n\n", \
95  #e, __FILE__, __LINE__); \
96  if (getenv("ABORT_ON_ERRORS")) \
97  abort(); \
98  throw GenericException(__FILE__, __LINE__, \
99  "ASSERT '%s' FAILED", #e); \
100  }
101 
102 #endif
103 
A trace or logging facility.
Definition: MsgLogger.h:28
void log(const char *format, va_list ap) __attribute__((format(printf
Log some text.
friend void LOG_MSG(const char *format, va_list ap)
Log message.
Auto-close FILE pointer wrapper.
Definition: AutoFilePtr.h:15
virtual ~MsgLogger()
Destructor.
MsgLogger(const char *filename=0)
Construct a new logger.