If you are interested in HTTP communication, try this:
-'MIDORI_SOUP_DEBUG=2 _build/default/midori/midori'
+'MIDORI_DEBUG=soup:2 _build/default/midori/midori'
-Where '2' can be a level between 0 and 3.
+Where '2' can be a level between 1 and 3.
If you are interested in (non-) touchscreen behaviour, try this:
(__filter[4] != '-' && __filter[5] != '-')
#ifdef G_ENABLE_DEBUG
#define adblock_debug(dmsg, darg1, darg2) \
- do { if (debug == 1) g_debug (dmsg, darg1, darg2); } while (0)
+ do { if (midori_debug ("adblock:1")) g_debug (dmsg, darg1, darg2); } while (0)
#else
#define adblock_debug(dmsg, darg1, darg2) /* nothing */
#endif
static GHashTable* blockcssprivate = NULL;
static GHashTable* navigationwhitelist = NULL;
static GString* blockcss = NULL;
-#ifdef G_ENABLE_DEBUG
-static guint debug;
-#endif
static gboolean
adblock_parse_file (gchar* path);
}
#ifdef G_ENABLE_DEBUG
- if (debug == 2)
+ if (midori_debug ("adblock:2"))
g_test_timer_start ();
#endif
if (adblock_is_matched (req_uri, page_uri))
g_object_set_data (G_OBJECT (web_view), "blocked-uris", blocked_uris);
}
#ifdef G_ENABLE_DEBUG
- if (debug == 2)
+ if (midori_debug ("adblock:2"))
g_debug ("match: %f%s", g_test_timer_elapsed (), "seconds");
#endif
adblock_activate_cb (MidoriExtension* extension,
MidoriApp* app)
{
- #ifdef G_ENABLE_DEBUG
- const gchar* debug_mode;
- #endif
KatzeArray* browsers;
MidoriBrowser* browser;
- #ifdef G_ENABLE_DEBUG
- debug_mode = g_getenv ("MIDORI_ADBLOCK");
- if (debug_mode)
- {
- if (*debug_mode == '1')
- debug = 1;
- else if (*debug_mode == '2')
- debug = 2;
- else
- debug = 0;
- }
- #endif
-
adblock_reload_rules (extension, FALSE);
browsers = katze_object_get_object (app, "browsers");
}
}
- if (g_getenv ("MIDORI_COOKIES_DEBUG") != NULL)
+ if (!g_strcmp0 (g_getenv ("MIDORI_DEBUG"), "cookies"))
http_cookies->counter++;
if (old_cookie) {
goto failed;
g_free (temporary_filename);
- if (g_getenv ("MIDORI_COOKIES_DEBUG") != NULL)
+ if (!g_strcmp0 (g_getenv ("MIDORI_DEBUG"), "cookies"))
{
g_print ("KatzeHttpCookies: %d cookies changed\n", http_cookies->counter);
http_cookies->counter = 0;
fclose (f);
g_unlink (temporary_filename);
g_free (temporary_filename);
- if (g_getenv ("MIDORI_COOKIES_DEBUG") != NULL)
+ if (!g_strcmp0 (g_getenv ("MIDORI_DEBUG"), "cookies"))
g_print ("KatzeHttpCookies: Failed to write '%s'\n",
http_cookies->filename);
return FALSE;
}
}
- if (g_getenv ("MIDORI_COOKIES_DEBUG") != NULL)
+ if (!g_strcmp0 (g_getenv ("MIDORI_DEBUG"), "cookies"))
http_cookies->counter++;
if (!http_cookies->timeout && (old_cookie || new_cookie->expires))
soup_uri_set_query (stripped_uri, NULL);
stripped_referer = soup_uri_to_string (stripped_uri, FALSE);
soup_uri_free (stripped_uri);
- if (g_getenv ("MIDORI_SOUP_DEBUG"))
+ if (midori_debug ("soup"))
g_message ("Referer %s stripped to %s", referer, stripped_referer);
soup_message_headers_replace (msg->request_headers, "Referer",
stripped_referer);
static void
midori_soup_session_debug (SoupSession* session)
{
- const char* soup_debug = g_getenv ("MIDORI_SOUP_DEBUG");
-
- if (soup_debug)
+ gint soup_debug_level = 0;
+ if (midori_debug ("soup:1"))
+ soup_debug_level = 1;
+ else if (midori_debug ("soup:2"))
+ soup_debug_level = 2;
+ else if (midori_debug ("soup:3"))
+ soup_debug_level = 3;
+ if (soup_debug_level > 0)
{
- gint soup_debug_level = atoi (soup_debug);
SoupLogger* logger = soup_logger_new (soup_debug_level, -1);
soup_logger_attach (logger, session);
g_object_unref (logger);
gchar** keys = g_object_get_data (G_OBJECT (app), "extensions");
KatzeArray* extensions;
#ifdef G_ENABLE_DEBUG
- gboolean startup_timer = g_getenv ("MIDORI_STARTTIME") != NULL;
+ gboolean startup_timer = midori_debug ("startup");
GTimer* timer = startup_timer ? g_timer_new () : NULL;
#endif
gint64 current;
gchar** command = g_object_get_data (G_OBJECT (app), "execute-command");
#ifdef G_ENABLE_DEBUG
- gboolean startup_timer = g_getenv ("MIDORI_STARTTIME") != NULL;
+ gboolean startup_timer = midori_debug ("startup");
GTimer* timer = startup_timer ? g_timer_new () : NULL;
#endif
gint max_history_age;
gint clear_prefs = MIDORI_CLEAR_NONE;
#ifdef G_ENABLE_DEBUG
- gboolean startup_timer = g_getenv ("MIDORI_STARTTIME") != NULL;
+ gboolean startup_timer = midori_debug ("startup");
#define midori_startup_timer(tmrmsg) if (startup_timer) \
g_debug (tmrmsg, (g_test_timer_last () - g_test_timer_elapsed ()) * -1)
#else
#endif
}
+gboolean
+midori_debug (const gchar* token)
+{
+ static const gchar* debug_token = NULL;
+ g_return_val_if_fail (token != NULL, FALSE);
+ if (debug_token == NULL)
+ {
+ const gchar* debug = g_getenv ("MIDORI_DEBUG");
+ const gchar* debug_tokens = "soup:1 soup:2 soup:3 cookies";
+ const gchar* full_debug_tokens = "adblock:1 adblock:2 startup bookmarks";
+ if (debug && strstr (full_debug_tokens, debug))
+ {
+ #ifdef G_ENABLE_DEBUG
+ debug_token = g_intern_static_string (debug);
+ #else
+ g_warning ("Value '%s' for MIDORI_DEBUG requires a full debugging build.", debug);
+ #endif
+ }
+ else if (debug && strstr (debug_tokens, debug))
+ debug_token = g_intern_static_string (debug);
+ else if (debug)
+ g_warning ("Unrecognized value '%s' for MIDORI_DEBUG.", debug);
+ else
+ debug_token = "NONE";
+ if (!debug_token)
+ {
+ debug_token = "INVALID";
+ g_print ("Supported values: %s\nWith full debugging: %s\n",
+ debug_tokens, full_debug_tokens);
+ }
+ }
+ return debug_token == g_intern_static_string (token);
+}
+
gchar*
midori_app_get_lib_path (const gchar* package);
+gboolean
+midori_debug (const gchar* token);
+
G_END_DECLS
#endif /* __MIDORI_APP_H__ */
}
#ifdef G_ENABLE_DEBUG
- if (g_getenv ("MIDORI_BOOKMARKS_DEBUG"))
+ if (midori_debug ("bookmarks")
sqlite3_trace (db, midori_bookmarks_dbtracer, NULL);
#endif
#ifdef G_ENABLE_DEBUG
GTimer* timer = NULL;
- if (g_getenv ("MIDORI_STARTTIME") != NULL)
+ if (midori_debug ("startup")
timer = g_timer_new ();
#endif
speeddial_markup ? speeddial_markup : "", "about:blank", NULL);
#ifdef G_ENABLE_DEBUG
- if (g_getenv ("MIDORI_STARTTIME") != NULL)
+ if (midori_debug ("startup")
{
g_debug ("Speed Dial: \t%fs", g_timer_elapsed (timer, NULL));
g_timer_destroy (timer);