Mercurial > projects > ldc
comparison gen/logger.cpp @ 131:5825d48b27d1 trunk
[svn r135] * Merged DMD 1.025 *
* Fixed a minor linking order mishap *
* Added an command line option -annotate *
* Fixed some problems with running optimizations *
* Added std.stdio and dependencies to lphobos (still not 100% working, but compiles and links) *
* Fixed problems with passing aggregate types to variadic functions *
* Added initial code towards full GC support, currently based on malloc and friends, not all the runtime calls the GC yet for memory *
* Fixed problems with resolving nested function context pointers for some heavily nested cases *
* Redid function argument passing + other minor code cleanups, still lots to do on this end... *
author | lindquist |
---|---|
date | Fri, 04 Jan 2008 01:38:42 +0100 |
parents | 027b8d8b71ec |
children | 1700239cab2e |
comparison
equal
deleted
inserted
replaced
130:a7dfa0ed966c | 131:5825d48b27d1 |
---|---|
11 namespace Logger | 11 namespace Logger |
12 { | 12 { |
13 static std::string indent_str; | 13 static std::string indent_str; |
14 static std::ofstream null_out("/dev/null"); | 14 static std::ofstream null_out("/dev/null"); |
15 | 15 |
16 static bool enabled = false; | 16 static bool _enabled = false; |
17 void indent() | 17 void indent() |
18 { | 18 { |
19 if (enabled) { | 19 if (_enabled) { |
20 indent_str += "* "; | 20 indent_str += "* "; |
21 } | 21 } |
22 } | 22 } |
23 void undent() | 23 void undent() |
24 { | 24 { |
25 if (enabled) { | 25 if (_enabled) { |
26 assert(!indent_str.empty()); | 26 assert(!indent_str.empty()); |
27 indent_str.resize(indent_str.size()-2); | 27 indent_str.resize(indent_str.size()-2); |
28 } | 28 } |
29 } | 29 } |
30 std::ostream& cout() | 30 std::ostream& cout() |
31 { | 31 { |
32 if (enabled) | 32 if (_enabled) |
33 return std::cout << indent_str; | 33 return std::cout << indent_str; |
34 else | 34 else |
35 return null_out; | 35 return null_out; |
36 } | 36 } |
37 void println(const char* fmt,...) | 37 void println(const char* fmt,...) |
38 { | 38 { |
39 if (enabled) { | 39 if (_enabled) { |
40 printf(indent_str.c_str()); | 40 printf(indent_str.c_str()); |
41 va_list va; | 41 va_list va; |
42 va_start(va,fmt); | 42 va_start(va,fmt); |
43 vprintf(fmt,va); | 43 vprintf(fmt,va); |
44 va_end(va); | 44 va_end(va); |
45 printf("\n"); | 45 printf("\n"); |
46 } | 46 } |
47 } | 47 } |
48 void print(const char* fmt,...) | 48 void print(const char* fmt,...) |
49 { | 49 { |
50 if (enabled) { | 50 if (_enabled) { |
51 printf(indent_str.c_str()); | 51 printf(indent_str.c_str()); |
52 va_list va; | 52 va_list va; |
53 va_start(va,fmt); | 53 va_start(va,fmt); |
54 vprintf(fmt,va); | 54 vprintf(fmt,va); |
55 va_end(va); | 55 va_end(va); |
56 } | 56 } |
57 } | 57 } |
58 void enable() | 58 void enable() |
59 { | 59 { |
60 enabled = true; | 60 _enabled = true; |
61 } | 61 } |
62 void disable() | 62 void disable() |
63 { | 63 { |
64 enabled = false; | 64 _enabled = false; |
65 } | |
66 bool enabled() | |
67 { | |
68 return _enabled; | |
65 } | 69 } |
66 void attention(const char* fmt,...) | 70 void attention(const char* fmt,...) |
67 { | 71 { |
68 printf("***ATTENTION*** "); | 72 printf("***ATTENTION*** "); |
69 va_list va; | 73 va_list va; |