lib/aux: Print progress output with igt_info
PATCH 1/1 lib/aux: Print progress output with igt_info
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.
--- lib/igt_aux.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
lib/igt_aux.c +3 -3
@@ -229,11 +229,11 @@ void igt_progress(const char *header, uint64_t i, uint64_t total) {int divider =200 ; -if (!isatty (fileno (stderr))) +if (!isatty (STDOUT_FILENO ))return ;if (i+1 >= total) { -igt_warn ("\r%s100%%\n" , header); +igt_info ("\r%s100%%\n" , header);return ; }
@@ -242,7 +242,7 @@ 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, +igt_info ("\r%s%3llu%%" , header, (long long unsigned )i *100 / total); }
Signature · 1 line
2.1.1
Quoted 3 lines · Daniel Vetter
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.
Tune it down? It was on stderr to segregate it from stdout. So either the activity indicator is sufficient to take over, or it should be made so.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 8 lines · Chris Wilson
Quoted 3 lines · Daniel Vetter
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.
Tune it down? It was on stderr to segregate it from stdout. So either the activity indicator is sufficient to take over, or it should be made so.
The revised patch after a bit of discussion with Thomas on irc does it better. Let me resend.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 1/1 lib/aux: Print progress output at INFO level
In reply to Daniel VetterWith 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.
--- lib/igt_aux.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-)
lib/igt_aux.c +21 -11
@@ -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 */
Signature · 1 line
2.1.1
Re: [PATCH] lib/aux: Print progress output at INFO level
Quoted 9 lines · Daniel Vetter
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_infofor bothigt_progressandigt_print_activity.
Quoted 6 lines
v3: Interactive output should go to stderr. Also extract the "is this a terminal" check.
Cc Thomas Wood <[email protected]>Cc Chris Wilson <[email protected]>Signed-off-by Daniel Vetter <[email protected]>
Not reusing the igt_warn() is great as well (we had earlier problems when igt_warn* became smarter...)
Nothing to complain about here, lgtm.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre