From patchwork Mon Aug 13 16:23:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 957048 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 41q1Hd3XBTz9ryt for ; Tue, 14 Aug 2018 02:23:25 +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="3i1Rwwl/"; 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 41q1Hd1t9nzF0h0 for ; Tue, 14 Aug 2018 02:23:25 +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="3i1Rwwl/"; 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="3i1Rwwl/"; 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 41q1HT0DtfzDrYj for ; Tue, 14 Aug 2018 02:23:15 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:References:Cc:To:From:Subject:Sender :Reply-To: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=f7/zfw63hXVJh1vwQzuT4ZLrDwQllbzjy1+ZQOA8CGk=; b=3i1Rwwl/LQC9TBCGStKA2dlceL 8B3Ur5d26bydTYHQjkJblE5KUt5B94QFw/7xcSB9ha593pUaxaMOWSjW3MCtBp1a0CTA7iABa147n AB55hy+KbcrG1ktHYKdKwGgw1BMHPiFZDZiLlFH4XbQrCl1no+OC7GJi8xfkPljYMT2nA4RA+wWnR 2jygUpmV08VUvK1uW60ch8F7TuQuVPExhkb6FV4AI6z5bk12OW4hT8NPnQXeWJqrQNC5gvQEYANyG mRvw1aHzKJ/FAnPBj515yr9LXSsdE/SEkdXlg/vfcCaRxxxukymAwXmtahFRvXVeC+x919NWJ3rMh Qg5k91VA==; Received: from 50-233-148-155-static.hfc.comcastbusiness.net ([50.233.148.155] helo=[10.18.6.178]) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fpFcb-0005Hy-Vz; Mon, 13 Aug 2018 16:23:10 +0000 Subject: [PATCH v2] pb_log: Break out timestamp From: Geoff Levand To: Samuel Mendoza-Jonas References: Message-ID: Date: Mon, 13 Aug 2018 09:23:07 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US 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 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" Fixes double timestamp on pb_log_fn, pb_debug_fn. Signed-off-by: Geoff Levand --- v2: Add timestamp to pb_debug. lib/log/log.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/log/log.c b/lib/log/log.c index 5466d81..7f14232 100644 --- a/lib/log/log.c +++ b/lib/log/log.c @@ -9,7 +9,7 @@ static FILE *logf; static bool debug; -static void __log(const char *fmt, va_list ap) +static void __log_timestamp(void) { char hms[20] = {'\0'}; time_t t; @@ -17,10 +17,15 @@ static void __log(const char *fmt, va_list ap) if (!logf) return; - /* Add timestamp */ t = time(NULL); strftime(hms, sizeof(hms), "%T", localtime(&t)); fprintf(logf, "[%s] ", hms); +} + +static void __log(const char *fmt, va_list ap) +{ + if (!logf) + return; vfprintf(logf, fmt, ap); fflush(logf); @@ -30,6 +35,7 @@ void pb_log(const char *fmt, ...) { va_list ap; va_start(ap, fmt); + __log_timestamp(); __log(fmt, ap); va_end(ap); } @@ -49,6 +55,7 @@ void pb_debug(const char *fmt, ...) if (!debug) return; va_start(ap, fmt); + __log_timestamp(); __log(fmt, ap); va_end(ap); }