From patchwork Mon Jul 9 21:21:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 941681 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41PdZY69Q2z9rxs for ; Tue, 10 Jul 2018 07:22:13 +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="GPTVq5Xm"; 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 41PdZY4Z0szDrcC for ; Tue, 10 Jul 2018 07:22:13 +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="GPTVq5Xm"; 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 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 41PdZJ3BYGzDr2p for ; Tue, 10 Jul 2018 07:21:59 +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=Nc2rcRx2ws74lviXOb5qnOm/4uPwMSyKYuaop+vdV7s=; b=GPTVq5Xm/szy72WGtEYAFFVsY 2Lppa3NRLfDzHaeRFY5copjDWmrJMChEeSrJPvo2UBYwN6YQQUpsB4N1LLj9a8txAP2xVFm1+VuY/ WSZkP8gBWMOc1u47Uj4MPjYu85TGMBPyhpkUxWnHb5oShl/hu9wH6ylJsiBbbFwkM515qKsx5yakG cEeujABnmO5VcMGyUD1NoAmKD6gm7EskFkEaJMjrn6lZOvA+JpR0MRB1vLq69njxaZTks8Ufd+Yrh SwNpBFpQYdY2GmsSSNFKoglavtcWamXpjB9DADJPMys1myDXYKyxGtt7F5aQiKKgbcftZP6ZTV2i4 6bOY8eMCg==; Received: from geoff by merlin.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fcdbX-0001RS-1w; Mon, 09 Jul 2018 21:21:55 +0000 Message-Id: <70da1a43de28d88eaafe303a71db5ba33a464fdd.1531170563.git.geoff@infradead.org> In-Reply-To: References: From: Geoff Levand Patch-Date: Mon, 9 Jul 2018 13:57:53 -0700 Subject: [PATCH v1 03/10] lib/log: Add verbose logging routines To: Samuel Mendoza-Jonas Date: Mon, 09 Jul 2018 21:21:55 +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: 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 44543d0..4c832bc 100644 --- a/lib/log/log.c +++ b/lib/log/log.c @@ -23,6 +23,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; @@ -33,6 +42,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);