From patchwork Wed Aug 8 00:01:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 954749 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 41lWlW4Fp2z9s3q for ; Wed, 8 Aug 2018 10:01:59 +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="gpXji+qU"; 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 41lWlW2KXVzDqrN for ; Wed, 8 Aug 2018 10:01:59 +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="gpXji+qU"; 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="gpXji+qU"; 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 41lWkj0MMZzDqk8 for ; Wed, 8 Aug 2018 10:01:14 +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=O5uYGcvNpRrDfYHmCxgxT4UKA+ngRIhqlO/Tj9i7AEg=; b=gpXji+qUG4uuploiS+Qhn5xnz XqFvqqoIQuMi6ONJXusYlxRIfchyHHo8Y1247/qZ4KfzoSJJnPL7Nw9RTuhgbfuCPCG1dJVVfVLtC QrhqtjyDZxVp6AriwEQ9/8YvC6hgPOJFqKYRZDa6aGOHxla49b7u+DXtjS+JlEoJWpK3+KUZw10Ec yQLtmP9DaGxgLQHaB3sF1sCQNL9/WyJ+INHmKnN9OmI7wtADAAo7XFj+bF7Rgyzs7fKejYkaRARnW x9/l3CgDKoLm2b3wzFeTe2SVUbqjW0uZZavsLib6Yn5i9+QOLcugCGoEp/dN9O1KPcp7NnJgMzXuj 6pf69V1sA==; Received: from geoff by merlin.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fnBuX-0004Tp-Rp; Wed, 08 Aug 2018 00:01:09 +0000 Message-Id: In-Reply-To: References: From: Geoff Levand Patch-Date: Tue, 7 Aug 2018 16:54:47 -0700 Subject: [PATCH v1 3/6] pb_log: Break out timestamp To: Samuel Mendoza-Jonas Date: Wed, 08 Aug 2018 00:01:09 +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" Fixes double timestamp on pb_log_fn, pb_debug_fn. Signed-off-by: Geoff Levand --- lib/log/log.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/log/log.c b/lib/log/log.c index 5466d81..98b38dd 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); }