From 75018632a9b953aafeae6f4e8aea607fd1d89dca Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 6 Sep 2017 18:28:12 +0100 Subject: Use coccinelle to change logging macro calls in c files for F in $(git ls-files '*.c');do spatch --sp-file foo.cocci --in-place ${F};done @@ expression E; @@ -LOG(E); +NSLOG(netsurf, INFO, E); @@ expression E, E1; @@ -LOG(E, E1); +NSLOG(netsurf, INFO, E, E1); @@ expression E, E1, E2; @@ -LOG(E, E1, E2); +NSLOG(netsurf, INFO, E, E1, E2); @@ expression E, E1, E2, E3; @@ -LOG(E, E1, E2, E3); +NSLOG(netsurf, INFO, E, E1, E2, E3); @@ expression E, E1, E2, E3, E4; @@ -LOG(E, E1, E2, E3, E4); +NSLOG(netsurf, INFO, E, E1, E2, E3, E4); @@ expression E, E1, E2, E3, E4, E5; @@ -LOG(E, E1, E2, E3, E4, E5); +NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5); @@ expression E, E1, E2, E3, E4, E5, E6; @@ -LOG(E, E1, E2, E3, E4, E5, E6); +NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6); @@ expression E, E1, E2, E3, E4, E5, E6, E7; @@ -LOG(E, E1, E2, E3, E4, E5, E6, E7); +NSLOG(netsurf, INFO, E, E1, E2, E3, E4, E5, E6, E7); --- frontends/framebuffer/gui.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'frontends/framebuffer/gui.c') diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c index 1460c77f6..ebd0b7b66 100644 --- a/frontends/framebuffer/gui.c +++ b/frontends/framebuffer/gui.c @@ -120,7 +120,7 @@ static void die(const char *error) */ static nserror fb_warn_user(const char *warning, const char *detail) { - LOG("%s %s", warning, detail); + NSLOG(netsurf, INFO, "%s %s", warning, detail); return NSERROR_OK; } @@ -153,7 +153,7 @@ widget_scroll_y(struct gui_window *gw, int y, bool abs) int content_width, content_height; int height; - LOG("window scroll"); + NSLOG(netsurf, INFO, "window scroll"); if (abs) { bwidget->pany = y - bwidget->scrolly; } else { @@ -237,7 +237,7 @@ fb_pan(fbtk_widget_t *widget, height = fbtk_get_height(widget); width = fbtk_get_width(widget); - LOG("panning %d, %d", bwidget->panx, bwidget->pany); + NSLOG(netsurf, INFO, "panning %d, %d", bwidget->panx, bwidget->pany); x = fbtk_get_absx(widget); y = fbtk_get_absy(widget); @@ -413,7 +413,8 @@ fb_browser_window_redraw(fbtk_widget_t *widget, fbtk_callback_info *cbi) bwidget = fbtk_get_userpw(widget); if (bwidget == NULL) { - LOG("browser widget from widget %p was null", widget); + NSLOG(netsurf, INFO, + "browser widget from widget %p was null", widget); return -1; } @@ -465,7 +466,7 @@ process_cmdline(int argc, char** argv) {0, 0, 0, 0 } }; /* no long options */ - LOG("argc %d, argv %p", argc, argv); + NSLOG(netsurf, INFO, "argc %d, argv %p", argc, argv); fename = "sdl"; febpp = 32; @@ -534,7 +535,7 @@ static nserror set_defaults(struct nsoption_s *defaults) if (nsoption_charp(cookie_file) == NULL || nsoption_charp(cookie_jar) == NULL) { - LOG("Failed initialising cookie options"); + NSLOG(netsurf, INFO, "Failed initialising cookie options"); return NSERROR_BAD_PARAMETER; } @@ -612,7 +613,7 @@ static void framebuffer_run(void) static void gui_quit(void) { - LOG("gui_quit"); + NSLOG(netsurf, INFO, "gui_quit"); urldb_save_cookies(nsoption_charp(cookie_jar)); @@ -639,7 +640,8 @@ fb_browser_window_click(fbtk_widget_t *widget, fbtk_callback_info *cbi) cbi->event->type != NSFB_EVENT_KEY_UP) return 0; - LOG("browser window clicked at %d,%d", cbi->x, cbi->y); + NSLOG(netsurf, INFO, "browser window clicked at %d,%d", cbi->x, + cbi->y); switch (cbi->event->type) { case NSFB_EVENT_KEY_DOWN: @@ -824,7 +826,7 @@ fb_browser_window_input(fbtk_widget_t *widget, fbtk_callback_info *cbi) static fbtk_modifier_type modifier = FBTK_MOD_CLEAR; int ucs4 = -1; - LOG("got value %d", cbi->event->value.keycode); + NSLOG(netsurf, INFO, "got value %d", cbi->event->value.keycode); switch (cbi->event->type) { case NSFB_EVENT_KEY_DOWN: @@ -1200,7 +1202,7 @@ create_toolbar(struct gui_window *gw, toolbar_layout = NSFB_TOOLBAR_DEFAULT_LAYOUT; } - LOG("Using toolbar layout %s", toolbar_layout); + NSLOG(netsurf, INFO, "Using toolbar layout %s", toolbar_layout); itmtype = toolbar_layout; @@ -1234,7 +1236,7 @@ create_toolbar(struct gui_window *gw, (*itmtype != 0) && (xdir !=0)) { - LOG("toolbar adding %c", *itmtype); + NSLOG(netsurf, INFO, "toolbar adding %c", *itmtype); switch (*itmtype) { @@ -1376,7 +1378,9 @@ create_toolbar(struct gui_window *gw, default: widget = NULL; xdir = 0; - LOG("Unknown element %c in toolbar layout", *itmtype); + NSLOG(netsurf, INFO, + "Unknown element %c in toolbar layout", + *itmtype); break; } @@ -1385,7 +1389,7 @@ create_toolbar(struct gui_window *gw, xpos += (xdir * (fbtk_get_width(widget) + padding)); } - LOG("xpos is %d", xpos); + NSLOG(netsurf, INFO, "xpos is %d", xpos); itmtype += xdir; } @@ -1595,7 +1599,7 @@ create_normal_browser_window(struct gui_window *gw, int furniture_width) int statusbar_width = 0; int toolbar_height = nsoption_int(fb_toolbar_size); - LOG("Normal window"); + NSLOG(netsurf, INFO, "Normal window"); gw->window = fbtk_create_window(fbtk, 0, 0, 0, 0, 0); @@ -1626,7 +1630,8 @@ create_normal_browser_window(struct gui_window *gw, int furniture_width) false); fbtk_set_handler(gw->status, FBTK_CBT_POINTERENTER, set_ptr_default_move, NULL); - LOG("status bar %p at %d,%d", gw->status, fbtk_get_absx(gw->status), fbtk_get_absy(gw->status)); + NSLOG(netsurf, INFO, "status bar %p at %d,%d", gw->status, + fbtk_get_absx(gw->status), fbtk_get_absy(gw->status)); /* create horizontal scrollbar */ gw->hscroll = fbtk_create_hscroll(gw->window, @@ -2183,7 +2188,7 @@ main(int argc, char** argv) /* create an initial browser window */ - LOG("calling browser_window_create"); + NSLOG(netsurf, INFO, "calling browser_window_create"); ret = nsurl_create(feurl, &url); if (ret == NSERROR_OK) { @@ -2205,7 +2210,7 @@ main(int argc, char** argv) netsurf_exit(); if (fb_font_finalise() == false) - LOG("Font finalisation failed."); + NSLOG(netsurf, INFO, "Font finalisation failed."); /* finalise options */ nsoption_finalise(nsoptions, nsoptions_default); -- cgit v1.2.3 From 8123e65351788fa633962c4f5e1bb41f1ef346e2 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sun, 10 Sep 2017 14:22:05 +0100 Subject: Finalise nslog layer properly in closedown --- frontends/amiga/gui.c | 3 +++ frontends/atari/gui.c | 4 ++++ frontends/beos/gui.cpp | 6 ++++++ frontends/framebuffer/gui.c | 3 +++ frontends/gtk/gui.c | 3 +++ frontends/monkey/main.c | 3 +++ frontends/riscos/gui.c | 3 +++ frontends/windows/main.c | 3 +++ utils/log.c | 18 +++++++++++++++++- utils/log.h | 9 +++++++++ 10 files changed, 54 insertions(+), 1 deletion(-) (limited to 'frontends/framebuffer/gui.c') diff --git a/frontends/amiga/gui.c b/frontends/amiga/gui.c index e4acf70c2..fbaa2acfb 100644 --- a/frontends/amiga/gui.c +++ b/frontends/amiga/gui.c @@ -5841,6 +5841,9 @@ int main(int argc, char** argv) free(current_user_dir); FreeVec(current_user_faviconcache); + /* finalise logging */ + nslog_finalise(); + #ifndef __amigaos4__ /* OS3 low memory handler */ ami_memory_fini(memhandler); diff --git a/frontends/atari/gui.c b/frontends/atari/gui.c index a400285d3..6ee63b301 100644 --- a/frontends/atari/gui.c +++ b/frontends/atari/gui.c @@ -1225,6 +1225,10 @@ int main(int argc, char** argv) fclose(stderr); #endif NSLOG(netsurf, INFO, "exit_gem"); + + /* finalise logging */ + nslog_finalise(); + exit_gem(); return 0; diff --git a/frontends/beos/gui.cpp b/frontends/beos/gui.cpp index 69a0d6dde..19f8eac49 100644 --- a/frontends/beos/gui.cpp +++ b/frontends/beos/gui.cpp @@ -1066,6 +1066,12 @@ int main(int argc, char** argv) netsurf_exit(); + /* finalise options */ + nsoption_finalise(nsoptions, nsoptions_default); + + /* finalise logging */ + nslog_finalise(); + return 0; } diff --git a/frontends/framebuffer/gui.c b/frontends/framebuffer/gui.c index ebd0b7b66..e252f25f3 100644 --- a/frontends/framebuffer/gui.c +++ b/frontends/framebuffer/gui.c @@ -2215,6 +2215,9 @@ main(int argc, char** argv) /* finalise options */ nsoption_finalise(nsoptions, nsoptions_default); + /* finalise logging */ + nslog_finalise(); + return 0; } diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c index 6a61b3d06..8c9ad088d 100644 --- a/frontends/gtk/gui.c +++ b/frontends/gtk/gui.c @@ -1198,5 +1198,8 @@ int main(int argc, char** argv) /* finalise options */ nsoption_finalise(nsoptions, nsoptions_default); + /* finalise logging */ + nslog_finalise(); + return 0; } diff --git a/frontends/monkey/main.c b/frontends/monkey/main.c index d697f271f..53cde5a72 100644 --- a/frontends/monkey/main.c +++ b/frontends/monkey/main.c @@ -404,5 +404,8 @@ main(int argc, char **argv) /* finalise options */ nsoption_finalise(nsoptions, nsoptions_default); + /* finalise logging */ + nslog_finalise(); + return 0; } diff --git a/frontends/riscos/gui.c b/frontends/riscos/gui.c index 9d651bc10..cfc513f72 100644 --- a/frontends/riscos/gui.c +++ b/frontends/riscos/gui.c @@ -2557,5 +2557,8 @@ int main(int argc, char** argv) netsurf_exit(); nsoption_finalise(nsoptions, nsoptions_default); + /* finalise logging */ + nslog_finalise(); + return 0; } diff --git a/frontends/windows/main.c b/frontends/windows/main.c index 98e90be80..a3a7c2b39 100644 --- a/frontends/windows/main.c +++ b/frontends/windows/main.c @@ -419,5 +419,8 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd) /* finalise options */ nsoption_finalise(nsoptions, nsoptions_default); + /* finalise logging */ + nslog_finalise(); + return 0; } diff --git a/utils/log.c b/utils/log.c index 68a470aa9..e267b3179 100644 --- a/utils/log.c +++ b/utils/log.c @@ -137,8 +137,8 @@ nslog_set_filter(const char *filter) } err = nslog_filter_set_active(filt, NULL); + filt = nslog_filter_unref(filt); if (err != NSLOG_NO_ERROR) { - nslog_filter_unref(filt); return NSERROR_NOSPACE; } @@ -287,3 +287,19 @@ nslog_set_filter_by_options() else return nslog_set_filter(nsoption_charp(log_filter)); } + +/* exported interface documented in utils/log.h */ +void +nslog_finalise() +{ + NSLOG(netsurf, INFO, + "Finalising logging, please report any further messages"); + verbose_log = true; + if (logfile != stderr) { + fclose(logfile); + logfile = stderr; + } +#ifdef WITH_NSLOG + nslog_cleanup(); +#endif +} diff --git a/utils/log.h b/utils/log.h index a94afc130..b773ec4a2 100644 --- a/utils/log.h +++ b/utils/log.h @@ -43,6 +43,15 @@ typedef bool(nslog_ensure_t)(FILE *fptr); */ extern nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv); +/** + * Shut down the logging system. + * + * Shuts down the logging subsystem, resetting to verbose logging and output + * to stderr. Note, if logging is done after calling this, it will be sent + * to stderr without filtering. + */ +extern void nslog_finalise(void); + /** * Set the logging filter. * -- cgit v1.2.3