Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | Related Pages

baselevels.h

00001 // -*- mode: c++;
00002 
00003 #ifndef baselevels_h
00004 #define baselevels_h
00005 /* 
00006  *  Define base log level classes for streamlog::logstream. There are the following
00007  *  groups of log level classes: DEBUG, WARNING, MESSAGE and ERROR. 
00008  *  By default all groups are active, except DEBUG when compiled with
00009  *  -DNDEBUG, i.e. in release mode.
00010  *  Through -DSTREAMLOG_LEVEL=N, where N=0,1,2,3,4 this behaviour can be changed, e.g.
00011  *  if -DSTREAMLOG_LEVEL=2 is specified at compile time all messages of the groups
00012  *  DEBUG and MESSAGE are suppressed (no overhead in space or time) and only WARNING
00013  *  and ERROR messages will be visible if the current log level is reached.
00014  *  
00015  *  @author F. Gaede, DESY
00016  *  @version $Id: baselevels.h,v 1.2 2007/07/13 11:09:04 gaede Exp $
00017  */
00018 
00019 
00020 namespace streamlog{
00021 
00022 #define STREAMLOG_MAX_LEVEL 0xFFFFFFFF 
00023     
00024 #ifndef STREAMLOG_LEVEL
00025  #ifndef NDEBUG
00026   #define STREAMLOG_LEVEL 0
00027  #else
00028   #define STREAMLOG_LEVEL 1
00029  #endif
00030 #endif
00031 
00032 #if STREAMLOG_LEVEL > 3
00033   #define STREAMLOG_ERROR_ACTIVE false
00034 #else
00035   #define STREAMLOG_ERROR_ACTIVE true
00036 #endif
00037 
00038 #if STREAMLOG_LEVEL > 2
00039   #define STREAMLOG_WARNING_ACTIVE false
00040 #else
00041   #define STREAMLOG_WARNING_ACTIVE true
00042 #endif
00043 
00044 #if STREAMLOG_LEVEL > 1
00045   #define STREAMLOG_MESSAGE_ACTIVE false
00046 #else
00047   #define STREAMLOG_MESSAGE_ACTIVE true
00048 #endif
00049 
00050 #if STREAMLOG_LEVEL > 0
00051   #define STREAMLOG_DEBUG_ACTIVE false
00052 #else
00053   #define STREAMLOG_DEBUG_ACTIVE true
00054 #endif
00055 
00056   
00057   template <unsigned LEVEL, bool ON>
00058   struct Verbosity{
00059     static const unsigned level = LEVEL ; 
00060     static const bool active = ON ;
00061   } ;
00062 
00063 
00064 
00066 #define DEFINE_STREAMLOG_LEVEL( ClassName, String, LOG_Level, Active )\
00067   template <bool ON>\
00068   struct  active_##ClassName : public Verbosity< (LOG_Level) , ON >{\
00069     static const char* name() { return (String) ; }\
00070   };\
00071   typedef  active_##ClassName< Active > ClassName ; \
00072 
00073 }
00074 #endif

Generated on Mon Jan 12 09:48:50 2009 for Marlin by doxygen 1.3.5