mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-09-03 03:07:56 +00:00
rate limit some error messages
This commit is contained in:
11
hprint.cpp
11
hprint.cpp
@@ -575,4 +575,15 @@ EX vector<string> split_string(const string& s, char sep) {
|
||||
return res;
|
||||
}
|
||||
|
||||
map<string, int> last_rlerr;
|
||||
int err_freq = 10000;
|
||||
|
||||
EX void rate_limited_error(const string& s, const string& t IS("")) {
|
||||
auto& last = last_rlerr[s];
|
||||
if(!last || ticks > last + err_freq) {
|
||||
last = ticks;
|
||||
println(hlog, s, t);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user