From 35dacc36716bdac66bc2673a6725083dc265d310 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 23 May 2013 11:50:57 +0100 Subject: move the logging initialisation out to be call by frontends This allows each frontend to pass a distinct callback to configure the output file stream appropriately for their use. --- utils/log.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'utils/log.c') diff --git a/utils/log.c b/utils/log.c index 96a6d3c5b..2aa39ee41 100644 --- a/utils/log.c +++ b/utils/log.c @@ -31,9 +31,9 @@ nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv) { nserror ret = NSERROR_OK; - if (((*pargc) > 1) && - (argv[1][0] == '-') && - (argv[1][1] == 'v') && + if (((*pargc) > 1) && + (argv[1][0] == '-') && + (argv[1][1] == 'v') && (argv[1][2] == 0)) { int argcmv; for (argcmv = 2; argcmv < (*pargc); argcmv++) { @@ -43,15 +43,17 @@ nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv) /* ensure we actually show logging */ verbose_log = true; - - /* ensure stderr is available */ - if (ensure != NULL) { - if (ensure(stderr) == false) { - /* failed to ensure output */ - ret = NSERROR_INIT_FAILED; - } - } } + + /* ensure output file handle is correctly configured */ + if ((verbose_log == true) && + (ensure != NULL) && + (ensure(stderr) == false)) { + /* failed to ensure output configuration */ + ret = NSERROR_INIT_FAILED; + verbose_log = false; + } + return ret; } -- cgit v1.2.3