diff options
author | Ian Romanick <idr@us.ibm.com> | 2007-02-20 15:19:23 -0800 |
---|---|---|
committer | Ian Romanick <idr@us.ibm.com> | 2007-02-20 15:19:23 -0800 |
commit | a4b344baa2484c65a1618f3cce3a94c91dea8ef7 (patch) | |
tree | f2d3e6571c94378db5a87d882c039909d6a47d3f /src/egl/main/egllog.c | |
parent | f0bcee5db0523edaacbd1fb0eaa74b435ae7c188 (diff) | |
parent | 440759c2cdfdd9a7fbc6500fca2afa519126c1a7 (diff) |
Merge branch 'master' of ssh+git://idr@git.freedesktop.org/git/mesa/mesa
Diffstat (limited to 'src/egl/main/egllog.c')
-rw-r--r-- | src/egl/main/egllog.c | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/src/egl/main/egllog.c b/src/egl/main/egllog.c index 59b1d2684e..dc1daaa996 100644 --- a/src/egl/main/egllog.c +++ b/src/egl/main/egllog.c @@ -6,13 +6,44 @@ #include <stdarg.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include "egllog.h" #define MAXSTRING 1000 +#define FALLBACK_LOG_LEVEL _EGL_DEBUG +#define FALLBACK_LOG_LEVEL_STR "debug" +static EGLint ReportingLevel = -1; -/* XXX init this with an env var or something */ -static EGLint ReportingLevel = _EGL_DEBUG; + +static void +log_level_initialize (void) +{ + char *log_env = getenv ("EGL_LOG_LEVEL"); + + if (log_env == NULL) { + ReportingLevel = FALLBACK_LOG_LEVEL; + } + else if (strcasecmp (log_env, "fatal") == 0) { + ReportingLevel = _EGL_FATAL; + } + else if (strcasecmp (log_env, "warning") == 0) { + ReportingLevel = _EGL_WARNING; + } + else if (strcasecmp (log_env, "info") == 0) { + ReportingLevel = _EGL_INFO; + } + else if (strcasecmp (log_env, "debug") == 0) { + ReportingLevel = _EGL_DEBUG; + } + else { + fprintf (stderr, "Unrecognized EGL_LOG_LEVEL environment variable value. " + "Expected one of \"fatal\", \"warning\", \"info\", \"debug\". " + "Got \"%s\". Falling back to \"%s\".\n", + log_env, FALLBACK_LOG_LEVEL_STR); + ReportingLevel = FALLBACK_LOG_LEVEL; + } +} /** @@ -25,6 +56,12 @@ _eglLog(EGLint level, const char *fmtStr, ...) va_list args; char msg[MAXSTRING]; const char *levelStr; + static int log_level_initialized = 0; + + if (!log_level_initialized) { + log_level_initialize (); + log_level_initialized = 1; + } if (level <= ReportingLevel) { switch (level) { |