From 2d808508e1fd5bf142a44f2675ecfdd2ad6d8cc9 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 31 May 2008 19:48:32 +0200 Subject: [PATCH] Fix loglevel handling. Use the content of the enviroment variable OSL_LOGLEVEL. --- osl.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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); -- 2.39.5