1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-08-25 15:02:19 +00:00

rate limit some error messages

This commit is contained in:
Zeno Rogue 2025-04-08 13:50:21 +02:00
parent 019711f818
commit 9521a01999
3 changed files with 16 additions and 7 deletions

View File

@ -56,9 +56,8 @@ EX }
EX void glError(const char* GLcall, const char* file, const int line) {
GLenum errCode = glGetError();
if(errCode!=GL_NO_ERROR) {
println(hlog, hr::format("OPENGL ERROR #%i: in file %s on line %i :: %s",errCode,file, line, GLcall));
}
if(errCode!=GL_NO_ERROR)
rate_limited_error(hr::format("OPENGL ERROR #%i: in file %s on line %i :: %s",errCode,file, line, GLcall));
}
#if HDR
@ -74,9 +73,8 @@ struct glwrap {
void glwrap::act(const char *when) {
GLenum errCode = glGetError();
if(errCode!=GL_NO_ERROR) {
println(hlog, hr::format("GL error %i %s: %s:%i", errCode, when, msg, line));
}
if(errCode!=GL_NO_ERROR)
rate_limited_error(hr::format("GL error %i %s: %s:%i", errCode, when, msg, line));
}
#if HDR

View File

@ -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);
}
}
}

View File

@ -1122,7 +1122,7 @@ EX ld det(const transmatrix& T) {
/** warning about incorrect inverse */
void inverse_error(const transmatrix& T) {
println(hlog, "Warning: inverting a singular matrix: ", T);
rate_limited_error("Warning: inverting a singular matrix", lalign(0, ": ", T));
}
/** inverse of a 3x3 matrix */