mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-07-14 11:49:53 +03:00
I use thttpd for exposing Prometheus metrics using CGI script. Now it logs "spawned CGI process ..." to syslog each time the metrics endpoint is requested which fills /var/log/messages.
79 lines
2.4 KiB
Diff
79 lines
2.4 KiB
Diff
From: Jakub Jirutka <jakub@jirutka.cz>
|
||
Date: Sun, 20 Apr 2025 23:50:25 +0200
|
||
Subject: Allow to disable debug logging
|
||
|
||
If `THTTPD_LOG_DEBUG` environment variable is set to `0`, debug messages
|
||
won't be logged to syslog. This is a downstream Alpinw's patch to avoid
|
||
filling /var/log/messages with "spawned CGI process ...".
|
||
|
||
--- a/libhttpd.c
|
||
+++ b/libhttpd.c
|
||
@@ -192,7 +192,9 @@
|
||
*/
|
||
static int sub_process = 0;
|
||
|
||
+static int log_debug_disabled = 0;
|
||
|
||
+
|
||
static void
|
||
check_options( void )
|
||
{
|
||
@@ -236,6 +238,11 @@
|
||
static char ghnbuf[256];
|
||
char* cp;
|
||
|
||
+ // XXX: This is a downstream feature in Alpine Linux.
|
||
+ cp = getenv("THTTPD_LOG_DEBUG");
|
||
+ if ( cp && strchr(cp, '0') )
|
||
+ log_debug_disabled = 1;
|
||
+
|
||
check_options();
|
||
|
||
hs = NEW( httpd_server, 1 );
|
||
@@ -2172,7 +2179,7 @@
|
||
{
|
||
cp = &buf[18];
|
||
hc->if_modified_since = tdate_parse( cp );
|
||
- if ( hc->if_modified_since == (time_t) -1 )
|
||
+ if ( hc->if_modified_since == (time_t) -1 && ! log_debug_disabled )
|
||
syslog( LOG_DEBUG, "unparsable time: %.80s", cp );
|
||
}
|
||
else if ( strncasecmp( buf, "Cookie:", 7 ) == 0 )
|
||
@@ -2213,7 +2220,7 @@
|
||
{
|
||
cp = &buf[9];
|
||
hc->range_if = tdate_parse( cp );
|
||
- if ( hc->range_if == (time_t) -1 )
|
||
+ if ( hc->range_if == (time_t) -1 && ! log_debug_disabled )
|
||
syslog( LOG_DEBUG, "unparsable time: %.80s", cp );
|
||
}
|
||
else if ( strncasecmp( buf, "Content-Type:", 13 ) == 0 )
|
||
@@ -2271,7 +2278,7 @@
|
||
strncasecmp( buf, "Via:", 4 ) == 0 ||
|
||
strncasecmp( buf, "X-", 2 ) == 0 )
|
||
; /* ignore */
|
||
- else
|
||
+ else if ( ! log_debug_disabled )
|
||
syslog( LOG_DEBUG, "unknown request header: %.80s", buf );
|
||
#endif /* LOG_UNKNOWN_HEADERS */
|
||
}
|
||
@@ -2974,7 +2981,8 @@
|
||
|
||
/* Parent process. */
|
||
closedir( dirp );
|
||
- syslog( LOG_DEBUG, "spawned indexing process %d for directory '%.200s'", r, hc->expnfilename );
|
||
+ if ( ! log_debug_disabled )
|
||
+ syslog( LOG_DEBUG, "spawned indexing process %d for directory '%.200s'", r, hc->expnfilename );
|
||
#ifdef CGI_TIMELIMIT
|
||
/* Schedule a kill for the child process, in case it runs too long */
|
||
client_data.i = r;
|
||
@@ -3602,7 +3610,8 @@
|
||
}
|
||
|
||
/* Parent process. */
|
||
- syslog( LOG_DEBUG, "spawned CGI process %d for file '%.200s'", r, hc->expnfilename );
|
||
+ if ( ! log_debug_disabled )
|
||
+ syslog( LOG_DEBUG, "spawned CGI process %d for file '%.200s'", r, hc->expnfilename );
|
||
#ifdef CGI_TIMELIMIT
|
||
/* Schedule a kill for the child process, in case it runs too long */
|
||
client_data.i = r;
|