Google OR-Tools: ortools/util/logging.cc Source File
24#include "absl/strings/str_cat.h"
25#include "absl/strings/str_format.h"
26#include "absl/strings/str_join.h"
31 std::string s = absl::StrCat(num);
34 for (int i = 0; i < size; ++i) {
46 std::function<void(const std::string& message)> callback) {
53 const std::string& message) {
55 std::cout << message << std::endl;
69bool SolverLogger::RateIsOk(const ThrottlingData& data) {
70 const double time = std::max(1.0, timer_.Get());
72 static_cast<double>(data.num_displayed_logs - throttling_threshold_) /
74 return rate < throttling_rate_;
79 ThrottlingData& data = id_to_throttling_data_[id];
81 if (data.num_last_skipped_logs > 0) {
84 " [skipped_logs=", data.num_last_skipped_logs, "]"));
88 data.UpdateWhenDisplayed();
90 data.num_last_skipped_logs++;
100 for (int id = 0; id < id_to_throttling_data_.size(); ++id) {
101 ThrottlingData& data = id_to_throttling_data_[id];
102 if (data.num_last_skipped_logs == 0) continue;
103 if (ignore_rates || RateIsOk(data)) {
106 absl::StrCat(data.last_skipped_message, " [skipped_logs=",
107 data.num_last_skipped_logs - 1, "]"));
114 time_limit_->AdvanceDeterministicTime(work_);
116 time_limit_->GetElapsedDeterministicTime() - dtime_at_start_;
118 std::string counter_string;
119 for (const auto& [counter_name, count] : counters_) {
120 absl::StrAppend(&counter_string, " #", counter_name, "=",
125 if (override_logging_ ? log_when_override_ : logger_->LoggingIsEnabled()) {
128 absl::StrCat(absl::StrFormat(" %.2es", timer_.Get()),
129 absl::StrFormat(" %.2ed", dtime),
131 counter_string, " ", absl::StrJoin(extra_infos_, " ")));
~PresolveTimer()
Definition logging.cc:113
bool WorkLimitIsReached() const
void ThrottledLog(int id, const std::string &message)
Definition logging.cc:77
SolverLogger()
Definition logging.cc:43
void FlushPendingThrottledLogs(bool ignore_rates=false)
Definition logging.cc:95
int GetNewThrottledId()
Definition logging.cc:63
void AddInfoLoggingCallback(std::function< void(const std::string &message)> callback)
Definition logging.cc:45
void ClearInfoLoggingCallbacks()
Definition logging.cc:50
void LogInfo(const char *source_filename, int source_line, const std::string &message)
Definition logging.cc:52
std::string FormatCounter(int64_t num)
Definition logging.cc:30