[gnome-photos] Add basic debug infrastructure



commit 771a39de3649481bd8275bc72c59c9a8c2daf849
Author: Pranav Kant <pranav913 gmail com>
Date:   Wed Feb 11 19:13:41 2015 +0530

    Add basic debug infrastructure
    
    https://bugzilla.gnome.org/show_bug.cgi?id=744305

 src/Makefile.am    |    2 +
 src/photos-debug.c |   66 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/photos-debug.h |   42 +++++++++++++++++++++++++++++++++
 3 files changed, 110 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 397e1e8..0d6a6b6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -84,6 +84,8 @@ gnome_photos_SOURCES = \
        photos-create-collection-icon-job.h \
        photos-create-collection-job.c \
        photos-create-collection-job.h \
+       photos-debug.c \
+       photos-debug.h \
        photos-delete-item-job.c \
        photos-delete-item-job.h \
        photos-delete-notification.c \
diff --git a/src/photos-debug.c b/src/photos-debug.c
new file mode 100644
index 0000000..fc361d2
--- /dev/null
+++ b/src/photos-debug.c
@@ -0,0 +1,66 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2015 Pranav Kant
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+
+#include "config.h"
+
+#include <stdarg.h>
+
+#include <glib.h>
+
+#include "photos-debug.h"
+
+
+static PhotosDebugFlags debug_flags;
+
+
+void
+photos_debug_init (void)
+{
+  const GDebugKey keys[] =
+    {
+      { "dlna", PHOTOS_DEBUG_DLNA },
+      { "gegl", PHOTOS_DEBUG_GEGL },
+      { "network", PHOTOS_DEBUG_NETWORK },
+      { "tracker", PHOTOS_DEBUG_TRACKER }
+    };
+  const gchar *debug_string;
+
+  debug_string = g_getenv ("GNOME_PHOTOS_DEBUG");
+  debug_flags = g_parse_debug_string (debug_string, keys, G_N_ELEMENTS (keys));
+}
+
+
+void photos_debug (guint flags, const char *fmt, ...)
+{
+  if ((debug_flags & flags) != 0)
+    {
+      gchar *message;
+      va_list ap;
+
+      va_start (ap, fmt);
+      message = g_strdup_vprintf (fmt, ap);
+      va_end (ap);
+
+      g_debug ("%s", message);
+
+      g_free (message);
+    }
+}
diff --git a/src/photos-debug.h b/src/photos-debug.h
new file mode 100644
index 0000000..fe72875
--- /dev/null
+++ b/src/photos-debug.h
@@ -0,0 +1,42 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2015 Pranav Kant
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef PHOTOS_DEBUG_H
+#define PHOTOS_DEBUG_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+typedef enum
+{
+  PHOTOS_DEBUG_DLNA       = 1 << 0,
+  PHOTOS_DEBUG_GEGL       = 1 << 1,
+  PHOTOS_DEBUG_NETWORK    = 1 << 2,
+  PHOTOS_DEBUG_TRACKER    = 1 << 3
+} PhotosDebugFlags;
+
+void        photos_debug_init          (void);
+
+void        photos_debug               (guint flags, const char *fmt, ...) G_GNUC_PRINTF (2, 3);
+
+G_END_DECLS
+
+#endif /* PHOTOS_DEBUG_H */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]