| 1 | //===----------------------------------------------------------------------===// |
| 2 | // DuckDB |
| 3 | // |
| 4 | // duckdb/common/printer.hpp |
| 5 | // |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #pragma once |
| 10 | |
| 11 | #include "duckdb/common/common.hpp" |
| 12 | |
| 13 | namespace duckdb { |
| 14 | |
| 15 | enum class OutputStream : uint8_t { STREAM_STDOUT = 1, STREAM_STDERR = 2 }; |
| 16 | |
| 17 | //! Printer is a static class that allows printing to logs or stdout/stderr |
| 18 | class Printer { |
| 19 | public: |
| 20 | //! Print the object to the stream |
| 21 | DUCKDB_API static void Print(OutputStream stream, const string &str); |
| 22 | //! Print the object to stderr |
| 23 | DUCKDB_API static void Print(const string &str); |
| 24 | //! Directly prints the string to stdout without a newline |
| 25 | DUCKDB_API static void RawPrint(OutputStream stream, const string &str); |
| 26 | //! Flush an output stream |
| 27 | DUCKDB_API static void Flush(OutputStream stream); |
| 28 | //! Whether or not we are printing to a terminal |
| 29 | DUCKDB_API static bool IsTerminal(OutputStream stream); |
| 30 | //! The terminal width |
| 31 | DUCKDB_API static idx_t TerminalWidth(); |
| 32 | }; |
| 33 | } // namespace duckdb |
| 34 | |