Google OR-Tools: ortools/util/logging.h Source File
14#ifndef ORTOOLS_UTIL_LOGGING_H_
15#define ORTOOLS_UTIL_LOGGING_H_
22#include "absl/strings/str_cat.h"
63 std::function<void(const std::string& message)> callback);
72 void LogInfo(const char* source_filename, int source_line,
73 const std::string& message);
79 void ThrottledLog(int id, const std::string& message);
88 int64_t num_displayed_logs = 0;
89 int64_t num_last_skipped_logs = 0;
90 std::string last_skipped_message;
92 void UpdateWhenDisplayed() {
98 bool RateIsOk(const ThrottlingData& data);
101 bool log_to_stdout_ = false;
102 std::vector<std::function<void(const std::string& message)>> info_callbacks_;
107 const int throttling_threshold_ = 20;
108 const double throttling_rate_ = 1.0;
114#define SOLVER_LOG(logger, ...) \
115 if ((logger)->LoggingIsEnabled()) \
116 (logger)->LogInfo(__FILE__, __LINE__, absl::StrCat(__VA_ARGS__))
118#define FORCED_SOLVER_LOG(logger, ...) \
119 (logger)->LogInfo(__FILE__, __LINE__, absl::StrCat(__VA_ARGS__))
130 : name_(std::move(name)),
131 dtime_at_start_(time_limit->GetElapsedDeterministicTime()),
139 void AddToWork(double dtime) { work_ += dtime; }
147 void AddCounter(std::string name, int64_t count) {
153 void AddMessage(std::string name) { extra_infos_.push_back(std::move(name)); }
166 double wtime() const { return timer_.Get(); }
170 const double dtime_at_start_;
176 bool override_logging_ = false;
177 bool log_when_override_ = false;
179 std::vector<std::pair<std::string, int64_t>> counters_;
void AddMessage(std::string name)
Definition logging.h:153
void OverrideLogging(bool value)
Definition logging.h:160
double deterministic_time() const
Definition logging.h:165
void TrackSimpleLoop(int size)
Definition logging.h:140
double wtime() const
Definition logging.h:166
void AddCounter(std::string name, int64_t count)
Definition logging.h:147
void AddToWork(double dtime)
Definition logging.h:139
PresolveTimer(std::string name, SolverLogger *logger, TimeLimit *time_limit)
Definition logging.h:129
void TrackFastLoop(int size)
Definition logging.h:142
void TrackHashLookups(int size)
Definition logging.h:141
bool WorkLimitIsReached() const
Definition logging.h:143
void EnableLogging(bool enable)
Definition logging.h:51
void ThrottledLog(int id, const std::string &message)
void SetLogToStdOut(bool enable)
Definition logging.h:57
void FlushPendingThrottledLogs(bool ignore_rates=false)
bool LoggingIsEnabled() const
Definition logging.h:54
void AddInfoLoggingCallback(std::function< void(const std::string &message)> callback)
void ClearInfoLoggingCallbacks()
int NumInfoLoggingCallbacks() const
Definition logging.h:69
void LogInfo(const char *source_filename, int source_line, const std::string &message)
std::string FormatCounter(int64_t num)