Go to the documentation of this file.
15 #include <util/pragma_push.def>
17 #pragma warning(disable:4668)
24 #include <util/pragma_pop.def>
42 : always_flush(_always_flush), is_a_tty(false), use_SGR(false)
45 HANDLE out_handle=GetStdHandle(STD_OUTPUT_HANDLE);
48 if(GetConsoleMode(out_handle, &consoleMode))
52 #ifdef ENABLE_VIRTUAL_TERMINAL_PROCESSING
53 consoleMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
54 if(SetConsoleMode(out_handle, consoleMode))
77 const std::string &message)
86 GetStdHandle((level>1)?STD_OUTPUT_HANDLE:STD_ERROR_HANDLE);
92 if(GetConsoleMode(out_handle, &consoleMode))
95 std::wstring wide_message=
widen(message);
100 out_handle, wide_message.c_str(),
101 (DWORD)wide_message.size(), &number_written, NULL);
103 WriteConsoleW(out_handle, L
"\r\n", 2, &number_written, NULL);
111 std::cout << message <<
'\n';
114 std::cerr << message <<
'\n';
122 std::cout << message <<
'\n';
125 std::cerr << message <<
'\n';
137 std::cout << std::flush;
140 std::cerr << std::flush;
145 const std::string &message,
153 auto &out = std::cerr;
160 if(!
function.empty())
181 out << column <<
": ";
191 out << message <<
'\n';
193 const auto file_name = location.
full_path();
194 if(file_name.has_value() && !line.
empty())
197 std::ifstream in(
widen(file_name.value()));
199 std::ifstream in(file_name.value());
203 const auto line_number = std::stoull(
id2string(line));
204 std::string source_line;
205 for(std::size_t l = 0; l < line_number; l++)
206 std::getline(in, source_line);
209 out <<
' ' << source_line <<
'\n';
219 const std::string &message)
225 std::cerr << message <<
'\n' << std::flush;
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
const irep_idt & get_function() const
void print(unsigned, const xmlt &) override
bool use_SGR
true if we use ECMA-48 SGR to render colors
static const commandt reset
return to default formatting, as defined by the terminal
const irep_idt & get_column() const
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
const irep_idt & get_line() const
virtual void print(unsigned level, const std::string &message)=0
virtual void flush(unsigned level) override
static const commandt bright_magenta
render text with bright magenta foreground color
static const commandt bold
render text with bold font
std::string string(const messaget::commandt &c) const
feed a command into a string
const std::string & id2string(const irep_idt &d)
bool is_a_tty
true if we are outputting to a proper console
optionalt< std::string > full_path() const
Get a path to the file, including working directory.
std::wstring widen(const char *s)
static const commandt red
render text with red foreground color
void print(unsigned, const xmlt &) override
const irep_idt & get_file() const
console_message_handlert()
std::string command(unsigned c) const override
Create an ECMA-48 SGR (Select Graphic Rendition) command with given code.