diff --git a/libc/log/log.h b/libc/log/log.h index 8e963c8cf..c19223515 100644 --- a/libc/log/log.h +++ b/libc/log/log.h @@ -72,6 +72,14 @@ extern unsigned __log_level; /* log level for runtime check */ ((!__builtin_constant_p(LEVEL) || (LEVEL) <= LOGGABLELEVEL) && \ (LEVEL) <= __log_level) +// log a message with the specified log level (not checking if LOGGABLE) +#define ANYF(LEVEL, FMT, ...) \ + do { \ + ++ftrace; \ + flogf(LEVEL, __FILE__, __LINE__, NULL, FMT, ##__VA_ARGS__); \ + --ftrace; \ + } while (0) + // die with an error message without backtrace and debugger invocation #define DIEF(FMT, ...) \ do { \ diff --git a/tool/net/redbean.c b/tool/net/redbean.c index 8ad8f814d..9e2381dcf 100644 --- a/tool/net/redbean.c +++ b/tool/net/redbean.c @@ -1118,7 +1118,7 @@ static void ReportWorkerResources(int pid, struct rusage *ru) { AppendResourceReport(&b, ru, "\n"); if (b) { if ((s = IndentLines(b, appendz(b).i - 1, 0, 1))) { - DEBUGF("(stat) resource report for pid %d\n%s", pid, s); + ANYF(kLogDebug, "(stat) resource report for pid %d\n%s", pid, s); free(s); } free(b); @@ -6122,8 +6122,8 @@ static bool HandleMessageAcutal(void) { LockInc(&shared->c.messageshandled); ++messageshandled; if (loglatency || LOGGABLE(kLogDebug)) { - DEBUGF("(stat) %`'.*s latency %,ldµs", msg.uri.b - msg.uri.a, inbuf.p + msg.uri.a, - (long)((nowl() - startrequest) * 1e6L)); + ANYF(kLogDebug, "(stat) %`'.*s latency %,ldµs", msg.uri.b - msg.uri.a, inbuf.p + msg.uri.a, + (long)((nowl() - startrequest) * 1e6L)); } if (!generator) { return TransmitResponse(p);