From patchwork Thu Jan 22 00:26:58 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 19742 X-Patchwork-Delegate: jk@ozlabs.org Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 2F16FDDF6D for ; Thu, 22 Jan 2009 14:35:42 +1100 (EST) X-Original-To: cbe-oss-dev@ozlabs.org Delivered-To: cbe-oss-dev@ozlabs.org Received: from hera.kernel.org (hera.kernel.org [140.211.167.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7FB25DDF57; Thu, 22 Jan 2009 14:31:55 +1100 (EST) Received: from hera.kernel.org (IDENT:U2FsdGVkX19JboXHL7YOZBWzOOToDSR7HBPk41hZcvQ@localhost [127.0.0.1]) by hera.kernel.org (8.14.2/8.14.2) with ESMTP id n0M3A4Iw003016 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 22 Jan 2009 03:10:04 GMT Received: (from geoff@localhost) by hera.kernel.org (8.14.2/8.13.1/Submit) id n0M3A4wl003015; Thu, 22 Jan 2009 03:10:04 GMT Message-Id: <20090122002653.545966402@am.sony.com> References: <20090122002653.146035454@am.sony.com> User-Agent: quilt/0.46-1 Date: Wed, 21 Jan 2009 16:26:58 -0800 From: Geoff Levand To: Jeremy Kerr Content-Disposition: inline; filename=flush-log-on-write.diff X-Virus-Scanned: ClamAV 0.93.3/8886/Wed Jan 21 22:46:06 2009 on hera.kernel.org X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on hera.kernel.org X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.0 (hera.kernel.org [127.0.0.1]); Thu, 22 Jan 2009 03:10:06 +0000 (UTC) Cc: cbe-oss-dev@ozlabs.org Subject: [Cbe-oss-dev] [patch 5/9] petitboot: Flush log stream on write X-BeenThere: cbe-oss-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Discussion about Open Source Software for the Cell Broadband Engine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Flush the pb_log stream when the stream is changed, and add an option to flush the pb_log stream on every write. Useful while debugging. Signed-off-by: Geoff Levand --- lib/log.c | 10 ++++++++++ lib/log.h | 1 + 2 files changed, 11 insertions(+) --- a/lib/log.c +++ b/lib/log.c @@ -4,6 +4,7 @@ #include "log.h" static FILE *logf; +static int always_flush; void pb_log(const char *fmt, ...) { @@ -15,9 +16,18 @@ void pb_log(const char *fmt, ...) va_start(ap, fmt); vfprintf(stream, fmt, ap); va_end(ap); + + if (always_flush) + fflush(stream); } void pb_log_set_stream(FILE *stream) { + fflush(logf ? logf : stdout); logf = stream; } + +void pb_log_always_flush(int state) +{ + always_flush = state; +} --- a/lib/log.h +++ b/lib/log.h @@ -5,5 +5,6 @@ void pb_log(const char *fmt, ...); void pb_log_set_stream(FILE *stream); +void pb_log_always_flush(int state); #endif /* _LOG_H */