mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-03 15:38:22 +00:00
Fix redbean latency and resource usage logging (#257)
This commit is contained in:
parent
7d25fb0090
commit
818926dbae
2 changed files with 11 additions and 3 deletions
|
@ -72,6 +72,14 @@ extern unsigned __log_level; /* log level for runtime check */
|
||||||
((!__builtin_constant_p(LEVEL) || (LEVEL) <= LOGGABLELEVEL) && \
|
((!__builtin_constant_p(LEVEL) || (LEVEL) <= LOGGABLELEVEL) && \
|
||||||
(LEVEL) <= __log_level)
|
(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
|
// die with an error message without backtrace and debugger invocation
|
||||||
#define DIEF(FMT, ...) \
|
#define DIEF(FMT, ...) \
|
||||||
do { \
|
do { \
|
||||||
|
|
|
@ -1118,7 +1118,7 @@ static void ReportWorkerResources(int pid, struct rusage *ru) {
|
||||||
AppendResourceReport(&b, ru, "\n");
|
AppendResourceReport(&b, ru, "\n");
|
||||||
if (b) {
|
if (b) {
|
||||||
if ((s = IndentLines(b, appendz(b).i - 1, 0, 1))) {
|
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(s);
|
||||||
}
|
}
|
||||||
free(b);
|
free(b);
|
||||||
|
@ -6122,8 +6122,8 @@ static bool HandleMessageAcutal(void) {
|
||||||
LockInc(&shared->c.messageshandled);
|
LockInc(&shared->c.messageshandled);
|
||||||
++messageshandled;
|
++messageshandled;
|
||||||
if (loglatency || LOGGABLE(kLogDebug)) {
|
if (loglatency || LOGGABLE(kLogDebug)) {
|
||||||
DEBUGF("(stat) %`'.*s latency %,ldµs", msg.uri.b - msg.uri.a, inbuf.p + msg.uri.a,
|
ANYF(kLogDebug, "(stat) %`'.*s latency %,ldµs", msg.uri.b - msg.uri.a, inbuf.p + msg.uri.a,
|
||||||
(long)((nowl() - startrequest) * 1e6L));
|
(long)((nowl() - startrequest) * 1e6L));
|
||||||
}
|
}
|
||||||
if (!generator) {
|
if (!generator) {
|
||||||
return TransmitResponse(p);
|
return TransmitResponse(p);
|
||||||
|
|
Loading…
Add table
Reference in a new issue