diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-01 20:31:07 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-01 20:31:07 +0000 |
commit | 87f795e4d28eee0ae57f9d916ef12141937e4b4a (patch) | |
tree | 0e268900f2e65c87cd41b6c286715a7f2fb5e615 /src/util | |
parent | 7824120f64433bee7048d983a7d5fc2ff91d1d14 (diff) | |
download | gnunet-87f795e4d28eee0ae57f9d916ef12141937e4b4a.tar.gz gnunet-87f795e4d28eee0ae57f9d916ef12141937e4b4a.zip |
LRN: Allow env vars to adjust and override loglevel
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/common_logging.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/util/common_logging.c b/src/util/common_logging.c index a80321c83..463936741 100644 --- a/src/util/common_logging.c +++ b/src/util/common_logging.c | |||
@@ -179,6 +179,9 @@ GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile) | |||
179 | FILE *altlog; | 179 | FILE *altlog; |
180 | int dirwarn; | 180 | int dirwarn; |
181 | char *fn; | 181 | char *fn; |
182 | const char *env_loglevel; | ||
183 | int env_minlevel = 0; | ||
184 | int env_min_force_level = 100000; | ||
182 | 185 | ||
183 | #ifdef WINDOWS | 186 | #ifdef WINDOWS |
184 | QueryPerformanceFrequency (&performance_frequency); | 187 | QueryPerformanceFrequency (&performance_frequency); |
@@ -188,7 +191,17 @@ GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile) | |||
188 | "%s-%d", | 191 | "%s-%d", |
189 | comp, | 192 | comp, |
190 | getpid()); | 193 | getpid()); |
194 | env_loglevel = getenv ("GNUNET_LOGLEVEL"); | ||
195 | if (env_loglevel != NULL) | ||
196 | env_minlevel = get_type (env_loglevel); | ||
197 | env_loglevel = getenv ("GNUNET_FORCE_LOGLEVEL"); | ||
198 | if (env_loglevel != NULL) | ||
199 | env_min_force_level = get_type (env_loglevel); | ||
191 | min_level = get_type (loglevel); | 200 | min_level = get_type (loglevel); |
201 | if (env_minlevel > min_level) | ||
202 | min_level = env_minlevel; | ||
203 | if (env_min_force_level < min_level) | ||
204 | min_level = env_min_force_level; | ||
192 | if (logfile == NULL) | 205 | if (logfile == NULL) |
193 | return GNUNET_OK; | 206 | return GNUNET_OK; |
194 | fn = GNUNET_STRINGS_filename_expand (logfile); | 207 | fn = GNUNET_STRINGS_filename_expand (logfile); |