commit c43c8b4

uint  ·  2026-10-26 14:22:49 +0000 UTC
parent d16eda6
use LOG_FIELD to autoalign fields
7 files changed,  +73, -70
+23, -23
  1@@ -61,7 +61,7 @@ static int load_path(const char* path)
  2 			continue;
  3 
  4 		if (set_kv(k, v) < 0)
  5-			LOG(true, "CONF", "Config Error       %s=%s", k, v);
  6+			LOG_FIELD(true, "CONF", "Config Error", "%s=%s", k, v);
  7 	}
  8 
  9 	free(line);
 10@@ -118,11 +118,11 @@ static int set_kv(const char* k, const char* v)
 11 		long p = strtol(v, &end, 10);
 12 
 13 		if (end == v || *end != '\0') {
 14-			LOG(true, "CONF", "Config Error       %s invalid integer '%s'", k, v);
 15+			LOG_FIELD(true, "CONF", "Config Error", "%s invalid integer '%s'", k, v);
 16 			return -1;
 17 		}
 18 		if (p < 1 || p > 65535) {
 19-			LOG(true, "CONF", "Config Error       server_port out of bounds (1..65535)");
 20+			LOG_FIELD(true, "CONF", "Config Error", "server_port out of bounds (1..65535)");
 21 			return -1;
 22 		}
 23 
 24@@ -133,7 +133,7 @@ static int set_kv(const char* k, const char* v)
 25 	if (strcmp(k, "verbose_log") == 0) {
 26 		bool b;
 27 		if (parse_bool(v, &b) < 0){
 28-			LOG(true, "CONF", "Config Error       verbose_log invalid bool \"%s\"", v);
 29+			LOG_FIELD(true, "CONF", "Config Error", "verbose_log invalid bool \"%s\"", v);
 30 			return -1;
 31 		}
 32 
 33@@ -151,11 +151,11 @@ static int set_kv(const char* k, const char* v)
 34 		long t = strtol(v, &end, 10);
 35 
 36 		if (end == v || *end != '\0') {
 37-			LOG(true, "CONF", "Config Error       %s invalid integer '%s'", k, v);
 38+			LOG_FIELD(true, "CONF", "Config Error", "%s invalid integer '%s'", k, v);
 39 			return -1;
 40 		}
 41 		if (t < 1 || t > 300) {
 42-			LOG(true, "CONF", "Config Error       http_io_timeout too %s (1..300)", t > 300 ? "high" : "low");
 43+			LOG_FIELD(true, "CONF", "Config Error", "http_io_timeout too %s (1..300)", t > 300 ? "high" : "low");
 44 			return -1;
 45 		}
 46 
 47@@ -168,11 +168,11 @@ static int set_kv(const char* k, const char* v)
 48 		long n = strtol(v, &end, 10);
 49 
 50 		if (end == v || *end != '\0') {
 51-			LOG(true, "CONF", "Config Error       %s invalid integer '%s'", k, v);
 52+			LOG_FIELD(true, "CONF", "Config Error", "%s invalid integer '%s'", k, v);
 53 			return -1;
 54 		}
 55 		if (n < 1 || n > 1024) {
 56-			LOG(true, "CONF", "Config Error       max_clients too %s (1..1024)", n > 1024 ? "high" : "low");
 57+			LOG_FIELD(true, "CONF", "Config Error", "max_clients too %s (1..1024)", n > 1024 ? "high" : "low");
 58 			return -1;
 59 		}
 60 
 61@@ -185,11 +185,11 @@ static int set_kv(const char* k, const char* v)
 62 		long n = strtol(v, &end, 10);
 63 
 64 		if (end == v || *end != '\0') {
 65-			LOG(true, "CONF", "Config Error       %s invalid integer '%s'", k, v);
 66+			LOG_FIELD(true, "CONF", "Config Error", "%s invalid integer '%s'", k, v);
 67 			return -1;
 68 		}
 69 		if (n < 0 || n > INT_MAX) {
 70-			LOG(true, "CONF", "Config Error       auth_delay out of bounds (0..%d)", INT_MAX);
 71+			LOG_FIELD(true, "CONF", "Config Error", "auth_delay out of bounds (0..%d)", INT_MAX);
 72 			return -1;
 73 		}
 74 
 75@@ -201,26 +201,26 @@ static int set_kv(const char* k, const char* v)
 76 	if (strcmp(k, "user") == 0) {
 77 		int r = users_push(v);
 78 		if (r < 0)
 79-			LOG(true, "CONF", "Config Error       user invalid '%s'", v);
 80+			LOG_FIELD(true, "CONF", "Config Error", "user invalid '%s'", v);
 81 		return r;
 82 	}
 83 
 84 	if (strcmp(k, "pass") == 0) {
 85 		int r = users_set_pass(v);
 86 		if (r < 0)
 87-			LOG(true, "CONF", "Config Error       pass invalid '%s'", v);
 88+			LOG_FIELD(true, "CONF", "Config Error", "pass invalid '%s'", v);
 89 		return r;
 90 	}
 91 
 92 	if (strcmp(k, "allow") == 0) {
 93 		int r = users_add_allow(v);
 94 		if (r < 0)
 95-			LOG(true, "CONF", "Config Error       allow invalid '%s'", v);
 96+			LOG_FIELD(true, "CONF", "Config Error", "allow invalid '%s'", v);
 97 		return r;
 98 	}
 99 
100 	/* unknown key */
101-	LOG(true, "CONF", "Unknown Key Value  %s=%s", k, v);
102+	LOG_FIELD(true, "CONF", "Unknown Key Value", "%s=%s", k, v);
103 	return 0;
104 }
105 
106@@ -278,19 +278,19 @@ log:
107 	char maxc[16];
108 	char adly[16];
109 
110-	LOG(true, "CONF", "Config File        %s", path);
111-	LOG(true, "CONF", "Media Directory    %s", media_dir);
112-	LOG(true, "CONF", "Server Address     %s", server_addr);
113+	LOG_FIELD(true, "CONF", "Config File", "%s", path);
114+	LOG_FIELD(true, "CONF", "Media Directory", "%s", media_dir);
115+	LOG_FIELD(true, "CONF", "Server Address", "%s", server_addr);
116 	snprintf(port, sizeof(port), "%d", server_port);
117-	LOG(true, "CONF", "Server Port        %s", port);
118-	LOG(true, "CONF", "Verbose Logging    %s", (verbose_log) ? "true" : "false");
119-	LOG(true, "CONF", "CORS origins       %s", cors_origin);
120+	LOG_FIELD(true, "CONF", "Server Port", "%s", port);
121+	LOG_FIELD(true, "CONF", "Verbose Logging", "%s", (verbose_log) ? "true" : "false");
122+	LOG_FIELD(true, "CONF", "CORS origins", "%s", cors_origin);
123 	snprintf(tmo, sizeof(tmo), "%d", http_io_timeout);
124-	LOG(true, "CONF", "HTTP IO Timeout    %s", tmo);
125+	LOG_FIELD(true, "CONF", "HTTP IO Timeout", "%s", tmo);
126 	snprintf(maxc, sizeof(maxc), "%d", max_clients);
127-	LOG(true, "CONF", "Max Clients        %s", maxc);
128+	LOG_FIELD(true, "CONF", "Max Clients", "%s", maxc);
129 	snprintf(adly, sizeof(adly), "%d", auth_delay);
130-	LOG(true, "CONF", "Auth Delay         %s (ms)", adly);
131+	LOG_FIELD(true, "CONF", "Auth Delay", "%s (ms)", adly);
132 
133 	return;
134 }
+21, -21
  1@@ -535,7 +535,7 @@ static void reply(int c, const char* hdr, const struct response* res)
  2 static int route_dispatch(int c, const char* hdr, const char* path, const struct user* u, int head_only)
  3 {
  4 	if (strcmp(path, "/ping") == 0) {
  5-		LOG(verbose_log, "HTTP", "Route              /ping");
  6+		LOG_FIELD(verbose_log, "HTTP", "Route", "/ping");
  7 		reply(c, hdr, &(struct response){ HTTP_200, HTTP_TEXT, NULL, "OK\n", sizeof("OK\n") - 1, 1, 0 });
  8 		return 0;
  9 	}
 10@@ -550,7 +550,7 @@ static int route_dispatch(int c, const char* hdr, const char* path, const struct
 11 		struct item tmp;
 12 		char rel[4096];
 13 
 14-		LOG(verbose_log, "HTTP", "Route              /stream");
 15+		LOG_FIELD(verbose_log, "HTTP", "Route", "/stream");
 16 		tmp.path = rel;
 17 
 18 		int rc = route_item_path(&tmp, path, "/stream/", u, c, hdr);
 19@@ -567,7 +567,7 @@ static int route_dispatch(int c, const char* hdr, const char* path, const struct
 20 		const char* type;
 21 		struct json j;
 22 
 23-		LOG(verbose_log, "HTTP", "Route              /meta");
 24+		LOG_FIELD(verbose_log, "HTTP", "Route", "/meta");
 25 		tmp.path = rel;
 26 
 27 		int rc = route_item_path(&tmp, path, "/meta/", u, c, hdr);
 28@@ -590,7 +590,7 @@ static int route_dispatch(int c, const char* hdr, const char* path, const struct
 29 		return 0;
 30 	}
 31 
 32-	LOG(verbose_log, "HTTP", "Route not found    %s", path);
 33+	LOG_FIELD(verbose_log, "HTTP", "Route not found", "%s", path);
 34 	reply(c, hdr, &(struct response){ HTTP_404, HTTP_TEXT, NULL, "Not Found\n", sizeof("Not Found\n") - 1, 1, 0 });
 35 	return 0;
 36 }
 37@@ -670,7 +670,7 @@ static int route_library(int c, const char* hdr, const struct user* u, int head_
 38 	struct json j;
 39 	struct library view;
 40 
 41-	LOG(verbose_log, "HTTP", "Route              /library");
 42+	LOG_FIELD(verbose_log, "HTTP", "Route", "/library");
 43 	(void)pthread_mutex_lock(&lib_lock);
 44 	memset(&view, 0, sizeof(view));
 45 
 46@@ -702,13 +702,13 @@ static int route_library(int c, const char* hdr, const struct user* u, int head_
 47 			free(view.items);
 48 
 49 		(void)pthread_mutex_unlock(&lib_lock);
 50-		LOG(verbose_log, "JSON", "Encode     FAILED");
 51+		LOG_FIELD(verbose_log, "JSON", "Encode", "FAILED");
 52 		reply(c, hdr, &(struct response){ HTTP_500, HTTP_TEXT, NULL, "JSON Encode Failed\n", sizeof("JSON Encode Failed\n") - 1, 1, 0 });
 53 		return -1;
 54 	}
 55 
 56 	(void)pthread_mutex_unlock(&lib_lock);
 57-	LOG(verbose_log, "JSON", "Encoded bytes      %zu bytes", j.len);
 58+	LOG_FIELD(verbose_log, "JSON", "Encoded bytes", "%zu bytes", j.len);
 59 	reply(c, hdr, &(struct response){ HTTP_200, HTTP_JSON, NULL, j.buf, j.len, !head_only, 0 });
 60 	json_free(&j);
 61 
 62@@ -742,7 +742,7 @@ static int route_method(int c, const char* hdr, const char* method, int* head_on
 63 		return 1;
 64 	}
 65 
 66-	LOG(verbose_log, "HTTP", "Method forbidden   %s", method);
 67+	LOG_FIELD(verbose_log, "HTTP", "Method forbidden", "%s", method);
 68 	reply(c, hdr, &(struct response){ HTTP_405, HTTP_TEXT, NULL, "Method Not Allowed\n", sizeof("Method Not Allowed\n") - 1, 1, 0 });
 69 	return 1;
 70 }
 71@@ -763,19 +763,19 @@ static int route_rescan(int c, const char* hdr, const struct user* u)
 72 	size_t before = 0;
 73 	size_t after = 0;
 74 
 75-	LOG(verbose_log, "HTTP", "Route              /rescan");
 76+	LOG_FIELD(verbose_log, "HTTP", "Route", "/rescan");
 77 	if (users.len == 0) {
 78-		LOG(true, "HTTP", "Rescan forbidden   Auth disabled");
 79+		LOG_FIELD(true, "HTTP", "Rescan forbidden", "Auth disabled");
 80 		reply(c, hdr, &(struct response){ HTTP_403, HTTP_TEXT, NULL, "Forbidden\n", sizeof("Forbidden\n") - 1, 1, 0 });
 81 		return 0;
 82 	}
 83 
 84-	LOG(true, "SCAN", "Rescan requested   %s", u->name);
 85+	LOG_FIELD(true, "SCAN", "Rescan requested", "%s", u->name);
 86 	clock_gettime(CLOCK_MONOTONIC, &t0);
 87 
 88 	(void)pthread_mutex_lock(&lib_lock);
 89 	before = lib.len;
 90-	LOG(verbose_log, "SCAN", "Rescan begin       %s (%zu items)", media_dir, before);
 91+	LOG_FIELD(verbose_log, "SCAN", "Rescan begin", "%s (%zu items)", media_dir, before);
 92 	int ok = scan_library_rescan(&lib, media_dir);
 93 	after = lib.len;
 94 	(void)pthread_mutex_unlock(&lib_lock);
 95@@ -784,12 +784,12 @@ static int route_rescan(int c, const char* hdr, const struct user* u)
 96 	long ms = (t1.tv_sec - t0.tv_sec) * 1000L + (t1.tv_nsec - t0.tv_nsec) / 1000000L;
 97 
 98 	if (ok < 0) {
 99-		LOG(true, "SCAN", "Rescan FAILED      %s (%ld ms)", media_dir, ms);
100+		LOG_FIELD(true, "SCAN", "Rescan FAILED", "%s (%ld ms)", media_dir, ms);
101 		reply(c, hdr, &(struct response){ HTTP_500, HTTP_TEXT, NULL, "Rescan Failed\n", sizeof("Rescan Failed\n") - 1, 1, 0 });
102 		return -1;
103 	}
104 
105-	LOG(true, "SCAN", "Rescan OK          %zu -> %zu (%ld ms)", before, after, ms);
106+	LOG_FIELD(true, "SCAN", "Rescan OK", "%zu -> %zu (%ld ms)", before, after, ms);
107 	reply(c, hdr, &(struct response){ HTTP_200, HTTP_TEXT, NULL, "OK\n", sizeof("OK\n") - 1, 1, 0 });
108 	return 0;
109 }
110@@ -834,7 +834,7 @@ static int stream_file(int c, const struct item* it, const char* hdr, int head_o
111 
112 	/* build absolute path */
113 	if (join_path(full, sizeof(full), media_dir, it->path) < 0) {
114-		LOG(verbose_log, "HTTP", "Stream FAILED      Path too long");
115+		LOG_FIELD(verbose_log, "HTTP", "Stream FAILED", "Path too long");
116 		reply(c, hdr, &(struct response){ HTTP_500, HTTP_TEXT, NULL, "Server Error\n", sizeof("Server Error\n") - 1, 1, 0 });
117 		return -1;
118 	}
119@@ -842,7 +842,7 @@ static int stream_file(int c, const struct item* it, const char* hdr, int head_o
120 	/* open file */
121 	int fd = open(full, O_RDONLY);
122 	if (fd < 0) {
123-		LOG(verbose_log, "HTTP", "Open FAILED        %s", it->path);
124+		LOG_FIELD(verbose_log, "HTTP", "Open FAILED", "%s", it->path);
125 		reply(c, hdr, &(struct response){ HTTP_404, HTTP_TEXT, NULL, "Not Found\n", sizeof("Not Found\n") - 1, 1, 0 });
126 		return 0;
127 	}
128@@ -947,9 +947,9 @@ static int stream_file(int c, const struct item* it, const char* hdr, int head_o
129 		close(fd);
130 
131 		if (partial == RANGE_OK)
132-			LOG(verbose_log, "HTTP", "Header             %s [%zu-%zu/%zu]", it->path, start, end, total);
133+			LOG_FIELD(verbose_log, "HTTP", "Header", "%s [%zu-%zu/%zu]", it->path, start, end, total);
134 		else
135-			LOG(verbose_log, "HTTP", "Header             %s (%zu bytes)", it->path, total);
136+			LOG_FIELD(verbose_log, "HTTP", "Header", "%s (%zu bytes)", it->path, total);
137 
138 		return 0;
139 	}
140@@ -982,9 +982,9 @@ static int stream_file(int c, const struct item* it, const char* hdr, int head_o
141 	close(fd);
142 
143 	if (partial == RANGE_OK)
144-		LOG(verbose_log, "HTTP", "Streamed           %s [%zu-%zu/%zu]", it->path, start, end, total);
145+		LOG_FIELD(verbose_log, "HTTP", "Streamed", "%s [%zu-%zu/%zu]", it->path, start, end, total);
146 	else
147-		LOG(verbose_log, "HTTP", "Streamed           %s (%zu bytes)", it->path, total);
148+		LOG_FIELD(verbose_log, "HTTP", "Streamed", "%s (%zu bytes)", it->path, total);
149 
150 	return 0;
151 }
152@@ -1003,7 +1003,7 @@ int http_handle(int c)
153 		reply(c, hdr, &(struct response){ HTTP_400, HTTP_TEXT, NULL, "Bad Request\n", sizeof("Bad Request\n") - 1, 1, 0 });
154 		return -1;
155 	}
156-	LOG(verbose_log, "HTTP", "Request            %s %s", method, path);
157+	LOG_FIELD(verbose_log, "HTTP", "Request", "%s %s", method, path);
158 
159 	int head_only = 0;
160 	if (route_method(c, hdr, method, &head_only) != 0)
+6, -2
 1@@ -70,9 +70,9 @@ static inline void log_print(bool verbose, const char* tag,
 2 
 3 	log_vprint(verbose, tag,
 4 #if defined(DEBUG)
 5-			file, line, func,
 6+		file, line, func,
 7 #endif
 8-			fmt, ap);
 9+		fmt, ap);
10 
11 	va_end(ap);
12 }
13@@ -92,5 +92,9 @@ static inline void log_print(bool verbose, const char* tag,
14 	log_print((verbose_log), (tag), (fmt), ##__VA_ARGS__)
15 #endif
16 
17+/* Align a label before a printf-style message. */
18+#define LOG_FIELD(verbose, tag, label, fmt, ...) \
19+	LOG((verbose), (tag), "%-24s " fmt, (label), ##__VA_ARGS__)
20+
21 #endif /* LOG_H */
22 
+1, -1
1@@ -51,7 +51,7 @@ static int json_grow(struct json* j, size_t need)
2 
3 	char* nb = realloc(j->buf, ncap);
4 	if (!nb) {
5-		LOG(verbose_log, "JSON", "realloc FAILED     OOM");
6+		LOG_FIELD(verbose_log, "JSON", "realloc FAILED", "OOM");
7 		return -1;
8 	}
9 
+5, -5
 1@@ -185,15 +185,15 @@ void run(void)
 2 			(void)write_all(c, resp, sizeof(resp) - 1);
 3 
 4 			close(c);
 5-			LOG(true, "CORE", "Connection         Busy (503)");
 6+			LOG_FIELD(true, "CORE", "Connection", "Busy (503)");
 7 			continue;
 8 		}
 9 
10-		LOG(verbose_log, "CORE", "Connection         Accepted");
11+		LOG_FIELD(verbose_log, "CORE", "Connection", "Accepted");
12 		pthread_t t;
13 		int err = pthread_create(&t, NULL, client_thread, (void*)(intptr_t)c);
14 		if (err != 0) {
15-			LOG(true, "CORE", "pthread_create FAILED  %d", err);
16+			LOG_FIELD(true, "CORE", "pthread_create FAILED", "%d", err);
17 			close(c);
18 			release_slot();
19 			continue;
20@@ -242,13 +242,13 @@ void setup(void)
21 
22 	if (scan_library(&lib, media_dir) < 0)
23 		die("scan_library", EXIT_FAILURE);
24-	LOG(verbose_log, "SCAN", "Cached items       %zu", lib.len);
25+	LOG_FIELD(verbose_log, "SCAN", "Cached items", "%zu", lib.len);
26 
27 	ret = listen(sock, LISTEN_BACKLOG);
28 	if (ret < 0)
29 		die("listen", EXIT_FAILURE);
30 
31-	LOG(verbose_log, "CORE", "Listening on       %s:%d", server_addr, server_port);
32+	LOG_FIELD(verbose_log, "CORE", "Listening on", "%s:%d", server_addr, server_port);
33 #ifdef __OpenBSD__
34 	if (unveil(media_dir, "r") < 0)
35 		die("unveil", EXIT_FAILURE);
+2, -2
 1@@ -51,7 +51,7 @@ static int library_push(struct library* l, const char* rel)
 2 		size_t ncap = l->cap ? (l->cap * 2) : 64;
 3 		struct item* ni = realloc(l->items, ncap * sizeof(*ni));
 4 		if (!ni) {
 5-			LOG(verbose_log, "SCAN", "realloc FAILED     OOM");
 6+			LOG_FIELD(verbose_log, "SCAN", "realloc FAILED", "OOM");
 7 			return -1;
 8 		}
 9 		l->items = ni;
10@@ -95,7 +95,7 @@ static int scan_dir(struct library* l, const char* root, const char* rel)
11 
12 	d = opendir(full);
13 	if (!d) {
14-		LOG(verbose_log, "SCAN", "opendir FAILED     %s", full);
15+		LOG_FIELD(verbose_log, "SCAN", "opendir FAILED", "%s", full);
16 		return -1;
17 	}
18 
+15, -16
  1@@ -200,11 +200,11 @@ bool user_allows_path(const struct user* u, const char* relpath)
  2 int users_add_allow(const char* prefix)
  3 {
  4 	if (users.len == 0 || !prefix) {
  5-		LOG(true, "AUTH", "AddAllow FAILED     No user or prefix");
  6+		LOG_FIELD(true, "AUTH", "AddAllow FAILED", "No user or prefix");
  7 		return -1;
  8 	}
  9 
 10-	LOG(verbose_log, "AUTH", "Allow directories  %s %s", users.v[users.len - 1].name, prefix);
 11+	LOG_FIELD(verbose_log, "AUTH", "Allow directories", "%s %s", users.v[users.len - 1].name, prefix);
 12 
 13 	return allow_push(&users.v[users.len - 1], prefix);
 14 }
 15@@ -216,7 +216,7 @@ const struct user* users_auth_from_hdr(const char* hdr)
 16 
 17 	char auth[512];
 18 	if (hdr_get_value(auth, hdr, "authorization") < 0) {
 19-		LOG(true, "AUTH", "Authorization      Not found");
 20+		LOG_FIELD(true, "AUTH", "Authorization", "Not found");
 21 		return NULL;
 22 	}
 23 
 24@@ -226,7 +226,7 @@ const struct user* users_auth_from_hdr(const char* hdr)
 25 		p++;
 26 
 27 	if (strncasecmp(p, "Basic", 5) != 0) {
 28-		LOG(verbose_log, "AUTH", "Authorization      Not Basic");
 29+		LOG_FIELD(verbose_log, "AUTH", "Authorization", "Not Basic");
 30 		return NULL;
 31 	}
 32 
 33@@ -235,20 +235,20 @@ const struct user* users_auth_from_hdr(const char* hdr)
 34 		p++;
 35 
 36 	if (*p == '\0') {
 37-		LOG(verbose_log, "AUTH", "Basic Auth         Missing token");
 38+		LOG_FIELD(verbose_log, "AUTH", "Basic Auth", "Missing token");
 39 		return NULL;
 40 	}
 41 
 42 	unsigned char dec[512];
 43 	if (b64_decode(dec, sizeof(dec), p) < 0) {
 44-		LOG(verbose_log, "AUTH", "Basic Auth         B64 decode failed");
 45+		LOG_FIELD(verbose_log, "AUTH", "Basic Auth", "B64 decode failed");
 46 		secure_bzero(dec, sizeof(dec));
 47 		return NULL;
 48 	}
 49 
 50 	char* sep = strchr((char*)dec, ':');
 51 	if (!sep) {
 52-		LOG(verbose_log, "AUTH", "Basic Auth         Decoded but missing ':'");
 53+		LOG_FIELD(verbose_log, "AUTH", "Basic Auth", "Decoded but missing ':'");
 54 		secure_bzero(dec, sizeof(dec));
 55 		return NULL;
 56 	}
 57@@ -267,11 +267,11 @@ const struct user* users_auth_from_hdr(const char* hdr)
 58 	/* empty password -> passwordless account */
 59 	if (u->pass[0] == '\0') {
 60 		if (pass[0] == '\0') {
 61-			LOG(true, "AUTH", "Login OK           %s", user);
 62+			LOG_FIELD(true, "AUTH", "Login OK", "%s", user);
 63 			secure_bzero(dec, sizeof(dec));
 64 			return u;
 65 		}
 66-		LOG(true, "AUTH", "Login FAILED       %s", user);
 67+		LOG_FIELD(true, "AUTH", "Login FAILED", "%s", user);
 68 		secure_bzero(dec, sizeof(dec));
 69 		return NULL;
 70 	}
 71@@ -282,7 +282,7 @@ const struct user* users_auth_from_hdr(const char* hdr)
 72 		return NULL;
 73 	}
 74 
 75-	LOG(verbose_log, "AUTH", "Login OK           %s", user);
 76+	LOG_FIELD(verbose_log, "AUTH", "Login OK", "%s", user);
 77 	secure_bzero(dec, sizeof(dec));
 78 	return u;
 79 }
 80@@ -308,7 +308,7 @@ void users_free(void)
 81 int users_push(const char* name)
 82 {
 83 	if (!name || name[0] == '\0') {
 84-		LOG(true, "AUTH", "UserAdd FAILED     Empty username");
 85+		LOG_FIELD(true, "AUTH", "UserAdd FAILED", "Empty username");
 86 		return -1;
 87 	}
 88 
 89@@ -316,7 +316,7 @@ int users_push(const char* name)
 90 		size_t ncap = users.cap ? (users.cap * 2) : 8;
 91 		struct user* nv = realloc(users.v, ncap * sizeof(*nv));
 92 		if (!nv) {
 93-			LOG(true, "AUTH", "realloc FAILED     (cap=%zu -> %zu)", users.cap, ncap);
 94+			LOG_FIELD(true, "AUTH", "realloc FAILED", "(cap=%zu -> %zu)", users.cap, ncap);
 95 			return -1;
 96 		}
 97 		users.v = nv;
 98@@ -326,7 +326,7 @@ int users_push(const char* name)
 99 	memset(&users.v[users.len], 0, sizeof(users.v[users.len]));
100 	snprintf(users.v[users.len].name, sizeof(users.v[users.len].name), "%s", name);
101 
102-	LOG(verbose_log, "AUTH", "UserAdd SUCCESS    %s", users.v[users.len].name);
103+	LOG_FIELD(verbose_log, "AUTH", "UserAdd SUCCESS", "%s", users.v[users.len].name);
104 
105 	users.len++;
106 	return 0;
107@@ -335,7 +335,7 @@ int users_push(const char* name)
108 int users_set_pass(const char* pass)
109 {
110 	if (users.len == 0) {
111-		LOG(true, "AUTH", "SetPass FAILED     No users");
112+		LOG_FIELD(true, "AUTH", "SetPass FAILED", "No users");
113 		return -1;
114 	}
115 
116@@ -345,8 +345,7 @@ int users_set_pass(const char* pass)
117 	/* copy pass->user.pass */
118 	snprintf(users.v[users.len - 1].pass, sizeof(users.v[users.len - 1].pass), "%s", pass);
119 
120-	LOG(
121-		verbose_log, "AUTH", "Password set for   %s (%s)",
122+	LOG_FIELD(verbose_log, "AUTH", "Password set for", "%s (%s)",
123 		users.v[users.len - 1].name, (pass[0] == '\0') ? "none" : "set"
124 	);
125 	return 0;