mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-09 12:32:33 +03:00

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)
37 lines
632 B
C++
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
|
|
|