From patchwork Mon Jul 30 01:48:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Mendoza-Jonas X-Patchwork-Id: 950703 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 41f2Yf48gZz9s0R for ; Mon, 30 Jul 2018 11:49:26 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mendozajonas.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="GcobGGbC"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="YpoRSv5X"; 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 41f2Yf2TdMzF162 for ; Mon, 30 Jul 2018 11:49:26 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=mendozajonas.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="GcobGGbC"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="YpoRSv5X"; dkim-atps=neutral X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=mendozajonas.com (client-ip=64.147.123.19; helo=wout3-smtp.messagingengine.com; envelope-from=sam@mendozajonas.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=mendozajonas.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mendozajonas.com header.i=@mendozajonas.com header.b="GcobGGbC"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="YpoRSv5X"; dkim-atps=neutral Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41f2Y75GjvzF12X for ; Mon, 30 Jul 2018 11:48:58 +1000 (AEST) Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.west.internal (Postfix) with ESMTP id 017EB457; Sun, 29 Jul 2018 21:48:52 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Sun, 29 Jul 2018 21:48:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= mendozajonas.com; h=cc:date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=rbMXVtOW309Z7ng0I DL4LYYSszgbS5tpsxyC0uQ1mRM=; b=GcobGGbCAE4xp34vQ2R18XNE4VYVST0A3 1pabjCKOFdaz2twWZrfTB0kBA06GCD1h8CGsS7JfagRo/oH5Q9djgNmzj5NNfwSF NDvEHvbDgqXEF4c+PvyP8LrQlIIJOAyL8pl/rmz2AuEbxlpVla0wwrrmoSQNjZs5 ZRFWJapWr6BAWuxb7UiBF9BnmxtLulL10GVhj0sgVhATvZDKr50PMDE6SzEeeYFU FuH3lyc5MlX1Xy4AQKbStSBWqJhIcwg3kCDGxnbvCjG2FaRUpnLyQJ/m3xIjZ4Jz 95ju5XU0FQZg7SCjlLYTTulZNeeOMG8n/+r2rsm4O4KhgcimuQ/vQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=rbMXVtOW309Z7ng0I DL4LYYSszgbS5tpsxyC0uQ1mRM=; b=YpoRSv5XjNC8ujitZ0DjMFs69BiGLsecV 8FkuJPFxPZQ8U0D/v4Puo5n77okAlQ+tPIewij2QSatdllQMH4XhMwPwBrYapqs2 VY3EMejBDoKpdpXFs1W76EPyuTwbC8S+u1xhQ1dD8Rw1T6Xohds6q0JhHJVP5Mac kA8JlJd96Qgzgc54Lu1TYaigNyELqbcN7DgpKb4PHXQZ+gUJGwUdonbdVSfrs90S PBUjtPd19YmGk4ponEymOpYWK2QXXyUFET/qVpDzKjp/E+l6/7OfAQVwoB+o549V NryVdclntFno4eBM730qO2cC51cLPS5uPeBr4+/Tp5WReMgp8cY0Q== X-ME-Proxy: X-ME-Sender: Received: from v4.ozlabs.ibm.com (unknown [122.99.82.10]) by mail.messagingengine.com (Postfix) with ESMTPA id DD38FE4116; Sun, 29 Jul 2018 21:48:50 -0400 (EDT) From: Samuel Mendoza-Jonas To: petitboot@lists.ozlabs.org Subject: [PATCH 1/3] lib/log: Include timestamp prefix Date: Mon, 30 Jul 2018 11:48:24 +1000 Message-Id: <20180730014826.19097-1-sam@mendozajonas.com> X-Mailer: git-send-email 2.18.0 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: Samuel Mendoza-Jonas MIME-Version: 1.0 Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" The relative time between logged events is very useful during debugging, particularly when debugging autoboot failures. Prepend a short HH:MM:SS timestamp to each line logged. Signed-off-by: Samuel Mendoza-Jonas --- lib/log/log.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/log/log.c b/lib/log/log.c index 44543d0..adb2078 100644 --- a/lib/log/log.c +++ b/lib/log/log.c @@ -1,6 +1,8 @@ #include #include +#include +#include #include "log.h" @@ -9,8 +11,17 @@ static bool debug; static void __log(const char *fmt, va_list ap) { + char hms[20] = {'\0'}; + time_t t; + if (!logf) return; + + /* Add timestamp */ + t = time(NULL); + strftime(hms, sizeof(hms), "%T", localtime(&t)); + fprintf(logf, "[%s] ", hms); + vfprintf(logf, fmt, ap); fflush(logf); }