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. --- riscos/gui.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'riscos') diff --git a/riscos/gui.c b/riscos/gui.c index 53f281dd8..bca2a701a 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -799,6 +799,17 @@ static void gui_init2(int argc, char** argv) free(url); } +/** + * Ensures output logging stream is correctly configured + */ +static bool nslog_stream_configure(FILE *fptr) +{ + /* set log stream to be non-buffering */ + setbuf(fptr, NULL); + + return true; +} + /** Normal entry point from OS */ int main(int argc, char** argv) { @@ -809,8 +820,6 @@ int main(int argc, char** argv) int used = -1; /* slightly better with older OSLib versions */ os_error *error; - setbuf(stderr, NULL); - /* Consult NetSurf$Logging environment variable to decide if logging * is required. */ error = xos_read_var_val_size("NetSurf$Logging", 0, os_VARTYPE_STRING, @@ -828,6 +837,11 @@ int main(int argc, char** argv) } } + /* initialise logging. Not fatal if it fails but not much we + * can do about it either. + */ + nslog_init(nslog_stream_configure, &argc, argv); + /* Pass a NULL pointer for Messages path, because until the Choices * are loaded in netsurf_init, we don't know the Messages path. */ netsurf_init(&argc, &argv, "NetSurf:Choices", NULL); -- cgit v1.2.3