[longomatch/redesign: 60/96] Init Logging at startup and starting logging exceptions



commit d83f7029933ff0bd7ee9aa6b0fa61829708bed74
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 |   26 +++++++++++++++++++++++++-
 1 files changed, 25 insertions(+), 1 deletions(-)
---
diff --git a/LongoMatch/Main.cs b/LongoMatch/Main.cs
index 6dd3ba7..b09925c 100644
--- a/LongoMatch/Main.cs
+++ b/LongoMatch/Main.cs
@@ -43,12 +43,16 @@ namespace LongoMatch
 
 		public static void Main(string[] args)
 		{
+			Log.Debugging = Debugging;
+			
+			Log.Information("Starting " + Constants.SOFTWARE_NAME);
 			//Configuramos el directorio base de la ejecucuión y el directorio HOME
 			baseDirectory = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory,"../../");
 			homeDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal);
 			configDirectory = System.IO.Path.Combine(homeDirectory,".longomatch");
 			homeDirectory = System.IO.Path.Combine(homeDirectory,Constants.SOFTWARE_NAME);
 
+			
 			if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
 				SetUpWin32Config();
 			}
@@ -178,7 +182,26 @@ namespace LongoMatch
 				return db;
 			}
 		}
-
+		
+		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 SetUpWin32Config() {
 			Environment.SetEnvironmentVariable("GST_PLUGIN_PATH",RelativeToPrefix("lib\\gstreamer-0.10"));
 			baseDirectory = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory,"../");
@@ -223,6 +246,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]