From: Andre Noll Date: Sat, 31 May 2008 17:48:32 +0000 (+0200) Subject: Fix loglevel handling. X-Git-Tag: v0.1.0~92 X-Git-Url: http://git.tuebingen.mpg.de/?p=osl.git;a=commitdiff_plain;h=2d808508e1fd5bf142a44f2675ecfdd2ad6d8cc9;ds=sidebyside Fix loglevel handling. Use the content of the enviroment variable OSL_LOGLEVEL. --- diff --git a/osl.c b/osl.c index 81b035d..cc0e641 100644 --- 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);