ldc/gen/logger.h
Frits van Bommel e37c82d1ec Use LLVM OStream wrapper instead of <iostream> in the logger.
llvm::OStream provides all std::ostream functionality (by holding a
std::ostream* internally), but
 * doesn't include <iostream>, avoiding per-file overhead.
 * allows the stream pointer to be null, and the (inlined) operators do nothing
   when that's the case. (This also allows removal of the ofstream("/dev/null")
   hack Logger used when disabled, which presumably wasn't very portable)
2009-02-26 14:51:02 +01:00

37 lines
632 B
C++

#ifndef _llvmd_gen_logger_h_
#define _llvmd_gen_logger_h_
#include "llvm/Support/Streams.h"
struct Loc;
namespace Logger
{
void indent();
void undent();
llvm::OStream cout();
void println(const char* fmt, ...);
void print(const char* fmt, ...);
void enable();
void disable();
bool enabled();
void attention(const Loc& loc, const char* fmt, ...);
struct LoggerScope
{
LoggerScope()
{
Logger::indent();
}
~LoggerScope()
{
Logger::undent();
}
};
}
#define LOG_SCOPE Logger::LoggerScope _logscope;
#endif