From: Daniel Vetter Subject: [PATCH] lib/aux: Print progress output at INFO level Date: Tue, 30 Sep 2014 22:55:35 +0200 Message-ID: <1412110535-28078-1-git-send-email-daniel.vetter@ffwll.ch> References: <1412095552-27429-1-git-send-email-daniel.vetter@ffwll.ch> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-wi0-f177.google.com (mail-wi0-f177.google.com [209.85.212.177]) by gabe.freedesktop.org (Postfix) with ESMTP id AD2886ED3E for ; Tue, 30 Sep 2014 13:55:44 -0700 (PDT) Received: by mail-wi0-f177.google.com with SMTP id cc10so4683017wib.16 for ; Tue, 30 Sep 2014 13:55:43 -0700 (PDT) In-Reply-To: <1412095552-27429-1-git-send-email-daniel.vetter@ffwll.ch> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: Intel Graphics Development Cc: Daniel Vetter , Daniel Vetter , Thomas Wood List-Id: intel-gfx@lists.freedesktop.org With the structured logging it makes more sense to tune this down a bit. Also, this way it is consistent with Thomas Wood's new activity indicator helper. Spotted while discussing Thomas' patch with him. v2: Thomas noticed that I've forgotten the fflush. Extract igt_interactive_info for both igt_progress and igt_print_activity. v3: Interactive output should go to stderr. Also extract the "is this a terminal" check. Cc: Thomas Wood Cc: Chris Wilson Signed-off-by: Daniel Vetter --- lib/igt_aux.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/igt_aux.c b/lib/igt_aux.c index 7c07b7d0722c..b32297ee508c 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -214,6 +214,23 @@ void igt_permute_array(void *array, unsigned size, } } +__attribute__((format(printf, 1, 2))) +static void igt_interactive_info(const char *format, ...) +{ + va_list args; + + if (!isatty(STDERR_FILENO)) + return; + + if (igt_log_level > IGT_LOG_INFO) + return; + + va_start(args, format); + vfprintf(stderr, format, args); + va_end(args); +} + + /** * igt_progress: * @header: header string to prepend to the progress indicator @@ -229,11 +246,8 @@ void igt_progress(const char *header, uint64_t i, uint64_t total) { int divider = 200; - if (!isatty(fileno(stderr))) - return; - if (i+1 >= total) { - igt_warn("\r%s100%%\n", header); + igt_interactive_info("\r%s100%%\n", header); return; } @@ -242,8 +256,8 @@ void igt_progress(const char *header, uint64_t i, uint64_t total) /* only bother updating about every 0.5% */ if (i % (total / divider) == 0) - igt_warn("\r%s%3llu%%", header, - (long long unsigned)i * 100 / total); + igt_interactive_info("\r%s%3llu%%", header, + (long long unsigned)i * 100 / total); } /** @@ -254,11 +268,7 @@ void igt_progress(const char *header, uint64_t i, uint64_t total) */ void igt_print_activity(void) { - if (!isatty(STDOUT_FILENO)) - return; - - igt_info("."); - fflush(stdout); + igt_interactive_info("."); } /* mappable aperture trasher helper */ -- 2.1.1