Luiza  v03-01
baselevels.h
1 // -*- mode: c++;
2 
3 #ifndef baselevels_h
4 #define baselevels_h
5 /*
6  * Define base log level classes for streamlog::logstream. There are the following
7  * groups of log level classes: DEBUG, WARNING, MESSAGE and ERROR.
8  * By default all groups are active, except DEBUG when compiled with
9  * -DNDEBUG, i.e. in release mode.
10  * Through -DSTREAMLOG_LEVEL=N, where N=0,1,2,3,4 this behaviour can be changed, e.g.
11  * if -DSTREAMLOG_LEVEL=2 is specified at compile time all messages of the groups
12  * DEBUG and MESSAGE are suppressed (no overhead in space or time) and only WARNING
13  * and ERROR messages will be visible if the current log level is reached.
14  *
15  * @author F. Gaede, DESY
16  * @version $Id: baselevels.h,v 1.2 2007-07-13 11:09:04 gaede Exp $
17  */
18 
19 
20 namespace streamlog{
21 
22 #define STREAMLOG_MAX_LEVEL 0xFFFFFFFF
23 
24 #ifndef STREAMLOG_LEVEL
25  #ifndef NDEBUG
26  #define STREAMLOG_LEVEL 0
27  #else
28  #define STREAMLOG_LEVEL 1
29  #endif
30 #endif
31 
32 #if STREAMLOG_LEVEL > 3
33  #define STREAMLOG_ERROR_ACTIVE false
34 #else
35  #define STREAMLOG_ERROR_ACTIVE true
36 #endif
37 
38 #if STREAMLOG_LEVEL > 2
39  #define STREAMLOG_WARNING_ACTIVE false
40 #else
41  #define STREAMLOG_WARNING_ACTIVE true
42 #endif
43 
44 #if STREAMLOG_LEVEL > 1
45  #define STREAMLOG_MESSAGE_ACTIVE false
46 #else
47  #define STREAMLOG_MESSAGE_ACTIVE true
48 #endif
49 
50 #if STREAMLOG_LEVEL > 0
51  #define STREAMLOG_DEBUG_ACTIVE false
52 #else
53  #define STREAMLOG_DEBUG_ACTIVE true
54 #endif
55 
56 
57  template <unsigned LEVEL, bool ON>
58  struct Verbosity{
59  static const unsigned level = LEVEL ;
60  static const bool active = ON ;
61  } ;
62 
63 
64 
66 #define DEFINE_STREAMLOG_LEVEL( ClassName, String, LOG_Level, Active )\
67  template <bool ON>\
68  struct active_##ClassName : public Verbosity< (LOG_Level) , ON >{\
69  static const char* name() { return (String) ; }\
70  };\
71  typedef active_##ClassName< Active > ClassName ; \
72 
73 }
74 #endif
Namespace of method for logging messages based on streamlog.
Definition: baselevels.h:20