Bump the version number in configure.ac to 1.0.5
[moonshot-ui.git] / src / moonshot-logger.vala
index d815210..c66aa7e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2014, JANET(UK)
+ * Copyright (c) 2011-2016, JANET(UK)
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -38,6 +38,13 @@ public MoonshotLogger get_logger(string name) {
 
 #if USE_LOG4VALA
 
+static void glib_default_log_handler(string? log_domain, LogLevelFlags log_level, string message)
+{
+    Log4Vala.Logger logger = Log4Vala.Logger.get_logger(log_domain ?? "Glib");
+    stderr.printf(log_level.to_string() + " : " + message ?? "" + "\n");
+    logger.error("Glib error level: " + log_level.to_string() + " : " + (message ?? ""));
+}
+
 /** Logger class that wraps the Log4Vala logger */
 public class MoonshotLogger : Object {
     static bool logger_is_initialized = false;
@@ -46,8 +53,15 @@ public class MoonshotLogger : Object {
 
     public MoonshotLogger(string name) {
         if (!logger_is_initialized) {
-            //!! TODO: Don't hard-code the pathname.
-            Log4Vala.init("/home/dbreslau/log4vala.conf");
+            Log.set_default_handler(glib_default_log_handler);
+
+#if IPC_MSRPC
+            // Look for config file in the app's current directory.
+            string conf_file = "log4vala.conf";
+#else
+            string conf_file = GLib.Environment.get_variable("MOONSHOT_UI_LOG_CONFIG");
+#endif
+            Log4Vala.init(conf_file);
             logger_is_initialized = true;
         }