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. --- beos/gui.cpp | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'beos/gui.cpp') diff --git a/beos/gui.cpp b/beos/gui.cpp index b2f40431d..091346605 100644 --- a/beos/gui.cpp +++ b/beos/gui.cpp @@ -398,11 +398,20 @@ static void gui_init2(int argc, char** argv) } } +/** + * 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) { - setbuf(stderr, NULL); - BPath options; if (find_directory(B_USER_SETTINGS_DIRECTORY, &options, true) == B_OK) { options.Append("x-vnd.NetSurf"); @@ -416,11 +425,16 @@ int main(int argc, char** argv) const char* messages = "/boot/apps/netsurf/res/en/Messages"; + /* initialise logging. Not fatal if it fails but not much we + * can do about it either. + */ + nslog_init(nslog_stream_configure, &argc, argv); + /* initialise netsurf */ netsurf_init(&argc, &argv, options.Path(), messages); - gui_init(argc, argv); - gui_init2(argc, argv); + gui_init(argc, argv); + gui_init2(argc, argv); netsurf_main_loop(); @@ -432,8 +446,6 @@ int main(int argc, char** argv) /** called when replicated from NSBaseView::Instantiate() */ int gui_init_replicant(int argc, char** argv) { - setbuf(stderr, NULL); - BPath options; if (find_directory(B_USER_SETTINGS_DIRECTORY, &options, true) == B_OK) { options.Append("x-vnd.NetSurf"); @@ -441,6 +453,11 @@ int gui_init_replicant(int argc, char** argv) const char* messages = "/boot/apps/netsurf/res/en/Messages"; + /* initialise logging. Not fatal if it fails but not much we + * can do about it either. + */ + nslog_init(nslog_stream_configure, &argc, argv); + /* initialise netsurf */ netsurf_init(&argc, &argv, options.Path(), messages); -- cgit v1.2.3