commit 9f799d905510b1fc86562dd95e2d31c02bf72ee8 from: rsadowski date: Mon Mar 2 19:24:58 2026 UTC Standardize logging with bgpd Tweak and OK claudio@ commit - 4a9fc8a790b8f50642beb4705ca291fe19d5ed83 commit + 9f799d905510b1fc86562dd95e2d31c02bf72ee8 blob - 300a5f2caca68dd2708400099f9a987c8f638c59 blob + 52066ce7b283363df94bef7d142056d06cb6bffb --- config.c +++ config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.68 2026/01/04 06:43:34 rsadowski Exp $ */ +/* $OpenBSD: config.c,v 1.69 2026/03/02 19:24:58 rsadowski Exp $ */ /* * Copyright (c) 2011 - 2015 Reyk Floeter @@ -31,6 +31,7 @@ #include #include "httpd.h" +#include "log.h" int config_getserver_config(struct httpd *, struct server *, struct imsg *); blob - 9a4eb3b5163303aeae40221a06aeaaabb11c5c72 blob + 6bbc9a4ce83c6668287d5ab45aaca61d74a51484 --- control.c +++ control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.21 2024/11/21 13:38:45 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.22 2026/03/02 19:24:58 rsadowski Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -31,6 +31,7 @@ #include #include "httpd.h" +#include "log.h" #define CONTROL_BACKLOG 5 blob - c2d74de03fe996c0fd88595e7e254257fe00bb2e blob + 4f84c00c6449947f21a1bd41ac874f2ea9e495e3 --- httpd.c +++ httpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: httpd.c,v 1.76 2026/01/02 08:45:16 rsadowski Exp $ */ +/* $OpenBSD: httpd.c,v 1.77 2026/03/02 19:24:58 rsadowski Exp $ */ /* * Copyright (c) 2014 Reyk Floeter @@ -42,6 +42,7 @@ #include #include "httpd.h" +#include "log.h" #define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b)) blob - 8aae0b3f561a781cb78cb94d1da4c547f39e565b blob + 7b00d7564bfffc954b9bca925c889977044b49db --- httpd.h +++ httpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: httpd.h,v 1.168 2026/02/28 09:36:08 rsadowski Exp $ */ +/* $OpenBSD: httpd.h,v 1.169 2026/03/02 19:24:58 rsadowski Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter @@ -760,28 +760,6 @@ void getmonotime(struct timeval *); extern struct httpd *httpd_env; -/* log.c */ -void log_init(int, int); -void log_procinit(const char *); -void log_setverbose(int); -int log_getverbose(void); -void log_warn(const char *, ...) - __attribute__((__format__ (printf, 1, 2))); -void log_warnx(const char *, ...) - __attribute__((__format__ (printf, 1, 2))); -void log_info(const char *, ...) - __attribute__((__format__ (printf, 1, 2))); -void log_debug(const char *, ...) - __attribute__((__format__ (printf, 1, 2))); -void logit(int, const char *, ...) - __attribute__((__format__ (printf, 2, 3))); -void vlog(int, const char *, va_list) - __attribute__((__format__ (printf, 2, 0))); -__dead void fatal(const char *, ...) - __attribute__((__format__ (printf, 1, 2))); -__dead void fatalx(const char *, ...) - __attribute__((__format__ (printf, 1, 2))); - /* proc.c */ enum privsep_procid proc_getid(struct privsep_proc *, unsigned int, const char *); blob - b7e25a64720a70b735c230af6fc27af11510a436 blob + 1935a84c21283d8bed0781f1c2e0b888ece63e2c --- log.c +++ log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.14 2017/03/21 12:06:55 bluhm Exp $ */ +/* $OpenBSD: log.c,v 1.15 2026/03/02 19:24:58 rsadowski Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -24,30 +24,11 @@ #include #include -static int debug; -static int verbose; -const char *log_procname; +#include "log.h" -void log_init(int, int); -void log_procinit(const char *); -void log_setverbose(int); -int log_getverbose(void); -void log_warn(const char *, ...) - __attribute__((__format__ (printf, 1, 2))); -void log_warnx(const char *, ...) - __attribute__((__format__ (printf, 1, 2))); -void log_info(const char *, ...) - __attribute__((__format__ (printf, 1, 2))); -void log_debug(const char *, ...) - __attribute__((__format__ (printf, 1, 2))); -void logit(int, const char *, ...) - __attribute__((__format__ (printf, 2, 3))); -void vlog(int, const char *, va_list) - __attribute__((__format__ (printf, 2, 0))); -__dead void fatal(const char *, ...) - __attribute__((__format__ (printf, 1, 2))); -__dead void fatalx(const char *, ...) - __attribute__((__format__ (printf, 1, 2))); +static int debug; +static int verbose; +static const char *log_procname; void log_init(int n_debug, int facility) @@ -168,7 +149,7 @@ log_debug(const char *emsg, ...) { va_list ap; - if (verbose > 1) { + if (verbose) { va_start(ap, emsg); vlog(LOG_DEBUG, emsg, ap); va_end(ap); @@ -189,10 +170,10 @@ vfatalc(int code, const char *emsg, va_list ap) sep = ""; } if (code) - logit(LOG_CRIT, "%s: %s%s%s", + logit(LOG_CRIT, "fatal in %s: %s%s%s", log_procname, s, sep, strerror(code)); else - logit(LOG_CRIT, "%s%s%s", log_procname, sep, s); + logit(LOG_CRIT, "fatal in %s%s%s", log_procname, sep, s); } void blob - 31f441011abf2dbc1ea4c2edc09ab20f6f99d8b7 blob + e9b99fa4aea094d1658e52367303518f0c4b7b71 --- logger.c +++ logger.c @@ -1,4 +1,4 @@ -/* $OpenBSD: logger.c,v 1.25 2024/01/17 08:22:40 claudio Exp $ */ +/* $OpenBSD: logger.c,v 1.26 2026/03/02 19:24:58 rsadowski Exp $ */ /* * Copyright (c) 2014 Reyk Floeter @@ -29,6 +29,7 @@ #include #include "httpd.h" +#include "log.h" int logger_dispatch_parent(int, struct privsep_proc *, struct imsg *); blob - /dev/null blob + 89b1434d78f78931a4c7f1d4cdb009c6d76f77bd (mode 644) --- /dev/null +++ log.h @@ -0,0 +1,46 @@ +/* $OpenBSD: log.h,v 1.1 2026/03/02 19:24:58 rsadowski Exp $ */ + +/* + * Copyright (c) 2003, 2004 Henning Brauer + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef LOG_H +#define LOG_H + +#include +#include + +void log_init(int, int); +void log_procinit(const char *); +void log_setverbose(int); +int log_getverbose(void); +void log_warn(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +void log_warnx(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +void log_info(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +void log_debug(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +void logit(int, const char *, ...) + __attribute__((__format__ (printf, 2, 3))); +void vlog(int, const char *, va_list) + __attribute__((__format__ (printf, 2, 0))); +__dead void fatal(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); +__dead void fatalx(const char *, ...) + __attribute__((__format__ (printf, 1, 2))); + +#endif /* LOG_H */ blob - 326b249662f3eb72fc53110facb2f4df953932a7 blob + 6d7119b91435454da9173e5993e1e1679ef9aa22 --- parse.y +++ parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.130 2025/11/28 16:10:00 rsadowski Exp $ */ +/* $OpenBSD: parse.y,v 1.131 2026/03/02 19:24:58 rsadowski Exp $ */ /* * Copyright (c) 2020 Matthias Pressfreund @@ -55,6 +55,7 @@ #include "httpd.h" #include "http.h" +#include "log.h" TAILQ_HEAD(files, file) files = TAILQ_HEAD_INITIALIZER(files); static struct file { blob - 66d528668df8490e31f639c477fd44392d80bc38 blob + 861cc4fef97137f56b677acc66c86594625272d9 --- proc.c +++ proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.52 2024/11/21 13:38:45 claudio Exp $ */ +/* $OpenBSD: proc.c,v 1.53 2026/03/02 19:24:58 rsadowski Exp $ */ /* * Copyright (c) 2010 - 2016 Reyk Floeter @@ -35,6 +35,7 @@ #include #include "httpd.h" +#include "log.h" void proc_exec(struct privsep *, struct privsep_proc *, unsigned int, int, char **); blob - a1ede3b1828510761cdea6988d5f556ea153c3fc blob + 0f42ccd442b660887bc9accab2763d7368c56029 --- server.c +++ server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.131 2026/02/28 09:36:08 rsadowski Exp $ */ +/* $OpenBSD: server.c,v 1.132 2026/03/02 19:24:58 rsadowski Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter @@ -43,6 +43,7 @@ #include #include "httpd.h" +#include "log.h" #define MINIMUM(a, b) (((a) < (b)) ? (a) : (b)) blob - c5f9917204c71c0a04b770782a1d38d247dbaad6 blob + 5c4a8d3434e4c35c14ccc5431d51799295457861 --- server_fcgi.c +++ server_fcgi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_fcgi.c,v 1.99 2026/01/02 08:45:16 rsadowski Exp $ */ +/* $OpenBSD: server_fcgi.c,v 1.100 2026/03/02 19:24:58 rsadowski Exp $ */ /* * Copyright (c) 2014 Florian Obser @@ -36,6 +36,7 @@ #include "httpd.h" #include "http.h" +#include "log.h" #define FCGI_PADDING_SIZE 255 #define FCGI_RECORD_SIZE \ blob - 379be0cfdaa7715bba11590513089cfdd17e63a8 blob + b01e0180a5491375c7edc88f2472603a43c7374a --- server_http.c +++ server_http.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_http.c,v 1.160 2026/02/28 09:36:08 rsadowski Exp $ */ +/* $OpenBSD: server_http.c,v 1.161 2026/03/02 19:24:58 rsadowski Exp $ */ /* * Copyright (c) 2020 Matthias Pressfreund @@ -42,6 +42,7 @@ #include "httpd.h" #include "http.h" +#include "log.h" #include "patterns.h" static int server_httpmethod_cmp(const void *, const void *);