Verified Commit cef01380 authored by James Westman's avatar James Westman
Browse files

Remove DEBUG macro

Just use g_debug instead
parent 1eaba7f8
Pipeline #273369 passed with stage
in 1 minute and 25 seconds
......@@ -8,7 +8,6 @@ gtk_prefix = gtk_dep.get_pkgconfig_variable('prefix')
gtk_docpath = join_paths(gtk_prefix, 'share', 'gtk-doc', 'html', 'gtk4')
libshumate_reference_ignored_h = [
'shumate-debug.h',
'shumate-enum-types.h',
'shumate-marshal.h',
'shumate.h',
......
......@@ -23,14 +23,12 @@ libshumate_public_h = [
]
libshumate_private_h = [
'shumate-debug.h',
'shumate-kinetic-scrolling-private.h',
'shumate-marker-private.h',
]
libshumate_sources = [
'shumate-coordinate.c',
'shumate-debug.c',
'shumate-file-cache.c',
'shumate-kinetic-scrolling.c',
'shumate-layer.c',
......
/*
* Copyright (C) 2007 Collabora Ltd.
* Copyright (C) 2007 Nokia Corporation
* Copyright (C) 2008-2009 Pierre-Luc Beaudoin <pierre-luc@pierlux.com>
* Copyright (C) 2019 Marcus Lundblad <ml@update.uu.se>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include "shumate-debug.h"
#include <errno.h>
#include <fcntl.h>
#include <glib.h>
#include <glib/gstdio.h>
#include <stdarg.h>
#include <sys/stat.h>
#include <unistd.h>
#ifdef ENABLE_DEBUG
static ShumateDebugFlags flags = 0;
static GDebugKey keys[] = {
{ "Loading", SHUMATE_DEBUG_LOADING },
{ "Engine", SHUMATE_DEBUG_ENGINE },
{ "View", SHUMATE_DEBUG_VIEW },
{ "Network", SHUMATE_DEBUG_NETWORK },
{ "Cache", SHUMATE_DEBUG_CACHE },
{ "Selection", SHUMATE_DEBUG_SELECTION },
{ "Other", SHUMATE_DEBUG_OTHER },
{ 0, }
};
static void
debug_set_flags (ShumateDebugFlags new_flags)
{
flags |= new_flags;
}
void
shumate_debug_set_flags (const char *flags_string)
{
guint nkeys;
for (nkeys = 0; keys[nkeys].value; nkeys++)
;
if (flags_string)
debug_set_flags (g_parse_debug_string (flags_string, keys, nkeys));
}
gboolean
shumate_debug_flag_is_set (ShumateDebugFlags flag)
{
return (flag & flags) != 0;
}
void
shumate_debug (ShumateDebugFlags flag,
const char *format,
...)
{
if (flag & flags)
{
va_list args;
va_start (args, format);
g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args);
va_end (args);
}
}
#else
gboolean
shumate_debug_flag_is_set (ShumateDebugFlags flag)
{
return FALSE;
}
void
shumate_debug (ShumateDebugFlags flag, const char *format, ...)
{
}
void
shumate_debug_set_flags (const char *flags_string)
{
}
#endif /* ENABLE_DEBUG */
/*
* Copyright (C) 2007 Collabora Ltd.
* Copyright (C) 2007 Nokia Corporation
* Copyright (C) 2008-2009 Pierre-Luc Beaudoin <pierre-luc@pierlux.com>
* Copyright (C) 2019 Marcus Lundblad <ml@update.uu.se>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __SHUMATE_DEBUG_H__
#define __SHUMATE_DEBUG_H__
#include "config.h"
#include <glib.h>
G_BEGIN_DECLS
/* Please keep this enum in sync with #keys in shumate-debug.c */
typedef enum
{
SHUMATE_DEBUG_LOADING = 1 << 1,
SHUMATE_DEBUG_ENGINE = 1 << 2,
SHUMATE_DEBUG_VIEW = 1 << 3,
SHUMATE_DEBUG_NETWORK = 1 << 4,
SHUMATE_DEBUG_CACHE = 1 << 5,
SHUMATE_DEBUG_SELECTION = 1 << 6,
SHUMATE_DEBUG_OTHER = 1 << 7,
} ShumateDebugFlags;
gboolean shumate_debug_flag_is_set (ShumateDebugFlags flag);
void shumate_debug (ShumateDebugFlags flag,
const char *format,
...) G_GNUC_PRINTF (2, 3);
void shumate_debug_set_flags (const char *flags_string);
G_END_DECLS
#endif /* __SHUMATE_DEBUG_H__ */
/* ------------------------------------ */
/* Below this point is outside the __DEBUG_H__ guard - so it can take effect
* more than once. So you can do:
*
* #define DEBUG_FLAG SHUMATE_DEBUG_ONE_THING
* #include "debug.h"
* ...
* DEBUG ("if we're debugging one thing");
* ...
* #undef DEBUG_FLAG
* #define DEBUG_FLAG SHUMATE_DEBUG_OTHER_THING
* #include "debug.h"
* ...
* DEBUG ("if we're debugging the other thing");
* ...
*/
#ifdef DEBUG_FLAG
#ifdef ENABLE_DEBUG
#undef DEBUG
#define DEBUG(format, ...) \
shumate_debug (DEBUG_FLAG, "%s: " format, G_STRFUNC, ## __VA_ARGS__)
#undef DEBUGGING
#define DEBUGGING shumate_debug_flag_is_set (DEBUG_FLAG)
#else /* !defined (ENABLE_DEBUG) */
#undef DEBUG
#define DEBUG(format, ...) do {} while (0)
#undef DEBUGGING
#define DEBUGGING 0
#endif /* !defined (ENABLE_DEBUG) */
#endif /* defined (DEBUG_FLAG) */
......@@ -37,9 +37,6 @@
* using the HTTP If-None-Match header).
*/
#define DEBUG_FLAG SHUMATE_DEBUG_CACHE
#include "shumate-debug.h"
#include "shumate-file-cache.h"
#include <sqlite3.h>
......@@ -156,7 +153,7 @@ finalize_sql (ShumateFileCache *file_cache)
{
int error = sqlite3_close (priv->db);
if (error != SQLITE_OK)
DEBUG ("Sqlite returned error %d when closing cache.db", error);
g_debug ("Sqlite returned error %d when closing cache.db", error);
priv->db = NULL;
}
}
......@@ -212,7 +209,7 @@ init_cache (ShumateFileCache *file_cache)
if (error == SQLITE_ERROR)
{
DEBUG ("Sqlite returned error %d when opening cache.db", error);
g_debug ("Sqlite returned error %d when opening cache.db", error);
return;
}
......@@ -222,7 +219,7 @@ init_cache (ShumateFileCache *file_cache)
NULL, NULL, &error_msg);
if (error_msg != NULL)
{
DEBUG ("Set PRAGMA: %s", error_msg);
g_debug ("Set PRAGMA: %s", error_msg);
sqlite3_free (error_msg);
return;
}
......@@ -236,7 +233,7 @@ init_cache (ShumateFileCache *file_cache)
NULL, NULL, &error_msg);
if (error_msg != NULL)
{
DEBUG ("Creating table 'tiles' failed: %s", error_msg);
g_debug ("Creating table 'tiles' failed: %s", error_msg);
sqlite3_free (error_msg);
return;
}
......@@ -247,7 +244,7 @@ init_cache (ShumateFileCache *file_cache)
if (error != SQLITE_OK)
{
priv->stmt_select = NULL;
DEBUG ("Failed to prepare the select Etag statement, error:%d: %s",
g_debug ("Failed to prepare the select Etag statement, error:%d: %s",
error, sqlite3_errmsg (priv->db));
return;
}
......@@ -258,7 +255,7 @@ init_cache (ShumateFileCache *file_cache)
if (error != SQLITE_OK)
{
priv->stmt_update = NULL;
DEBUG ("Failed to prepare the update popularity statement, error: %s",
g_debug ("Failed to prepare the update popularity statement, error: %s",
sqlite3_errmsg (priv->db));
return;
}
......@@ -498,7 +495,7 @@ db_get_etag (ShumateFileCache *self, ShumateTile *tile)
sql_rc = sqlite3_bind_text (priv->stmt_select, 1, filename, -1, SQLITE_STATIC);
if (sql_rc == SQLITE_ERROR)
{
DEBUG ("Failed to prepare the SQL query for finding the Etag of '%s', error: %s",
g_debug ("Failed to prepare the SQL query for finding the Etag of '%s', error: %s",
filename, sqlite3_errmsg (priv->db));
return NULL;
}
......@@ -511,12 +508,12 @@ db_get_etag (ShumateFileCache *self, ShumateTile *tile)
}
else if (sql_rc == SQLITE_DONE)
{
DEBUG ("'%s' doesn't have an etag",
g_debug ("'%s' doesn't have an etag",
filename);
}
else if (sql_rc == SQLITE_ERROR)
{
DEBUG ("Failed to finding the Etag of '%s', %d error: %s",
g_debug ("Failed to finding the Etag of '%s', %d error: %s",
filename, sql_rc, sqlite3_errmsg (priv->db));
}
......@@ -571,13 +568,13 @@ on_tile_filled (ShumateFileCache *self,
filename = get_filename (self, tile);
DEBUG ("popularity of %s", filename);
g_debug ("popularity of %s", filename);
sqlite3_reset (priv->stmt_update);
sql_rc = sqlite3_bind_text (priv->stmt_update, 1, filename, -1, SQLITE_STATIC);
if (sql_rc != SQLITE_OK)
{
DEBUG ("Failed to set values to the popularity query of '%s', error: %s",
g_debug ("Failed to set values to the popularity query of '%s', error: %s",
filename, sqlite3_errmsg (priv->db));
return;
}
......@@ -605,7 +602,7 @@ delete_tile (ShumateFileCache *file_cache, const char *filename)
sqlite3_exec (priv->db, query, NULL, NULL, &error);
if (error != NULL)
{
DEBUG ("Deleting tile from db failed: %s", error);
g_debug ("Deleting tile from db failed: %s", error);
sqlite3_free (error);
}
sqlite3_free (query);
......@@ -613,7 +610,7 @@ delete_tile (ShumateFileCache *file_cache, const char *filename)
file = g_file_new_for_path (filename);
if (!g_file_delete (file, NULL, &gerror))
{
DEBUG ("Deleting tile from disk failed: %s", gerror->message);
g_debug ("Deleting tile from disk failed: %s", gerror->message);
g_error_free (gerror);
}
g_object_unref (file);
......@@ -670,13 +667,13 @@ shumate_file_cache_purge (ShumateFileCache *file_cache)
rc = sqlite3_prepare (priv->db, query, strlen (query), &stmt, NULL);
if (rc != SQLITE_OK)
{
DEBUG ("Can't compute cache size %s", sqlite3_errmsg (priv->db));
g_debug ("Can't compute cache size %s", sqlite3_errmsg (priv->db));
}
rc = sqlite3_step (stmt);
if (rc != SQLITE_ROW)
{
DEBUG ("Failed to count the total cache consumption %s",
g_debug ("Failed to count the total cache consumption %s",
sqlite3_errmsg (priv->db));
sqlite3_finalize (stmt);
return;
......@@ -685,7 +682,7 @@ shumate_file_cache_purge (ShumateFileCache *file_cache)
current_size = sqlite3_column_int (stmt, 0);
if (current_size < priv->size_limit)
{
DEBUG ("Cache doesn't need to be purged at %d bytes", current_size);
g_debug ("Cache doesn't need to be purged at %d bytes", current_size);
sqlite3_finalize (stmt);
return;
}
......@@ -697,7 +694,7 @@ shumate_file_cache_purge (ShumateFileCache *file_cache)
rc = sqlite3_prepare (priv->db, query, strlen (query), &stmt, NULL);
if (rc != SQLITE_OK)
{
DEBUG ("Can't fetch tiles to delete: %s", sqlite3_errmsg (priv->db));
g_debug ("Can't fetch tiles to delete: %s", sqlite3_errmsg (priv->db));
}
rc = sqlite3_step (stmt);
......@@ -709,7 +706,7 @@ shumate_file_cache_purge (ShumateFileCache *file_cache)
filename = (const char *) sqlite3_column_text (stmt, 0);
size = sqlite3_column_int (stmt, 1);
highest_popularity = sqlite3_column_int (stmt, 2);
DEBUG ("Deleting %s of size %d", filename, size);
g_debug ("Deleting %s of size %d", filename, size);
delete_tile (file_cache, filename);
......@@ -717,7 +714,7 @@ shumate_file_cache_purge (ShumateFileCache *file_cache)
rc = sqlite3_step (stmt);
}
DEBUG ("Cache size is now %d", current_size);
g_debug ("Cache size is now %d", current_size);
sqlite3_finalize (stmt);
......@@ -726,7 +723,7 @@ shumate_file_cache_purge (ShumateFileCache *file_cache)
sqlite3_exec (priv->db, query, NULL, NULL, &error);
if (error != NULL)
{
DEBUG ("Updating popularity failed: %s", error);
g_debug ("Updating popularity failed: %s", error);
sqlite3_free (error);
}
sqlite3_free (query);
......@@ -935,7 +932,7 @@ shumate_file_cache_store_tile_async (ShumateFileCache *self,
filename = get_filename (self, tile);
file = g_file_new_for_path (filename);
DEBUG ("Update of %p", tile);
g_debug ("Update of %p", tile);
/* If needed, create the cache's dirs */
path = g_path_get_dirname (filename);
......
......@@ -37,9 +37,6 @@
#include "shumate-map-source-factory.h"
#define DEBUG_FLAG SHUMATE_DEBUG_NETWORK
#include "shumate-debug.h"
#include "shumate.h"
#include "shumate-enum-types.h"
#include "shumate-map-source.h"
......
......@@ -27,9 +27,6 @@
* most recently used tiles.
*/
#define DEBUG_FLAG SHUMATE_DEBUG_CACHE
#include "shumate-debug.h"
#include "shumate-memory-cache.h"
#include <glib.h>
......
......@@ -34,9 +34,6 @@
#include "shumate-network-tile-source.h"
#define DEBUG_FLAG SHUMATE_DEBUG_LOADING
#include "shumate-debug.h"
#include "shumate.h"
#include "shumate-enum-types.h"
#include "shumate-map-source.h"
......@@ -764,7 +761,7 @@ on_message_sent (GObject *source_object,
return;
}
DEBUG ("Got reply %d", data->msg->status_code);
g_debug ("Got reply %d", data->msg->status_code);
if (data->msg->status_code == SOUP_STATUS_NOT_MODIFIED)
{
......@@ -788,7 +785,7 @@ on_message_sent (GObject *source_object,
/* Verify if the server sent an etag and save it */
etag = soup_message_headers_get_one (data->msg->response_headers, "ETag");
DEBUG ("Received ETag %s", etag);
g_debug ("Received ETag %s", etag);
data->etag = g_strdup (etag);
......@@ -893,13 +890,13 @@ on_file_cache_get_tile (GObject *source_object, GAsyncResult *res, gpointer user
*/
if (etag)
{
DEBUG ("If-None-Match: %s", etag);
g_debug ("If-None-Match: %s", etag);
soup_message_headers_append (data->msg->request_headers,
"If-None-Match", etag);
}
else if (modtime_string)
{
DEBUG ("If-Modified-Since %s", modtime_string);
g_debug ("If-Modified-Since %s", modtime_string);
soup_message_headers_append (data->msg->request_headers,
"If-Modified-Since", modtime_string);
}
......
......@@ -50,9 +50,6 @@
#include "shumate-view.h"
#define DEBUG_FLAG SHUMATE_DEBUG_VIEW
#include "shumate-debug.h"
#include "shumate.h"
#include "shumate-enum-types.h"
#include "shumate-kinetic-scrolling-private.h"
......@@ -855,8 +852,6 @@ shumate_view_init (ShumateView *view)
GtkEventController *motion_controller;
GtkGesture *swipe_gesture;
shumate_debug_set_flags (g_getenv ("SHUMATE_DEBUG"));
priv->viewport = shumate_viewport_new ();
priv->zoom_on_double_click = TRUE;
priv->animate_zoom = TRUE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment