mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-04-17 17:29:02 +02:00
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)
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
@@ -14,7 +13,6 @@
|
||||
namespace Logger
|
||||
{
|
||||
static std::string indent_str;
|
||||
static std::ofstream null_out("/dev/null");
|
||||
|
||||
llvm::cl::opt<bool> _enabled("vv",
|
||||
llvm::cl::desc("Very verbose"),
|
||||
@@ -33,12 +31,12 @@ namespace Logger
|
||||
indent_str.resize(indent_str.size()-2);
|
||||
}
|
||||
}
|
||||
std::ostream& cout()
|
||||
llvm::OStream cout()
|
||||
{
|
||||
if (_enabled)
|
||||
return std::cout << indent_str;
|
||||
return llvm::cout << indent_str;
|
||||
else
|
||||
return null_out;
|
||||
return 0;
|
||||
}
|
||||
void println(const char* fmt,...)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user