commit 41395640e09aac151159bfd8cf33ed4f32725157 from: Omar Polo date: Mon Jul 19 07:31:40 2021 UTC introduce IMSG_LOG_REQUEST commit - 2b5e2a5f04b4447a13b5468f6bdfe133a91b8063 commit + 41395640e09aac151159bfd8cf33ed4f32725157 blob - def5176d1bae24c65f0f6a29ace1aa8546e113af blob + 34da70cdbb43806d2837ebecb321afaf6422a591 --- gmid.h +++ gmid.h @@ -302,6 +302,7 @@ enum imsg_type { IMSG_FCGI_REQ, IMSG_FCGI_FD, IMSG_LOG, + IMSG_LOG_REQUEST, IMSG_LOG_TYPE, IMSG_QUIT, }; blob - 8ce6d6d18ae8408b8172d037dde09fd310a8b487 blob + 6f73c8f17820dc4ae018ef27bb33c1e3efd8a97a --- log.c +++ log.c @@ -42,6 +42,7 @@ static void handle_dispatch_imsg(int, short, void*); static imsg_handlerfn *handlers[] = { [IMSG_QUIT] = handle_imsg_quit, [IMSG_LOG] = handle_imsg_log, + [IMSG_LOG_REQUEST] = handle_imsg_log, [IMSG_LOG_TYPE] = handle_imsg_log_type, }; @@ -252,14 +253,14 @@ log_request(struct client *c, char *meta, size_t l) (int)(t-meta), meta); if (ec < 0) err(1, "asprintf"); - send_log(LOG_NOTICE, IMSG_LOG, fmted, ec+1); + send_log(LOG_NOTICE, IMSG_LOG_REQUEST, fmted, ec+1); free(fmted); } static void -do_log(int priority, const char *msg) +do_log(int type, int priority, const char *msg) { int quit = 0; @@ -269,7 +270,8 @@ do_log(int priority, const char *msg) } if (log != NULL) { - print_date(log); + if (type != IMSG_LOG_REQUEST) + print_date(log); fprintf(log, "%s\n", msg); } else syslog(LOG_DAEMON | priority, "%s", msg); @@ -293,7 +295,7 @@ handle_imsg_log(struct imsgbuf *ibuf, struct imsg *ims msg = imsg->data; msg[datalen-1] = '\0'; priority = imsg->hdr.peerid; - do_log(priority, msg); + do_log(imsg->hdr.type, priority, msg); } static void