view 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
line wrap: on
line source

#ifndef LLVMD_NO_LOGGER

#include <cassert>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>

#include "gen/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