Mercurial > projects > ldc
annotate gen/logger.c @ 4:e116aa1488e6 trunk
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
fixed passing string literals as array parameters
few other fixes
moved some array routines into gen/arrays
author | lindquist |
---|---|
date | Mon, 03 Sep 2007 17:34:30 +0200 |
parents | c53b6e3fe49a |
children | 27b2f40bdb58 |
rev | line source |
---|---|
1 | 1 #ifndef LLVMD_NO_LOGGER |
2 | |
3 #include <cassert> | |
4 #include <cstdarg> | |
5 #include <cstdio> | |
6 #include <cstdlib> | |
7 #include <iostream> | |
8 #include <string> | |
9 | |
4
e116aa1488e6
[svn r8] changed backend includes to always use the gen/<foo>.h prefix
lindquist
parents:
1
diff
changeset
|
10 #include "gen/logger.h" |
1 | 11 |
12 namespace Logger | |
13 { | |
14 static std::string indent_str; | |
15 void indent() | |
16 { | |
17 indent_str += " "; | |
18 } | |
19 void undent() | |
20 { | |
21 assert(!indent_str.empty()); | |
22 indent_str.resize(indent_str.size()-2); | |
23 } | |
24 std::ostream& cout() | |
25 { | |
26 return std::cout << indent_str; | |
27 } | |
28 void println(const char* fmt,...) | |
29 { | |
30 printf(indent_str.c_str()); | |
31 va_list va; | |
32 va_start(va,fmt); | |
33 vprintf(fmt,va); | |
34 va_end(va); | |
35 printf("\n"); | |
36 } | |
37 void print(const char* fmt,...) | |
38 { | |
39 printf(indent_str.c_str()); | |
40 va_list va; | |
41 va_start(va,fmt); | |
42 vprintf(fmt,va); | |
43 va_end(va); | |
44 } | |
45 } | |
46 | |
47 #endif |