[Piglit] [PATCH 1/2] util/log: Add function piglit_logd()
Ilia Mirkin
imirkin at alum.mit.edu
Mon Jun 30 17:14:16 PDT 2014
On Mon, Jun 30, 2014 at 8:11 PM, Chad Versace
<chad.versace at linux.intel.com> wrote:
> The function logs a debug message if environment variable
> PIGLIT_DEBUG is "1" or "true".
>
> Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
Series is Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
In fact feel free to ignore my change and just push yours out to
switch those info logs to debug logs.
> ---
> tests/util/piglit-log.c | 37 +++++++++++++++++++++++++++++++++++++
> tests/util/piglit-log.h | 6 ++++++
> 2 files changed, 43 insertions(+)
>
> diff --git a/tests/util/piglit-log.c b/tests/util/piglit-log.c
> index 1cf9b10..99d13d3 100644
> --- a/tests/util/piglit-log.c
> +++ b/tests/util/piglit-log.c
> @@ -115,3 +115,40 @@ piglit_logi(const char *fmt, ...)
> piglit_log_tagv("info", fmt, ap);
> va_end(ap);
> }
> +
> +void
> +piglit_logd(const char *fmt, ...)
> +{
> + static bool once = true;
> + static bool debug = false;
> + va_list ap;
> +
> + if (once) {
> + const char *env;
> +
> + once = false;
> + env = getenv("PIGLIT_DEBUG");
> +
> + if (env == NULL
> + || streq(env, "")
> + || streq(env, "0")
> + || streq(env, "false")) {
> + debug = false;
> + } else if (streq(env, "1")
> + || streq(env, "true")) {
> + debug = true;
> + } else {
> + piglit_loge("PIGLIT_DEBUG has invalid value: "
> + "%s\n", env);
> + abort();
> + }
> + }
> +
> + if (!debug) {
> + return;
> + }
> +
> + va_start(ap, fmt);
> + piglit_log_tagv("debug", fmt, ap);
> + va_end(ap);
> +}
> diff --git a/tests/util/piglit-log.h b/tests/util/piglit-log.h
> index d52ccd9..c431ea0 100644
> --- a/tests/util/piglit-log.h
> +++ b/tests/util/piglit-log.h
> @@ -64,6 +64,12 @@ piglit_loge(const char *fmt, ...);
> void
> piglit_logi(const char *fmt, ...);
>
> +/**
> + * Log a debug message if environment variable PIGLIT_DEBUG is "1" or "true".
> + */
> +void
> +piglit_logd(const char *fmt, ...);
> +
> #ifdef __cplusplus
> } /* end extern "C" */
> #endif
> --
> 2.0.0
>
More information about the Piglit
mailing list