Merge pull request #378 from lukeIam/SmallLogFixes

Small log fixes
This commit is contained in:
Florian Küpper authored and GitHub committed 2018-02-27 22:04:02 +01:00
commit 48975b1ab5
3 files changed
+10 -11

No files matched your search

+1 -8
View File
@@ -73,14 +73,7 @@ namespace Vocaluxe
} }
catch (Exception e) catch (Exception e)
{ {
string stackTrace = ""; CLog.Fatal(e, "Unhandled error: {ErrorMessage}", CLog.Params(e.Message));
try
{
stackTrace = e.StackTrace;
}
catch {}
MessageBox.Show("Unhandled error: " + e.Message + stackTrace);
CLog.Error("Unhandled error: " + e.Message + stackTrace);
} }
#else #else
_Run(args); _Run(args);
+7 -1
View File
@@ -50,7 +50,7 @@ namespace VocaluxeLib.Log
/// <param name="fileNameSongInfoLog">The name of the log for song problems.</param> /// <param name="fileNameSongInfoLog">The name of the log for song problems.</param>
/// <param name="fileNameCrashMarker">The name of the file which is used as crash marker.</param> /// <param name="fileNameCrashMarker">The name of the file which is used as crash marker.</param>
/// <param name="currentVersion">The current version tag as it is displayed in the main menu.</param> /// <param name="currentVersion">The current version tag as it is displayed in the main menu.</param>
/// <param name="showReporterFunc">Delegate to the function wchih should be called if the reporter have to been shown.</param> /// <param name="showReporterFunc">Delegate to the function which should be called if the reporter have to been shown.</param>
public static void Init(string logFolder, string fileNameMainLog, string fileNameSongInfoLog, string fileNameCrashMarker, string currentVersion, ShowReporterDelegate showReporterFunc) public static void Init(string logFolder, string fileNameMainLog, string fileNameSongInfoLog, string fileNameCrashMarker, string currentVersion, ShowReporterDelegate showReporterFunc)
{ {
_LogFolder = logFolder; _LogFolder = logFolder;
@@ -156,6 +156,12 @@ namespace VocaluxeLib.Log
_MainLogStringWriter.Flush(); _MainLogStringWriter.Flush();
// Show the Reporter // Show the Reporter
_ShowReporterFunc(crash: crash, showContinue: showContinue, vocaluxeVersionTag: _CurrentVersion, log: _MainLogStringBuilder.ToString(), lastError: _FormatMessageTemplate(messageTemplate, propertyValues)); _ShowReporterFunc(crash: crash, showContinue: showContinue, vocaluxeVersionTag: _CurrentVersion, log: _MainLogStringBuilder.ToString(), lastError: _FormatMessageTemplate(messageTemplate, propertyValues));
// Delete the crash marker (we do not want to show this error again on the next restart)
if (!showContinue)
{
File.Delete(_CrashMarkerFilePath);
}
} }
/// <summary> /// <summary>
+2 -2
View File
@@ -73,7 +73,7 @@ namespace VocaluxeLib.Log.Rolling
private static void _DeleteOldLogs(string mainLogFile, int numLogsToKeep) private static void _DeleteOldLogs(string mainLogFile, int numLogsToKeep)
{ {
Regex r = new Regex($"{Path.GetDirectoryName(mainLogFile)}\\\\{Path.GetFileNameWithoutExtension(mainLogFile)}_([0-9]+){Path.GetExtension(mainLogFile)}", RegexOptions.IgnoreCase); Regex r = new Regex($"{Path.GetDirectoryName(mainLogFile)}\\{Path.DirectorySeparatorChar}{Path.GetFileNameWithoutExtension(mainLogFile)}_([0-9]+){Path.GetExtension(mainLogFile)}", RegexOptions.IgnoreCase);
IEnumerable<string> logFiles = Directory.EnumerateFiles($"{Path.GetDirectoryName(mainLogFile)}", $"{Path.GetFileNameWithoutExtension(mainLogFile)}*{Path.GetExtension(mainLogFile)}"); IEnumerable<string> logFiles = Directory.EnumerateFiles($"{Path.GetDirectoryName(mainLogFile)}", $"{Path.GetFileNameWithoutExtension(mainLogFile)}*{Path.GetExtension(mainLogFile)}");
foreach (string file in logFiles) foreach (string file in logFiles)
{ {
@@ -104,7 +104,7 @@ namespace VocaluxeLib.Log.Rolling
private static string _GenerateRollLogFileName(string mainLogFile, int number) private static string _GenerateRollLogFileName(string mainLogFile, int number)
{ {
return $"{Path.GetDirectoryName(mainLogFile)}\\{Path.GetFileNameWithoutExtension(mainLogFile)}_{number}{Path.GetExtension(mainLogFile)}"; return $"{ Path.GetDirectoryName(mainLogFile) }{ Path.DirectorySeparatorChar }{ Path.GetFileNameWithoutExtension(mainLogFile) }_{ number }{ Path.GetExtension(mainLogFile) }";
} }
} }
} }