From 69612bdea7ce4935bf16e616320045742af5ca20 Mon Sep 17 00:00:00 2001 From: okan Date: Sun, 4 Feb 2018 22:56:26 +0000 Subject: Slightly expand and expose verbose debugging. --- util.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'util.c') diff --git a/util.c b/util.c index 6898a26..5eb059f 100644 --- a/util.c +++ b/util.c @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: util.c,v 1.21 2018/02/02 13:40:55 okan Exp $ + * $OpenBSD: util.c,v 1.22 2018/02/04 22:56:26 okan Exp $ */ #include @@ -123,14 +123,16 @@ log_msg(const char *msg, va_list ap) } void -log_debug(const char *func, const char *msg, ...) +log_debug(int level, const char *func, const char *msg, ...) { char *fmt; va_list ap; + if (Conf.debug < level) + return; + va_start(ap, msg); - if (asprintf(&fmt, "%s: %s", func, msg) == -1) - exit(1); + xasprintf(&fmt, "debug%d: %s: %s", level, func, msg); log_msg(fmt, ap); va_end(ap); } -- cgit v1.2.3-2-gb3c3