[longomatch/redesign3: 59/156] Init Logging at startup and starting logging exceptions



commit 35346c70e9e4aaaccc81696450ab347d5febb87b
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 d2178cc..6d38119 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"));
@@ -196,6 +199,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);
 		}
@@ -219,6 +241,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]