[longomatch/redesign2: 59/140] Init Logging at startup and starting logging exceptions



commit f6322bb6d0b76e340d8bf290fec9882cff514ee0
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Sat Jan 29 18:00:56 2011 +0100

    Init Logging at startup and starting logging exceptions

 LongoMatch/Main.cs |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/LongoMatch/Main.cs b/LongoMatch/Main.cs
index c1d2beb..0b0f1ed 100644
--- a/LongoMatch/Main.cs
+++ b/LongoMatch/Main.cs
@@ -44,6 +44,9 @@ namespace LongoMatch
 		public static void Main(string[] args)
 		{
 			SetupBaseDir();
+
+			Log.Debugging = Debugging;
+			Log.Information("Starting " + Constants.SOFTWARE_NAME);
 
 			//Iniciamos la internalización
 			Catalog.Init(Constants.SOFTWARE_NAME.ToLower(),RelativeToPrefix("share/locale"));
@@ -193,6 +196,25 @@ namespace LongoMatch
 				configDirectory = System.IO.Path.Combine(home,".longomatch");
 		}
 
+		private static bool? debugging = null;	
+		public static bool Debugging {
+			get {
+				if (debugging == null) {
+					debugging = EnvironmentIsSet ("LGM_DEBUG");
+				}
+				return debugging.Value;
+			}
+			set {
+				debugging = value;
+				Log.Debugging = Debugging;
+			}
+		}
+		
+		public static bool EnvironmentIsSet (string env)
+		{
+			return !String.IsNullOrEmpty (Environment.GetEnvironmentVariable (env));
+		}
+		
 		private static void OnException(GLib.UnhandledExceptionArgs args) {
 			ProcessExecutionError((Exception)args.ExceptionObject);
 		}
@@ -216,6 +238,7 @@ namespace LongoMatch
 				s.WriteLine("\n\n\nStackTrace:");
 				s.WriteLine(System.Environment.StackTrace);
 			}
+			Log.Exception (ex);
 			//TODO Add bug reports link
 			MessagePopup.PopupMessage(null, MessageType.Error,
 			                          Catalog.GetString("The application has finished with an unexpected error.")+"\n"+



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