[gnome-documents] debug: add a debug utility function to print debug messages



commit 5c804dc8c700279ff16a6dcfbbe63d581c4500dc
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Nov 9 13:56:15 2011 -0500

    debug: add a debug utility function to print debug messages

 src/utils.js |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/src/utils.js b/src/utils.js
index 8da8a03..cd7f946 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -21,6 +21,7 @@
 
 const Gdk = imports.gi.Gdk;
 const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
 const Gtk = imports.gi.Gtk;
 
 const Documents = imports.documents;
@@ -31,6 +32,9 @@ const Lang = imports.lang;
 const _ICON_VIEW_SIZE = 128;
 const _LIST_VIEW_SIZE = 48;
 
+let debugInit = false;
+let debugEnabled = false;
+
 function getIconSize() {
     return Global.settings.get_boolean('list-view') ? _LIST_VIEW_SIZE : _ICON_VIEW_SIZE;
 }
@@ -74,3 +78,16 @@ function isSearchEvent(event) {
 
     return retval;
 }
+
+function debug(str) {
+    if (!debugInit) {
+        let env = GLib.getenv('DOCUMENTS_DEBUG');
+        if (env)
+            debugEnabled = true;
+
+        debugInit = true;
+    }
+
+    if (debugEnabled)
+        log('DEBUG: ' + str);
+}



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