[longomatch] Add full application log in error logs



commit d89c6f8fdbbf9f72edf1a9f9ed065460edc4d6af
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Thu Apr 23 15:51:46 2015 +0200

    Add full application log in error logs

 LongoMatch.Core/Config.cs           |    7 +++++++
 LongoMatch.Services/CoreServices.cs |    4 ++--
 LongoMatch/Main.cs                  |   22 +++++-----------------
 3 files changed, 14 insertions(+), 19 deletions(-)
---
diff --git a/LongoMatch.Core/Config.cs b/LongoMatch.Core/Config.cs
index 917efc8..655424b 100644
--- a/LongoMatch.Core/Config.cs
+++ b/LongoMatch.Core/Config.cs
@@ -144,6 +144,13 @@ namespace LongoMatch
                        }
                }
 
+               public static string LogFile {
+                       get {
+                               string filename = Constants.SOFTWARE_NAME.ToLower () + ".log";
+                               return Path.Combine (Config.ConfigDir, filename);
+                       }
+               }
+
                public static string HomeDir {
                        get {
                                return homeDirectory;
diff --git a/LongoMatch.Services/CoreServices.cs b/LongoMatch.Services/CoreServices.cs
index a8eec4a..4956809 100644
--- a/LongoMatch.Services/CoreServices.cs
+++ b/LongoMatch.Services/CoreServices.cs
@@ -62,8 +62,8 @@ namespace LongoMatch.Services
                        /* Check default folders */
                        CheckDirs ();
 
-                       Log.SetLogFile (Path.Combine (Config.HomeDir,
-                               Constants.SOFTWARE_NAME.ToLower () + ".log"));
+                       /* Redirects logs to a file */
+                       Log.SetLogFile (Config.LogFile);
 
                        /* Load user config */
                        Config.Load ();
diff --git a/LongoMatch/Main.cs b/LongoMatch/Main.cs
index 9fd31b9..0c940bc 100644
--- a/LongoMatch/Main.cs
+++ b/LongoMatch/Main.cs
@@ -157,29 +157,17 @@ namespace LongoMatch
                private static void ProcessExecutionError (Exception ex)
                {
                        string logFile = Constants.SOFTWARE_NAME + "-" + DateTime.Now + ".log";
-                       string message;
-
                        logFile = Utils.SanitizePath (logFile, ' ', ':');
-                       logFile = System.IO.Path.Combine (Config.HomeDir, logFile);
-
-                       message = SysInfo.PrintInfo (Assembly.GetExecutingAssembly ().GetName ().Version);
-                       if (ex.InnerException != null)
-                               message += String.Format ("{0}\n{1}\n{2}\n{3}\n{4}", ex.Message, 
ex.InnerException.Message, ex.Source, ex.StackTrace, ex.InnerException.StackTrace);
-                       else
-                               message += String.Format ("{0}\n{1}\n{2}", ex.Message, ex.Source, 
ex.StackTrace);
-
-                       using (StreamWriter s = new StreamWriter(logFile)) {
-                               s.WriteLine (message);
-                               s.WriteLine ("\n\n\nStackTrace:");
-                               s.WriteLine (System.Environment.StackTrace);
-                       }
+                       logFile = Path.Combine (Config.HomeDir, logFile);
+                       Log.Information (SysInfo.PrintInfo (Assembly.GetExecutingAssembly ().GetName 
().Version));
                        Log.Exception (ex);
+                       File.Copy (Config.LogFile, logFile);
+
                        //TODO Add bug reports link
                        MessagesHelpers.ErrorMessage (null,
-                                                     Catalog.GetString ("The application has finished with 
an unexpected error.") + "\n" +
+                               Catalog.GetString ("The application has finished with an unexpected error.") 
+ "\n" +
                                Catalog.GetString ("A log has been saved at: ") + logFile + "\n" +
                                Catalog.GetString ("Please, fill a bug report "));
-
                        Application.Quit ();
                }
        }


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