[Libva] [PATCH] Allow control over logging of messages from libva

Barry Scott barry.scott at onelan.co.uk
Thu May 14 06:45:36 PDT 2015


This patch has a error in it. I will resend with the fix.

On Thu 14 May 2015 13:59:45 Barry Scott wrote:
> In our application the messages output from va_infoMessage are
> filling log files with uninteresting messages. Which will cause
> log rotate to push out other messages of interest.
> 
> This patch allows the output of both va_errorMessage and
> va_infoMessage to be controlled by the LIBVA_LOG_LEVEL
> environment variable. Setting LIBVA_LOG_LEVEL=1 will show
> error messages and this is the default. Setting
> LIBVA_LOG_LEVEL=2 will show both info and error messages.
> Setting LIBVA_LOG_LEVEL=0 will turn off info and error
> messages.
> 
> Signed-off-by: Barry Scott <barry.scott at onelan.co.uk>
> ---
>  va/va.c | 25 ++++++++++++++++++++++++-
>  1 file changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/va/va.c b/va/va.c
> index 0298068..013b82e 100644
> --- a/va/va.c
> +++ b/va/va.c
> @@ -48,6 +48,10 @@
>  #define CHECK_MAXIMUM(s, ctx, var) if (!va_checkMaximum(ctx->max_##var,
> #var)) s = VA_STATUS_ERROR_UNKNOWN; #define CHECK_STRING(s, ctx, var) if
> (!va_checkString(ctx->str_##var, #var)) s = VA_STATUS_ERROR_UNKNOWN;
> 
> +#define LOG_LEVEL_INFO = 2
> +#define LOG_LEVEL_ERROR = 1
> +static int log_level = LOG_LEVEL_ERROR;
> +
>  /*
>   * read a config "env" for libva.conf or from environment setting
>   * liva.conf has higher priority
> @@ -108,6 +112,10 @@ void va_errorMessage(const char *msg, ...)
>      va_list args;
>      int n, len;
> 
> +    if (log_level < LOG_LEVEL_ERROR) {
> +        return;
> +    }
> +
>      va_start(args, msg);
>      len = vsnprintf(buf, sizeof(buf), msg, args);
>      va_end(args);
> @@ -133,6 +141,10 @@ void va_infoMessage(const char *msg, ...)
>      va_list args;
>      int n, len;
> 
> +    if (log_level < LOG_LEVEL_INFO) {
> +        return;
> +    }
> +
>      va_start(args, msg);
>      len = vsnprintf(buf, sizeof(buf), msg, args);
>      va_end(args);
> @@ -200,7 +212,18 @@ static VAStatus va_openDriver(VADisplay dpy, char
> *driver_name) char *search_path = NULL;
>      char *saveptr;
>      char *driver_dir;
> -
> +
> +    /* set the log level from the environement variable */
> +    char *log_env_var;
> +    log_env_var = getenv("LIBVA_LOG_LEVEL");
> +    if (log_env_var) {
> +        char *end;
> +        int level = strtol(log_env_var, &end, 10);
> +        if (*end == 0) {
> +            log_level = level;
> +        }
> +    }
> +
>      if (geteuid() == getuid())
>          /* don't allow setuid apps to use LIBVA_DRIVERS_PATH */
>          search_path = getenv("LIBVA_DRIVERS_PATH");



More information about the Libva mailing list