diff --git a/ChangeLog b/ChangeLog index 0e8fd2c..c8565bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ Changes between 1.6.9 and the master branch (RADSECPROXY-66, RADSECPROXY-74). - Reload TLS certificate CRLs on SIGHUP (RADSECPROXY-78). - Make use of SO_KEEPALIVE for tcp sockets (RADSECPROXY-12). + - Optionally include the thread-id in log messages Misc: - libnettle is now an unconditional dependency. diff --git a/debug.c b/debug.c index ab9c662..c5293d2 100644 --- a/debug.c +++ b/debug.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "debug.h" #include "util.h" @@ -25,6 +26,7 @@ static FILE *debug_file = NULL; static int debug_syslogfacility = 0; static int fticks_syslogfacility = 0; static uint8_t debug_timestamp = 0; +static uint8_t debug_tid = 0; void debug_init(char *ident) { debug_file = stderr; @@ -56,6 +58,10 @@ void debug_timestamp_on() { debug_timestamp = 1; } +void debug_tid_on() { + debug_tid = 1; +} + uint8_t debug_get_level() { return debug_level; } @@ -142,9 +148,17 @@ void debug_reopen_log() { void debug_logit(uint8_t level, const char *format, va_list ap) { struct timeval now; - char *timebuf; + char *timebuf, *tidbuf; int priority; + if (debug_tid) { + tidbuf = malloc((3*sizeof(pthread_t)+5)+strlen(format)); + sprintf(tidbuf, "(%ld) %s", pthread_self(), format); + format = tidbuf; + } else + tidbuf = NULL; + + if (debug_syslogfacility) { switch (level) { case DBG_DBG: @@ -177,6 +191,7 @@ void debug_logit(uint8_t level, const char *format, va_list ap) { vfprintf(debug_file, format, ap); fprintf(debug_file, "\n"); } + free(tidbuf); } void debug(uint8_t level, char *format, ...) { diff --git a/debug.h b/debug.h index 83785ee..4ea55a2 100644 --- a/debug.h +++ b/debug.h @@ -18,6 +18,7 @@ void debug_init(char *ident); void debug_set_level(uint8_t level); void debug_timestamp_on(); +void debug_tid_on(); uint8_t debug_get_level(); void debug(uint8_t level, char *format, ...); void debugx(int status, uint8_t level, char *format, ...); diff --git a/radsecproxy.c b/radsecproxy.c index 638e53f..eda19bc 100644 --- a/radsecproxy.c +++ b/radsecproxy.c @@ -3133,6 +3133,7 @@ void getmainconfig(const char *configfile) { "addTTL", CONF_LINT, &addttl, "LogLevel", CONF_LINT, &loglevel, "LogDestination", CONF_STR, &options.logdestination, + "LogThreadId", CONF_BLN, &options.logtid, "LoopPrevention", CONF_BLN, &options.loopprevention, "Client", CONF_CBK, confclient_cb, NULL, "Server", CONF_CBK, confserver_cb, NULL, @@ -3325,6 +3326,8 @@ int radsecproxy_main(int argc, char **argv) { } } free(options.logdestination); + if (options.logtid) + debug_tid_on(); if (!list_first(clconfs)) debugx(1, DBG_ERR, "No clients configured, nothing to do, exiting"); diff --git a/radsecproxy.conf.5.xml b/radsecproxy.conf.5.xml index d14ed3c..0377625 100644 --- a/radsecproxy.conf.5.xml +++ b/radsecproxy.conf.5.xml @@ -2,7 +2,7 @@ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"> - 2016-03-23 + 2018-03-13 radsecproxy.conf @@ -177,6 +177,15 @@ blocktype name { + + LogThreadId + + + This can be set to on to include the + thread-id in the log messages (useful for debugging). + + + FTicksReporting @@ -712,7 +721,7 @@ blocktype name { tls, certificateNameCheck, matchCertificateAttribute, AddTTL, tcpKeepalive, - rewrite, + rewrite, rewriteIn and rewriteOut are just as specified for the client block above, except that defaultServer (and not diff --git a/radsecproxy.h b/radsecproxy.h index 45e23ab..207b993 100644 --- a/radsecproxy.h +++ b/radsecproxy.h @@ -73,6 +73,7 @@ struct options { uint32_t ttlattrtype[2]; uint8_t addttl; uint8_t loglevel; + uint8_t logtid; uint8_t loopprevention; enum rsp_fticks_reporting_type fticks_reporting; enum rsp_fticks_mac_type fticks_mac;