From 2661aba8db1cfb2d8758ce25c2e36b16612345ac Mon Sep 17 00:00:00 2001 From: Simo Piiroinen Date: Wed, 6 May 2020 08:35:35 +0300 Subject: [PATCH] [logging] Flush after each message when logging to stderr When logging to stderr, the relevance of timestamps can suffer from unpredictable flush schedule if output happens to be block buffered. Ensure stderr is flushed after each message. Signed-off-by: Simo Piiroinen --- mce-log.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mce-log.c b/mce-log.c index eb90257b..53904eb2 100644 --- a/mce-log.c +++ b/mce-log.c @@ -2,8 +2,9 @@ * @file mce-log.c * Logging functions for Mode Control Entity *

- * Copyright © 2006-2007, 2010 Nokia Corporation and/or its subsidiary(-ies). - * Copyright (C) 2012-2019 Jolla Ltd. + * Copyright (c) 2006 - 2007, 2010 Nokia Corporation and/or its subsidiary(-ies). + * Copyright (c) 2012 - 2020 Jolla Ltd. + * Copyright (c) 2020 Open Mobile Platform LLC. *

* @author David Weinehall * @author Simo Piiroinen @@ -68,6 +69,7 @@ static void timestamp(struct timeval *tv) mce_log_name(), (long)diff.tv_sec, (long)(diff.tv_usec/1000), "END OF BURST"); + fflush(stderr); start = *tv; } prev = *tv; @@ -191,6 +193,7 @@ void mce_log_unconditional_va(loglevel_t loglevel, const char *const file, (long)tv.tv_sec, (long)(tv.tv_usec/1000), mce_log_level_tag(loglevel), msg); + fflush(stderr); } else { /* Use NOTICE priority when reporting LL_EXTRA * and LL_CRUCIAL logging */