lib/igt_kms: rip out custom verbose loggin support
PATCH 1/2 lib/igt_kms: rip out custom verbose loggin support
Instead just piggy-pack on top of igt_log.
Signed-off-by Daniel Vetter <[email protected]>
--- lib/igt_kms.c | 22 +--------------------- lib/igt_kms.h | 2 -- 2 files changed, 1 insertion(+), 23 deletions(-)
lib/igt_kms.c +1 -21
@@ -823,7 +823,7 @@ igt_display_log(igt_display_t *display, const char *fmt, ...)va_list args;int n, i; -if (!display->verbose) +if (igt_log_level >IGT_LOG_DEBUG )return 0 ;va_start (args, fmt);
@@ -883,23 +883,8 @@ void igt_display_init(igt_display_t *display, int drm_fd) {drmModeRes *resources;drmModePlaneRes *plane_resources; -bool verbose; -char *env;int i; -/* -* It's valid to set verbose before the init so we can get debugging -* output for the init() itself. -*/ - verbose = display->verbose; -memset (display,0 ,sizeof (igt_display_t)); - display->verbose = verbose; - -/* allow a verbose override from an env variable */ - env =getenv ("IGT_DISPLAY_VERBOSE" ); -if (env) - display->verbose =atoi (env) !=0 ; -LOG_INDENT (display,"init" ); display->drm_fd = drm_fd;
@@ -993,11 +978,6 @@ void igt_display_init(igt_display_t *display, int drm_fd)LOG_UNINDENT (display); } -void igt_display_set_verbose (igt_display_t *display,bool verbose) -{ - display->verbose = verbose; -} -int igt_display_get_n_pipes (igt_display_t *display) {return display->n_pipes;
lib/igt_kms.h +0 -2
@@ -155,7 +155,6 @@ typedef struct {struct igt_display {int drm_fd; -unsigned int verbose :1 ;int log_shift;int n_pipes;int n_outputs;
@@ -167,7 +166,6 @@ struct igt_display {void igt_display_init (igt_display_t *display,int drm_fd);void igt_display_fini (igt_display_t *display);int igt_display_commit (igt_display_t *display); -void igt_display_set_verbose (igt_display_t *display,bool verbose);int igt_display_get_n_pipes (igt_display_t *display);const char *igt_output_name (igt_output_t *output);
Signature · 1 line
1.8.4.rc3
PATCH 2/2 lib: add igt_vlog to print varargs
... and put it to immediate use in igt_display_log.
To make this all add up also drop the return value of igt_display_log, no one really cared anyway.
Aside: I've noticed that every time another subtest runs (at least with kms_pipe_crc_basic) the log indent level moves one up ...
Signed-off-by Daniel Vetter <[email protected]>
--- lib/igt_core.c | 27 +++++++++++++++++++++++++++ lib/igt_core.h | 1 + lib/igt_kms.c | 15 +++++---------- 3 files changed, 33 insertions(+), 10 deletions(-)
lib/igt_core.c +27 -0
@@ -1074,3 +1074,30 @@ void igt_log(enum igt_log_level level, const char *format, ...)vprintf (format, args);va_end (args); } + +/** +* igt_vlog: +* @level: #igt_log_level +* @format: format string +* @args: variable arguments lists +* +* This is the generic logging helper function using an explicit varargs +* structure and hence useful to implement domain-specific logging +* functions. +* +* If there is no need to wrap up a vararg list in the caller it is simpler to +* just use igt_log(). +*/ +void igt_vlog (enum igt_log_level level,const char *format,va_list args) +{ +assert (format); + +if (igt_log_level > level) +return ; + +if (level ==IGT_LOG_WARN ) { +fflush (stdout); +vfprintf (stderr, format, args); + }else +vprintf (format, args); +}
lib/igt_core.h +1 -0
@@ -389,6 +389,7 @@ enum igt_log_level { }; __attribute__((format (printf,2 ,3 )))void igt_log (enum igt_log_level level,const char *format, ...); +void igt_vlog (enum igt_log_level level,const char *format,va_list args);/** * igt_debug:
lib/igt_kms.c +5 -10
@@ -817,23 +817,18 @@ const char *plane_name(enum igt_plane p) } while (0)#define LOG (d, fmt, ...) igt_display_log(d, fmt, ## __VA_ARGS__) -static int __attribute__((format (printf,2 ,3 ))) +static void __attribute__((format (printf,2 ,3 )))igt_display_log (igt_display_t *display,const char *fmt, ...) {va_list args; -int n, i; - -if (igt_log_level >IGT_LOG_DEBUG ) -return 0 ; +int i;va_start (args, fmt); - n =printf ("display: " ); +igt_debug ("display: " );for (i =0 ; i < display->log_shift; i++) - n +=printf ("%s" ,LOG_SPACES ); - n +=vprintf (fmt, args); +igt_debug ("%s" ,LOG_SPACES ); +igt_vlog (IGT_LOG_DEBUG , fmt, args);va_end (args); - -return n; }static void igt_display_log_shift (igt_display_t *display,int shift)
Signature · 1 line
1.8.4.rc3