33 #define FMT_HEADER_ONLY 1 34 #define FMT_STRING_ALIAS 1 35 #include <fmt/format.h> 36 #include <fmt/printf.h> 37 #include <fmt/ranges.h> 39 #define DEFAULT_IO_BUFFER_SIZE 1024 79 void operator=(
Logger const &) =
delete;
86 void VError[[noreturn]](
const char *
format, fmt::format_args args)
const {
87 std::string err_msg = fmt::vformat(format, args);
88 err_msg =
fmt::format(
"[Open3D ERROR] {}", err_msg);
89 err_msg = ColorString(err_msg, TextColor::Red, 1);
90 throw std::runtime_error(err_msg);
93 void VWarning(
const char *format, fmt::format_args args)
const {
95 std::string err_msg = fmt::vformat(format, args);
96 err_msg =
fmt::format(
"[Open3D WARNING] {}", err_msg);
97 err_msg = ColorString(err_msg, TextColor::Yellow, 1);
102 void VInfo(
const char *format, fmt::format_args args)
const {
104 std::string err_msg = fmt::vformat(format, args);
105 err_msg =
fmt::format(
"[Open3D INFO] {}", err_msg);
110 void VDebug(
const char *format, fmt::format_args args)
const {
112 std::string err_msg = fmt::vformat(format, args);
113 err_msg =
fmt::format(
"[Open3D DEBUG] {}", err_msg);
118 template <
typename...
Args>
120 VError(format, fmt::make_format_args(args...));
123 template <
typename...
Args>
125 VWarning(format, fmt::make_format_args(args...));
128 template <
typename...
Args>
129 void Info(
const char *format,
const Args &... args)
const {
130 VInfo(format, fmt::make_format_args(args...));
133 template <
typename...
Args>
134 void Debug(
const char *format,
const Args &... args)
const {
135 VDebug(format, fmt::make_format_args(args...));
144 void ChangeConsoleColor(
TextColor text_color,
int highlight_text)
const;
145 void ResetConsoleColor()
const;
147 std::string ColorString(
const std::string &text,
149 int highlight_text)
const;
153 std::function<void(const std::string &)> print_fcn_ =
154 [](
const std::string &msg) {
173 template <
typename...
Args>
178 template <
typename...
Args>
183 template <
typename...
Args>
188 template <
typename...
Args>
212 const std::string &progress_info,
213 bool active =
false) {
214 reset(expected_count, progress_info, active);
218 const std::string &progress_info,
220 expected_count_ = expected_count;
221 current_count_ =
static_cast<size_t>(-1);
222 progress_info_ = progress_info;
233 if (current_count_ >= expected_count_) {
234 fmt::print(
"{}[{}] 100%\n", progress_info_,
235 std::string(resolution_,
'='));
237 size_t new_progress_pixel =
238 int(current_count_ * resolution_ / expected_count_);
239 if (new_progress_pixel > progress_pixel_) {
240 progress_pixel_ = new_progress_pixel;
241 int percent =
int(current_count_ * 100 / expected_count_);
242 fmt::print(
"{}[{}>{}] {:d}%\r", progress_info_,
243 std::string(progress_pixel_,
'='),
244 std::string(resolution_ - 1 - progress_pixel_,
' '),
253 const size_t resolution_ = 40;
254 size_t expected_count_;
255 size_t current_count_;
256 std::string progress_info_;
257 size_t progress_pixel_;
265 const std::string &option,
270 const std::string &option,
275 const std::string &option,
281 const std::string &option,
282 const Eigen::VectorXd
default_value = Eigen::VectorXd::Zero(0));
288 const std::vector<std::string> &options);
void VError(const char *format, fmt::format_args args) const
Definition: Console.h:86
std::string GetProgramOptionAsString(int argc, char **argv, const std::string &option, const std::string &default_value)
Definition: Console.cpp:104
void Info(const char *format, const Args &... args) const
Definition: Console.h:129
Definition: Console.h:193
VerbosityContextManager(VerbosityLevel level)
Definition: Console.h:195
void exit()
Definition: Console.h:202
double GetProgramOptionAsDouble(int argc, char **argv, const std::string &option, const double default_value)
Definition: Console.cpp:137
ConsoleProgressBar & operator++()
Definition: Console.h:228
Logger()
Definition: Console.h:77
void LogError(const char *format, const Args &... args)
Definition: Console.h:174
void LogWarning(const char *format, const Args &... args)
Definition: Console.h:179
void Debug(const char *format, const Args &... args) const
Definition: Console.h:134
bool ProgramOptionExistsAny(int argc, char **argv, const std::vector< std::string > &options)
Definition: Console.cpp:189
void VWarning(const char *format, fmt::format_args args) const
Definition: Console.h:93
TextColor
Definition: Console.h:66
void VInfo(const char *format, fmt::format_args args) const
Definition: Console.h:102
void LogDebug(const char *format, const Args &... args)
Definition: Console.h:189
std::string GetCurrentTimeStamp()
Definition: Console.cpp:99
VerbosityLevel GetVerbosityLevel()
Get global verbosity level of Open3D.
Definition: Console.h:169
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t timeout_in_ms capture_handle capture_handle capture_handle image_handle temperature_c int
Definition: K4aPlugin.cpp:475
int GetProgramOptionAsInt(int argc, char **argv, const std::string &option, const int default_value)
Definition: Console.cpp:116
VerbosityLevel
Definition: Console.h:44
void enter()
Definition: Console.h:197
void SetVerbosityLevel(VerbosityLevel level)
Definition: Console.h:164
Definition: Open3DViewer.h:29
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t timeout_in_ms capture_handle capture_handle capture_handle image_handle temperature_c k4a_image_t image_handle uint8_t image_handle image_handle image_handle image_handle image_handle timestamp_usec white_balance image_handle k4a_device_configuration_t config device_handle char size_t serial_number_size bool int32_t int32_t int32_t int32_t default_value
Definition: K4aPlugin.cpp:644
void Warning(const char *format, const Args &... args) const
Definition: Console.h:124
ConsoleProgressBar(size_t expected_count, const std::string &progress_info, bool active=false)
Definition: Console.h:211
filament::Texture::InternalFormat format
Definition: FilamentResourceManager.cpp:155
static Logger & i()
Definition: Console.h:81
void VDebug(const char *format, fmt::format_args args) const
Definition: Console.h:110
void reset(size_t expected_count, const std::string &progress_info, bool active)
Definition: Console.h:217
Eigen::VectorXd GetProgramOptionAsEigenVectorXd(int argc, char **argv, const std::string &option, const Eigen::VectorXd default_value)
Definition: Console.cpp:156
Definition: Console.h:209
VerbosityLevel verbosity_level_
Definition: Console.h:152
bool ProgramOptionExists(int argc, char **argv, const std::string &option)
Definition: Console.cpp:185
void LogInfo(const char *format, const Args &... args)
Definition: Console.h:184