Files
concrete/compiler/lib/Support/logging.cpp
Andi Drebes b9e2690823 refactor(compiler): Replace LOG_{VERBOSE,ERROR} macros with C++-style streams
Replace the macros `LOG_VERBOSE` and `LOG_ERROR` with C++-style
streams retrieved through `log_verbose()` and `log_error()`. This
aligns with the `MLIR` infrastructure and avoids pollution of the
global namespace through a common header file in subsequent
refactoring commits splitting the functionality of `src/main.cpp` into
multiple files.
2021-09-28 11:35:58 +02:00

23 lines
757 B
C++

#include <zamalang/Support/logging.h>
namespace mlir {
namespace zamalang {
static bool verbose = false;
static StreamWrap<llvm::raw_ostream> errWrap(&llvm::errs());
static StreamWrap<llvm::raw_ostream> nullWrap(&llvm::nulls());
// Returns a stream for logging errors
StreamWrap<llvm::raw_ostream> &log_error(void) { return errWrap; }
// Returns a stream that either shows or discards messages depending
// on the setup through `setupLogging`.
StreamWrap<llvm::raw_ostream> &log_verbose(void) {
return (verbose) ? errWrap : nullWrap;
}
// Sets up logging. If `verbose` is false, messages passed to
// `log_verbose` will be discarded.
void setupLogging(bool verbose) { ::mlir::zamalang::verbose = verbose; }
} // namespace zamalang
} // namespace mlir