From patchwork Thu Aug 2 17:29:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 952912 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41hHKL4pfhz9s2g for ; Fri, 3 Aug 2018 03:31:34 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="njiqu7cl"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41hHKL3CbvzF2D0 for ; Fri, 3 Aug 2018 03:31:34 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="njiqu7cl"; dkim-atps=neutral X-Original-To: Petitboot@lists.ozlabs.org Delivered-To: Petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=infradead.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=geoff@infradead.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="njiqu7cl"; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41hHH751gBzF2D8 for ; Fri, 3 Aug 2018 03:29:38 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Date:Cc:To:Subject:From:References: In-Reply-To:Message-Id:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=wElgGKHg27LxslOehNSMy0/cD6ooH8seS5YOJqhFJvU=; b=njiqu7cl/cp/2Mgl/ahchBvJS u9u+91McYOp74yTokuw4puomJtq4U35GKXrESnXvgnjTynAN0MJsK5prJdc6TWQr25QQ3lNTeJ9ax 4CTVtIbEC8HVM2CboZYaM+C3W/nb7ugn/BBUOaS07B5TJ5CuRtuh6grUl4+vONbt64ApwULdSiKZ/ bInDxwGMpStID/kW9L8DaeW89uDo4HEPpY6JHq5NFkQRDfXZjrdDLVR5nXUoLvxyG6MF2h/YVNrGn C0pY4y1XHQcWpTVzdiFTn4z+AvWIwj8aWrcwJqcyYsVV8NtLHnh7ov29BRdLLDJFIm7inSVxVmoTw K6NG1RduQ==; Received: from geoff by merlin.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1flHPp-0007WV-UM; Thu, 02 Aug 2018 17:29:33 +0000 Message-Id: <1f34794c770bf970381f6b72a3f85177cc1d4853.1533230644.git.geoff@infradead.org> In-Reply-To: References: From: Geoff Levand Patch-Date: Thu, 2 Aug 2018 10:19:53 -0700 Subject: [PATCH v2 04/30] lib/log: Add verbose logging routines To: Samuel Mendoza-Jonas Date: Thu, 02 Aug 2018 17:29:33 +0000 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ge Song , Petitboot@lists.ozlabs.org MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" Add three new logging routines pb_log_fn and pb_debug_fn, which print the calling function's name to the log, and pb_debug_fl which prints the calling function's name and the file line number to the log. Signed-off-by: Geoff Levand --- lib/log/log.c | 31 +++++++++++++++++++++++++++++++ lib/log/log.h | 10 ++++++++++ s | 0 3 files changed, 41 insertions(+) create mode 100644 s diff --git a/s b/s new file mode 100644 index 0000000..e69de29 diff --git a/lib/log/log.c b/lib/log/log.c index adb2078..0b145e0 100644 --- a/lib/log/log.c +++ b/lib/log/log.c @@ -34,6 +34,15 @@ void pb_log(const char *fmt, ...) va_end(ap); } +void _pb_log_fn(const char *func, const char *fmt, ...) +{ + va_list ap; + pb_log("%s: ", func); + va_start(ap, fmt); + __log(fmt, ap); + va_end(ap); +} + void pb_debug(const char *fmt, ...) { va_list ap; @@ -44,6 +53,28 @@ void pb_debug(const char *fmt, ...) va_end(ap); } +void _pb_debug_fn(const char *func, const char *fmt, ...) +{ + va_list ap; + if (!debug) + return; + pb_log("%s: ", func); + va_start(ap, fmt); + __log(fmt, ap); + va_end(ap); +} + +void _pb_debug_fl(const char *func, int line, const char *fmt, ...) +{ + va_list ap; + if (!debug) + return; + pb_log("%s:%d: ", func, line); + va_start(ap, fmt); + __log(fmt, ap); + va_end(ap); +} + void __pb_log_init(FILE *fp, bool _debug) { if (logf) diff --git a/lib/log/log.h b/lib/log/log.h index 9454596..2d4fd91 100644 --- a/lib/log/log.h +++ b/lib/log/log.h @@ -5,7 +5,17 @@ #include void __attribute__ ((format (printf, 1, 2))) pb_log(const char *fmt, ...); +void __attribute__ ((format (printf, 2, 3))) _pb_log_fn(const char *func, + const char *fmt, ...); +#define pb_log_fn(args...) _pb_log_fn(__func__, args) + void __attribute__ ((format (printf, 1, 2))) pb_debug(const char *fmt, ...); +void __attribute__ ((format (printf, 2, 3))) _pb_debug_fn(const char *func, + const char *fmt, ...); +#define pb_debug_fn(args...) _pb_debug_fn(__func__, args) +void __attribute__ ((format (printf, 3, 4))) _pb_debug_fl(const char *func, + int line, const char *fmt, ...); +#define pb_debug_fl(args...) _pb_debug_fl(__func__, __LINE__, args) void __pb_log_init(FILE *stream, bool debug);