| 397 | } |
| 398 | |
| 399 | BCLog::LogRateLimiter::Status BCLog::LogRateLimiter::Consume( |
| 400 | const SourceLocation& source_loc, |
| 401 | const std::string& str) |
| 402 | { |
| 403 | STDLOCK(m_mutex); |
| 404 | auto& stats{m_source_locations.try_emplace(source_loc, m_max_bytes).first->second}; |
| 405 | Status status{stats.m_dropped_bytes > 0 ? Status::STILL_SUPPRESSED : Status::UNSUPPRESSED}; |
| 406 | |
| 407 | if (!stats.Consume(str.size()) && status == Status::UNSUPPRESSED) { |
| 408 | status = Status::NEWLY_SUPPRESSED; |
| 409 | m_suppression_active = true; |
| 410 | } |
| 411 | |
| 412 | return status; |
| 413 | } |
| 414 | |
| 415 | std::string BCLog::Logger::Format(const util::log::Entry& entry) const |
| 416 | { |