14#ifndef OR_TOOLS_UTIL_LOGGING_H_
15#define OR_TOOLS_UTIL_LOGGING_H_
67 void LogInfo(
const char* source_filename,
int source_line,
82 struct ThrottlingData {
83 int64_t num_displayed_logs = 0;
84 int64_t num_last_skipped_logs = 0;
85 std::string last_skipped_message;
87 void UpdateWhenDisplayed() {
89 num_last_skipped_logs = 0;
90 last_skipped_message =
"";
93 bool RateIsOk(
const ThrottlingData& data);
95 bool is_enabled_ =
false;
96 bool log_to_stdout_ =
false;
97 std::vector<std::function<void(
const std::string&
message)>> info_callbacks_;
102 const int throttling_threshold_ = 20;
103 const double throttling_rate_ = 1.0;
106 std::vector<ThrottlingData> id_to_throttling_data_;
109#define SOLVER_LOG(logger, ...) \
110 if ((logger)->LoggingIsEnabled()) \
111 (logger)->LogInfo(__FILE__, __LINE__, absl::StrCat(__VA_ARGS__))
void EnableLogging(bool enable)
void ThrottledLog(int id, const std::string &message)
void SetLogToStdOut(bool enable)
Should all messages be displayed on stdout ?
void FlushPendingThrottledLogs(bool ignore_rates=false)
bool LoggingIsEnabled() const
Returns true iff logging is enabled.
void AddInfoLoggingCallback(std::function< void(const std::string &message)> callback)
void ClearInfoLoggingCallbacks()
Removes all callbacks registered via AddInfoLoggingCallback().
int NumInfoLoggingCallbacks() const
Returns the number of registered callbacks.
void LogInfo(const char *source_filename, int source_line, const std::string &message)
Logs a given information message and dispatch it to all callbacks.
In SWIG mode, we don't want anything besides these top-level includes.