view gen/logger.h @ 11:d3ee9efe20e2 trunk

[svn r15] * Fixed a bunch problems with virtual calls. Seems I did some rather poor testing. * Now 50/51 tests compile. * Added a simple runalltests.d scripts that should be run with 'gdmd -run runalltests.d' - LLVMDC will not compile it yet.
author lindquist
date Tue, 02 Oct 2007 05:10:18 +0200
parents c53b6e3fe49a
children 27b2f40bdb58
line wrap: on
line source

#ifndef _llvmd_gen_logger_h_
#define _llvmd_gen_logger_h_

#include <iostream>

namespace Logger
{
    #ifndef LLVMD_NO_LOGGER
    void indent();
    void undent();
    std::ostream& cout();
    void println(const char* fmt,...);
    void print(const char* fmt,...);
    #else
    inline void indent() {}
    inline void undent() {}
    inline std::ostream& cout() { return std::cout; }
    inline void println(const char* fmt, ...) {}
    inline void print(const char* fmt, ...) {}
    #endif

    struct LoggerScope
    {
        LoggerScope()
        {
            #ifndef LLVMD_NO_LOGGER
            //std::cout << "-->indented\n";
            Logger::indent();
            #endif
            
        }
        ~LoggerScope()
        {
            #ifndef LLVMD_NO_LOGGER
            //std::cout << "<--undented\n";
            Logger::undent();
            #endif
        }
    };
}

#ifndef LLVMD_NO_LOGGER
#define LOG_SCOPE    Logger::LoggerScope _logscope;
#else
#define LOG_SCOPE
#endif

#endif