From 25e22eb1f5046fdf9ef1d470b86faf640375de08 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Wed, 30 May 2007 22:27:58 +0000 Subject: Add a -v option to enable debug logging. Pass -v by default to the RO runimage. svn path=/trunk/netsurf/; revision=3306 --- !NetSurf/!Run,feb | 4 ++-- content/fetch.c | 6 +++++- desktop/netsurf.c | 10 ++++++++++ desktop/netsurf.h | 1 + utils/log.h | 7 ++++--- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/!NetSurf/!Run,feb b/!NetSurf/!Run,feb index 1629c42a2..7828c21fc 100644 --- a/!NetSurf/!Run,feb +++ b/!NetSurf/!Run,feb @@ -100,7 +100,7 @@ CDir .WWW.NetSurf FontInstall NetSurf:Resources.Fonts. WimpSlot -min 2240k -max 2240k -Run .!RunImage %*0 2>.WWW.NetSurf.Log +Run .!RunImage -v %*0 2>.WWW.NetSurf.Log | Uninstall NetSurf-specific fonts -FontRemove NetSurf:Resources.Fonts. \ No newline at end of file +FontRemove NetSurf:Resources.Fonts. diff --git a/content/fetch.c b/content/fetch.c index 2620f80b5..ed2c63670 100644 --- a/content/fetch.c +++ b/content/fetch.c @@ -248,7 +248,11 @@ void fetch_init(void) if (code != CURLE_OK) \ goto curl_easy_setopt_failed; - SETOPT(CURLOPT_VERBOSE, 1); + if (verbose_log) { + SETOPT(CURLOPT_VERBOSE, 1); + } else { + SETOPT(CURLOPT_VERBOSE, 0); + } SETOPT(CURLOPT_ERRORBUFFER, fetch_error_buffer); SETOPT(CURLOPT_WRITEFUNCTION, fetch_curl_data); SETOPT(CURLOPT_HEADERFUNCTION, fetch_curl_header); diff --git a/desktop/netsurf.c b/desktop/netsurf.c index 943ab4fcb..89d57341b 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -31,6 +31,7 @@ #include "netsurf/utils/utils.h" bool netsurf_quit = false; +bool verbose_log = false; static void netsurf_init(int argc, char** argv); static void netsurf_poll(void); @@ -66,6 +67,15 @@ void netsurf_init(int argc, char** argv) stdout = stderr; + if ((argc > 1) && (argv[1][0] == '-') && (argv[1][1] == 'v') && (argv[1][2] == 0)) { + int argcmv; + verbose_log = true; + for (argcmv = 2; argcmv < argc; argcmv++) { + argv[argcmv - 1] = argv[argcmv]; + } + argc--; + } + #ifdef _MEMDEBUG_H_ memdebug_memdebug("memdump"); #endif diff --git a/desktop/netsurf.h b/desktop/netsurf.h index a1865a604..cbffc9ccf 100644 --- a/desktop/netsurf.h +++ b/desktop/netsurf.h @@ -11,6 +11,7 @@ #include extern bool netsurf_quit; +extern bool verbose_log; extern const char * const netsurf_version; extern const int netsurf_version_major; extern const int netsurf_version_minor; diff --git a/utils/log.h b/utils/log.h index 6ad17bb0d..86a933a40 100644 --- a/utils/log.h +++ b/utils/log.h @@ -7,6 +7,7 @@ */ #include +#include "netsurf/desktop/netsurf.h" #ifndef _NETSURF_LOG_H_ #define _NETSURF_LOG_H_ @@ -15,11 +16,11 @@ # define LOG(x) ((void) 0) #else # ifdef __GNUC__ -# define LOG(x) (printf(__FILE__ " %s %i: ", __PRETTY_FUNCTION__, __LINE__), printf x, fputc('\n', stdout)) +# define LOG(x) do { if (verbose_log) (printf(__FILE__ " %s %i: ", __PRETTY_FUNCTION__, __LINE__), printf x, fputc('\n', stdout)); } while (0) # elif defined(__CC_NORCROFT) -# define LOG(x) (printf(__FILE__ " %s %i: ", __func__, __LINE__), printf x, fputc('\n', stdout)) +# define LOG(x) do { if (verbose_log) (printf(__FILE__ " %s %i: ", __func__, __LINE__), printf x, fputc('\n', stdout)); } while (0) # else -# define LOG(x) (printf(__FILE__ " %i: ", __LINE__), printf x, fputc('\n', stdout)) +# define LOG(x) do { if (verbose_log) (printf(__FILE__ " %i: ", __LINE__), printf x, fputc('\n', stdout)); } while (0) # endif #endif -- cgit v1.2.3