diff options
Diffstat (limited to 'log.c')
-rw-r--r-- | log.c | 35 |
1 files changed, 19 insertions, 16 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: log.c,v 1.49 2017/03/10 03:15:58 djm Exp $ */ | 1 | /* $OpenBSD: log.c,v 1.50 2017/05/17 01:24:17 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -257,18 +257,7 @@ log_init(char *av0, LogLevel level, SyslogFacility facility, int on_stderr) | |||
257 | 257 | ||
258 | argv0 = av0; | 258 | argv0 = av0; |
259 | 259 | ||
260 | switch (level) { | 260 | if (log_change_level(level) != 0) { |
261 | case SYSLOG_LEVEL_QUIET: | ||
262 | case SYSLOG_LEVEL_FATAL: | ||
263 | case SYSLOG_LEVEL_ERROR: | ||
264 | case SYSLOG_LEVEL_INFO: | ||
265 | case SYSLOG_LEVEL_VERBOSE: | ||
266 | case SYSLOG_LEVEL_DEBUG1: | ||
267 | case SYSLOG_LEVEL_DEBUG2: | ||
268 | case SYSLOG_LEVEL_DEBUG3: | ||
269 | log_level = level; | ||
270 | break; | ||
271 | default: | ||
272 | fprintf(stderr, "Unrecognized internal syslog level code %d\n", | 261 | fprintf(stderr, "Unrecognized internal syslog level code %d\n", |
273 | (int) level); | 262 | (int) level); |
274 | exit(1); | 263 | exit(1); |
@@ -341,13 +330,27 @@ log_init(char *av0, LogLevel level, SyslogFacility facility, int on_stderr) | |||
341 | #endif | 330 | #endif |
342 | } | 331 | } |
343 | 332 | ||
344 | void | 333 | int |
345 | log_change_level(LogLevel new_log_level) | 334 | log_change_level(LogLevel new_log_level) |
346 | { | 335 | { |
347 | /* no-op if log_init has not been called */ | 336 | /* no-op if log_init has not been called */ |
348 | if (argv0 == NULL) | 337 | if (argv0 == NULL) |
349 | return; | 338 | return 0; |
350 | log_init(argv0, new_log_level, log_facility, log_on_stderr); | 339 | |
340 | switch (new_log_level) { | ||
341 | case SYSLOG_LEVEL_QUIET: | ||
342 | case SYSLOG_LEVEL_FATAL: | ||
343 | case SYSLOG_LEVEL_ERROR: | ||
344 | case SYSLOG_LEVEL_INFO: | ||
345 | case SYSLOG_LEVEL_VERBOSE: | ||
346 | case SYSLOG_LEVEL_DEBUG1: | ||
347 | case SYSLOG_LEVEL_DEBUG2: | ||
348 | case SYSLOG_LEVEL_DEBUG3: | ||
349 | log_level = new_log_level; | ||
350 | return 0; | ||
351 | default: | ||
352 | return -1; | ||
353 | } | ||
351 | } | 354 | } |
352 | 355 | ||
353 | int | 356 | int |