]> git.tuebingen.mpg.de Git - osl.git/commitdiff
Fix loglevel handling.
authorAndre Noll <maan@systemlinux.org>
Sat, 31 May 2008 17:48:32 +0000 (19:48 +0200)
committerAndre Noll <maan@systemlinux.org>
Sat, 31 May 2008 17:48:32 +0000 (19:48 +0200)
Use the content of the enviroment variable OSL_LOGLEVEL.

osl.c

diff --git a/osl.c b/osl.c
index 81b035ddbf8c64588b350506451867a832f2a23e..cc0e641f1c53af37541c97090dc769723658b79b 100644 (file)
--- a/osl.c
+++ b/osl.c
@@ -90,6 +90,16 @@ __export const char *osl_strerror(int num)
        return msgstr.str + errmsgidx[num];
 }
 
+static int loglevel;
+
+static void __attribute ((constructor)) init_loglevel(void)
+{
+       char *p = getenv("OSL_LOGLEVEL");
+
+       /* don't log anything if unset */
+       loglevel = p? atoi(p) : EMERG + 1;
+}
+
 /**
  * The log function.
  *
@@ -106,7 +116,7 @@ __printf_2_3 void __log(int ll, const char* fmt,...)
        time_t t1;
        char str[255] = "";
 
-       if (ll < 2)
+       if (ll < loglevel)
                return;
        outfd = stderr;
        time(&t1);