Mercurial > projects > ldc
comparison gen/logger.c @ 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 | e116aa1488e6 |
comparison
equal
deleted
inserted
replaced
0:a9e71648e74d | 1:c53b6e3fe49a |
---|---|
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 | |
10 #include "logger.h" | |
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 |