Luiza  v03-01
streamlog.h
1 // -*- mode: c++;
2 #ifndef streamlog_h
3 #define streamlog_h
4 
15 #ifndef DONT_USE_STREAMLOG
16 #define USE_STREAMLOG
17 #endif
18 
19 #ifdef USE_STREAMLOG
20 
21 #include "logstream.h"
22 #include "logscope.h"
23 #include "loglevels.h"
24 
25 
26 #define streamlog_level( MLEVEL ) ( streamlog::out.would_write< streamlog::MLEVEL >() )
27 
28 
29 #define streamlog_out( MLEVEL ) if(streamlog::out.write< streamlog::MLEVEL >() ) streamlog::out()
30 
31 
32 #define streamlog_message( MLEVEL , CODE_BLOCK , OUT_MESSAGE)\
33  if( streamlog::out.write< streamlog::MLEVEL >() ) { \
34  CODE_BLOCK \
35  streamlog::out() << OUT_MESSAGE }
36 
37 //for use in templated classes with gcc 3.2 use these macros:
38 #define streamlog_out_T( MLEVEL ) if(streamlog::out.template write< streamlog::MLEVEL >() ) streamlog::out()
39 
40 #define streamlog_message_T( MLEVEL , CODE_BLOCK , OUT_MESSAGE)\
41  if( streamlog::out.template write< streamlog::MLEVEL >() ) { \
42  CODE_BLOCK \
43  streamlog::out() << OUT_MESSAGE }
44 
45 #else
46 
47 #define streamlog_out( MLEVEL ) std::cout
48 
49 #define streamlog_message( MLEVEL , CODE_BLOCK , OUT_MESSAGE)\
50  if( true ) { \
51  CODE_BLOCK \
52  std::out << OUT_MESSAGE }
53 
54 #endif
55 
56 
57 #endif