Printer is a static class that allows printing to logs or stdout/stderr.
More...
#include <duckdb.hpp>
|
| static DUCKDB_API void | Print (OutputStream stream, const string &str) |
| | Print the object to the stream.
|
| static DUCKDB_API void | Print (const string &str) |
| | Print the object to stderr.
|
| template<typename... ARGS> |
| static void | PrintF (OutputStream stream, const string &str, ARGS... params) |
| | Print the formatted object to the stream.
|
| template<typename... ARGS> |
| static void | PrintF (const string &str, ARGS... params) |
| | Print the formatted object to stderr.
|
| static DUCKDB_API void | RawPrint (OutputStream stream, const string &str) |
| | Directly prints the string to stdout without a newline.
|
| static DUCKDB_API void | Flush (OutputStream stream) |
| | Flush an output stream.
|
| static DUCKDB_API bool | IsTerminal (OutputStream stream) |
| | Whether or not we are printing to a terminal.
|
| static DUCKDB_API idx_t | TerminalWidth () |
| | The terminal width.
|
|
|
static line_printer_f | line_printer = Printer::DefaultLinePrint |
Printer is a static class that allows printing to logs or stdout/stderr.
◆ Print() [1/2]
| void duckdb::Printer::Print |
( |
OutputStream | stream, |
|
|
const string & | str ) |
|
static |
Print the object to the stream.
92556 {
92557 Printer::line_printer(stream, str);
92558}
◆ Print() [2/2]
| void duckdb::Printer::Print |
( |
const string & | str | ) |
|
|
static |
Print the object to stderr.
92565 {
92567}
static DUCKDB_API void Print(OutputStream stream, const string &str)
Print the object to the stream.
Definition duckdb.cpp:92556
◆ PrintF() [1/2]
template<typename... ARGS>
| void duckdb::Printer::PrintF |
( |
OutputStream | stream, |
|
|
const string & | str, |
|
|
ARGS... | params ) |
|
inlinestatic |
Print the formatted object to the stream.
41937 {
41939 }
static string Format(const string fmt_str, ARGS... params)
Format a string using printf semantics.
Definition duckdb.hpp:4002
PyParams params(const std::string &tag, const std::string &model, const std::string &weights, const std::string &device)
◆ PrintF() [2/2]
template<typename... ARGS>
| void duckdb::Printer::PrintF |
( |
const string & | str, |
|
|
ARGS... | params ) |
|
inlinestatic |
Print the formatted object to stderr.
41942 {
41943 Printer::PrintF(OutputStream::STREAM_STDERR, str, std::forward<ARGS>(params)...);
41944 }
static void PrintF(OutputStream stream, const string &str, ARGS... params)
Print the formatted object to the stream.
Definition duckdb.hpp:41937
◆ RawPrint()
| void duckdb::Printer::RawPrint |
( |
OutputStream | stream, |
|
|
const string & | str ) |
|
static |
Directly prints the string to stdout without a newline.
92535 {
92536#ifndef DUCKDB_DISABLE_PRINT
92537#ifdef DUCKDB_WINDOWS
92539
92540 auto unicode = WindowsUtil::UTF8ToMBCS(str.c_str());
92541 fprintf(stream == OutputStream::STREAM_STDERR ? stderr : stdout, "%s", unicode.c_str());
92542 return;
92543 }
92544#endif
92545 fprintf(stream == OutputStream::STREAM_STDERR ? stderr : stdout, "%s", str.c_str());
92546#endif
92547}
static DUCKDB_API bool IsTerminal(OutputStream stream)
Whether or not we are printing to a terminal.
Definition duckdb.cpp:92569
◆ Flush()
| void duckdb::Printer::Flush |
( |
OutputStream | stream | ) |
|
|
static |
Flush an output stream.
92559 {
92560#ifndef DUCKDB_DISABLE_PRINT
92561 fflush(stream == OutputStream::STREAM_STDERR ? stderr : stdout);
92562#endif
92563}
◆ IsTerminal()
| bool duckdb::Printer::IsTerminal |
( |
OutputStream | stream | ) |
|
|
static |
Whether or not we are printing to a terminal.
92569 {
92570#ifndef DUCKDB_DISABLE_PRINT
92571#ifdef DUCKDB_WINDOWS
92572 auto stream_handle = stream == OutputStream::STREAM_STDERR ? STD_ERROR_HANDLE : STD_OUTPUT_HANDLE;
92573 return GetFileType(GetStdHandle(stream_handle)) == FILE_TYPE_CHAR;
92574#else
92575 return isatty(stream == OutputStream::STREAM_STDERR ? 2 : 1);
92576#endif
92577#else
92578 throw InternalException("IsTerminal called while printing is disabled");
92579#endif
92580}
◆ TerminalWidth()
| idx_t duckdb::Printer::TerminalWidth |
( |
| ) |
|
|
static |
The terminal width.
92582 {
92583#ifndef DUCKDB_DISABLE_PRINT
92584#ifdef DUCKDB_WINDOWS
92585 CONSOLE_SCREEN_BUFFER_INFO csbi;
92587
92588 GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
92589 rows = csbi.srWindow.Right - csbi.srWindow.Left + 1;
92591#else
92592 struct winsize w;
92593 ioctl(0, TIOCGWINSZ, &w);
92594 return w.ws_col;
92595#endif
92596#else
92597 throw InternalException("TerminalWidth called while printing is disabled");
92598#endif
92599}
◆ DefaultLinePrint()
| void duckdb::Printer::DefaultLinePrint |
( |
OutputStream | stream, |
|
|
const string & | str ) |
|
staticprivate |
92549 {
92551}
static DUCKDB_API void RawPrint(OutputStream stream, const string &str)
Directly prints the string to stdout without a newline.
Definition duckdb.cpp:92535
The documentation for this class was generated from the following files: