changeset 1083:c8d534dfe4df

error: include the scgi request id in error messages This should make it easier to associate log messages with particular connection (and therefore a request log file). Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Wed, 30 Aug 2017 15:20:41 +0300
parents 7c32c7d15928
children 7103c3765cff
files error.c
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/error.c	Wed Aug 30 15:19:09 2017 +0300
+++ b/error.c	Wed Aug 30 15:20:41 2017 +0300
@@ -27,6 +27,7 @@
 #include <stdarg.h>
 
 /* session info */
+static __thread char session_str[64];
 static __thread uint32_t session_id;
 
 static void mylog(int level, const char *fmt, va_list ap)
@@ -46,6 +47,17 @@
 	session_id = id;
 }
 
+static const char *get_session(void)
+{
+	if (!session_id)
+		return "";
+
+	snprintf(session_str, sizeof(session_str), " {%u}", session_id);
+
+	return session_str;
+}
+
 struct jeffpc_ops init_ops = {
 	.log = mylog,
+	.get_session = get_session,
 };