/// \file Debug.cpp /// \brief Implementation of the debug framework // // This file is distributed under the MIT License. See LICENSE.md for details. // // Standard includes #include #include #include #include // LLVM includes #include "llvm/IR/Value.h" // Local libraries includes #include "revng/Support/Debug.h" #include "revng/Support/revng.h" namespace cl = llvm::cl; size_t MaxLoggerNameLength = 0; LogTerminator DoLog; llvm::ManagedStatic Loggers; std::ostream &dbg(std::cerr); Logger<> PassesLog("passes"); Logger<> ReleaseLog("release"); template void Logger::emit() { if (X && Enabled) { std::string Pad = std::string(MaxLoggerNameLength - Name.size(), ' '); dbg << "[" << Name.data() << Pad << "] "; for (unsigned I = 0; I < IndentLevel; I++) dbg << " "; dbg << Buffer.str() << "\n"; Buffer.str(""); Buffer.clear(); } } static std::unique_ptr> DebugLogging; static std::unique_ptr DebugLoggingAlias; llvm::ManagedStatic DebugLogOption; template unsigned Logger::IndentLevel; template void Logger::indent(unsigned Level) { if (isEnabled()) IndentLevel += Level; } template void Logger::unindent(unsigned Level) { if (isEnabled()) { revng_assert(IndentLevel - Level >= 0); IndentLevel -= Level; } } template void Logger::setIndentation(unsigned Level) { if (isEnabled()) IndentLevel = Level; } // Force instantiation template class Logger; template class Logger;