[rygel] core: A simple log handler



commit cd1035bb5f2150dc2518138130ac4eb9a636c8b5
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu Sep 24 18:34:45 2009 +0300

    core: A simple log handler
    
    For now it just registers a domain and a handler for it that only
    forwards the messages to glib default log domain.

 src/rygel/Makefile.am            |    3 +-
 src/rygel/rygel-log-handler.vala |   51 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletions(-)
---
diff --git a/src/rygel/Makefile.am b/src/rygel/Makefile.am
index c23535e..e83c263 100644
--- a/src/rygel/Makefile.am
+++ b/src/rygel/Makefile.am
@@ -83,7 +83,8 @@ VAPI_SOURCE_FILES = rygel-configuration.vala \
 		    rygel-media-db.vala \
 		    rygel-metadata-extractor.vala \
 		    rygel-media-db-container.vala \
-		    rygel-media-db-object-factory.vala
+		    rygel-media-db-object-factory.vala \
+		    rygel-log-handler.vala
 
 rygel_VALAFLAGS = \
 	-H rygel.h -C --library=rygel-1.0 --vapidir=$(srcdir) --thread \
diff --git a/src/rygel/rygel-log-handler.vala b/src/rygel/rygel-log-handler.vala
new file mode 100644
index 0000000..1e8d077
--- /dev/null
+++ b/src/rygel/rygel-log-handler.vala
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2008 Nokia Corporation.
+ *
+ * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ *                               <zeeshan ali nokia com>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel 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 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel 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 program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+public class Rygel.LogHandler : GLib.Object {
+    public const string DOMAIN = "Rygel";
+
+    private static LogHandler log_handler; // Singleton
+
+    public static LogHandler get_default () {
+        if (log_handler == null) {
+            log_handler = new LogHandler ();
+        }
+
+        return log_handler;
+    }
+
+    private LogHandler () {
+        Log.set_handler (DOMAIN,
+                         LogLevelFlags.LEVEL_MASK | LogLevelFlags.FLAG_FATAL,
+                         this.log_func);
+    }
+
+    private void log_func (string?       log_domain,
+                           LogLevelFlags log_levels,
+                           string        message) {
+        assert (log_domain == DOMAIN);
+
+        // Just forward the message to default domain for now
+        log (null, log_levels, message);
+    }
+}



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