Mercurial > projects > ldc
comparison gen/logger.h @ 1:c53b6e3fe49a trunk
[svn r5] Initial commit. Most things are very rough.
author | lindquist |
---|---|
date | Sat, 01 Sep 2007 21:43:27 +0200 |
parents | |
children | 27b2f40bdb58 |
comparison
equal
deleted
inserted
replaced
0:a9e71648e74d | 1:c53b6e3fe49a |
---|---|
1 #ifndef _llvmd_gen_logger_h_ | |
2 #define _llvmd_gen_logger_h_ | |
3 | |
4 #include <iostream> | |
5 | |
6 namespace Logger | |
7 { | |
8 #ifndef LLVMD_NO_LOGGER | |
9 void indent(); | |
10 void undent(); | |
11 std::ostream& cout(); | |
12 void println(const char* fmt,...); | |
13 void print(const char* fmt,...); | |
14 #else | |
15 inline void indent() {} | |
16 inline void undent() {} | |
17 inline std::ostream& cout() { return std::cout; } | |
18 inline void println(const char* fmt, ...) {} | |
19 inline void print(const char* fmt, ...) {} | |
20 #endif | |
21 | |
22 struct LoggerScope | |
23 { | |
24 LoggerScope() | |
25 { | |
26 #ifndef LLVMD_NO_LOGGER | |
27 //std::cout << "-->indented\n"; | |
28 Logger::indent(); | |
29 #endif | |
30 | |
31 } | |
32 ~LoggerScope() | |
33 { | |
34 #ifndef LLVMD_NO_LOGGER | |
35 //std::cout << "<--undented\n"; | |
36 Logger::undent(); | |
37 #endif | |
38 } | |
39 }; | |
40 } | |
41 | |
42 #ifndef LLVMD_NO_LOGGER | |
43 #define LOG_SCOPE Logger::LoggerScope _logscope; | |
44 #else | |
45 #define LOG_SCOPE | |
46 #endif | |
47 | |
48 #endif |