From: Martin Xu <martin...@intel.com>

---
 src/log.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/src/log.c b/src/log.c
index eb480b4..8b4fbe7 100644
--- a/src/log.c
+++ b/src/log.c
@@ -195,6 +195,18 @@ static connman_bool_t is_enabled(struct connman_debug_desc 
*desc)
        return FALSE;
 }
 
+static void glib_fatal_handler(const gchar *log_domain,
+               GLogLevelFlags log_level, const gchar *message,
+                                               gpointer user_data)
+
+{
+       connman_info("%s-CRITICAL **", log_domain);
+
+       signal_handler(0);
+}
+
+static int log_handler_id;
+
 int __connman_log_init(const char *debug, connman_bool_t detach)
 {
        int option = LOG_NDELAY | LOG_PID;
@@ -228,6 +240,10 @@ int __connman_log_init(const char *debug, connman_bool_t 
detach)
 
        signal_setup(signal_handler);
 
+       log_handler_id = g_log_set_handler ("GLib", G_LOG_LEVEL_MASK |
+                               G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
+                                               glib_fatal_handler, NULL);
+
        openlog("connmand", option, LOG_DAEMON);
 
        syslog(LOG_INFO, "Connection Manager version %s", VERSION);
@@ -239,6 +255,8 @@ void __connman_log_cleanup(void)
 {
        syslog(LOG_INFO, "Exit");
 
+       g_log_remove_handler("GLib", log_handler_id);
+
        closelog();
 
        signal_setup(SIG_DFL);
-- 
1.6.1.3

_______________________________________________
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

Reply via email to