Mercurial > projects > ldc
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gen/logger.c Sat Sep 01 21:43:27 2007 +0200 @@ -0,0 +1,47 @@ +#ifndef LLVMD_NO_LOGGER + +#include <cassert> +#include <cstdarg> +#include <cstdio> +#include <cstdlib> +#include <iostream> +#include <string> + +#include "logger.h" + +namespace Logger +{ + static std::string indent_str; + void indent() + { + indent_str += " "; + } + void undent() + { + assert(!indent_str.empty()); + indent_str.resize(indent_str.size()-2); + } + std::ostream& cout() + { + return std::cout << indent_str; + } + void println(const char* fmt,...) + { + printf(indent_str.c_str()); + va_list va; + va_start(va,fmt); + vprintf(fmt,va); + va_end(va); + printf("\n"); + } + void print(const char* fmt,...) + { + printf(indent_str.c_str()); + va_list va; + va_start(va,fmt); + vprintf(fmt,va); + va_end(va); + } +} + +#endif