summaryrefslogtreecommitdiff
path: root/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'log.c')
-rw-r--r--log.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/log.c b/log.c
index d0f86cf6f..99450dd12 100644
--- a/log.c
+++ b/log.c
@@ -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
@@ -256,18 +256,7 @@ log_init(char *av0, LogLevel level, SyslogFacility facility, int on_stderr)
256 256
257 argv0 = av0; 257 argv0 = av0;
258 258
259 switch (level) { 259 if (log_change_level(level) != 0) {
260 case SYSLOG_LEVEL_QUIET:
261 case SYSLOG_LEVEL_FATAL:
262 case SYSLOG_LEVEL_ERROR:
263 case SYSLOG_LEVEL_INFO:
264 case SYSLOG_LEVEL_VERBOSE:
265 case SYSLOG_LEVEL_DEBUG1:
266 case SYSLOG_LEVEL_DEBUG2:
267 case SYSLOG_LEVEL_DEBUG3:
268 log_level = level;
269 break;
270 default:
271 fprintf(stderr, "Unrecognized internal syslog level code %d\n", 260 fprintf(stderr, "Unrecognized internal syslog level code %d\n",
272 (int) level); 261 (int) level);
273 exit(1); 262 exit(1);
@@ -340,13 +329,27 @@ log_init(char *av0, LogLevel level, SyslogFacility facility, int on_stderr)
340#endif 329#endif
341} 330}
342 331
343void 332int
344log_change_level(LogLevel new_log_level) 333log_change_level(LogLevel new_log_level)
345{ 334{
346 /* no-op if log_init has not been called */ 335 /* no-op if log_init has not been called */
347 if (argv0 == NULL) 336 if (argv0 == NULL)
348 return; 337 return 0;
349 log_init(argv0, new_log_level, log_facility, log_on_stderr); 338
339 switch (new_log_level) {
340 case SYSLOG_LEVEL_QUIET:
341 case SYSLOG_LEVEL_FATAL:
342 case SYSLOG_LEVEL_ERROR:
343 case SYSLOG_LEVEL_INFO:
344 case SYSLOG_LEVEL_VERBOSE:
345 case SYSLOG_LEVEL_DEBUG1:
346 case SYSLOG_LEVEL_DEBUG2:
347 case SYSLOG_LEVEL_DEBUG3:
348 log_level = new_log_level;
349 return 0;
350 default:
351 return -1;
352 }
350} 353}
351 354
352int 355int