Add crash marker
This commit is contained in:
1 parent
b4bb001c51
commit
330b1eada2
4 files changed
+47
-7
No files matched your search
@@ -63,15 +63,15 @@ namespace Vocaluxe.Base
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_Version.ToLower().Contains("alpha"))
|
if (Version.ToLower().Contains("alpha"))
|
||||||
{
|
{
|
||||||
return ERevision.Alpha;
|
return ERevision.Alpha;
|
||||||
}
|
}
|
||||||
if (_Version.ToLower().Contains("beta"))
|
if (Version.ToLower().Contains("beta"))
|
||||||
{
|
{
|
||||||
return ERevision.Beta;
|
return ERevision.Beta;
|
||||||
}
|
}
|
||||||
if (_Version.ToLower().Contains("rc"))
|
if (Version.ToLower().Contains("rc"))
|
||||||
{
|
{
|
||||||
return ERevision.RC;
|
return ERevision.RC;
|
||||||
}
|
}
|
||||||
@@ -115,6 +115,7 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
public const string FileNameMainLog = "Vocaluxe.log";
|
public const string FileNameMainLog = "Vocaluxe.log";
|
||||||
public const string FileNameSongLog = "Song.log";
|
public const string FileNameSongLog = "Song.log";
|
||||||
|
public const string FileNameCrashMarker = "Marker";
|
||||||
|
|
||||||
public const string FileNameRequiredSkinElements = "RequiredSkinElements.xml";
|
public const string FileNameRequiredSkinElements = "RequiredSkinElements.xml";
|
||||||
|
|
||||||
@@ -194,7 +195,7 @@ namespace Vocaluxe.Base
|
|||||||
get { return _Assembly.Name; }
|
get { return _Assembly.Name; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string _Version
|
public static string Version
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -202,6 +203,14 @@ namespace Vocaluxe.Base
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string FullVersion
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Application.ProductVersion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static string GetFullVersionText()
|
public static string GetFullVersionText()
|
||||||
{
|
{
|
||||||
return ((AssemblyTitleAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false).First()).Title;
|
return ((AssemblyTitleAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false).First()).Title;
|
||||||
|
|||||||
+1
-1
@@ -97,7 +97,7 @@ namespace Vocaluxe
|
|||||||
Directory.CreateDirectory(CSettings.DataFolder);
|
Directory.CreateDirectory(CSettings.DataFolder);
|
||||||
|
|
||||||
// Init Log
|
// Init Log
|
||||||
CLog.Init(CSettings.FolderNameLogs, CSettings.FileNameMainLog, CSettings.FileNameSongLog);
|
CLog.Init(CSettings.FolderNameLogs, CSettings.FileNameMainLog, CSettings.FileNameSongLog, CSettings.FileNameCrashMarker, CSettings.FullVersion);
|
||||||
|
|
||||||
if (!CProgrammHelper.CheckRequirements())
|
if (!CProgrammHelper.CheckRequirements())
|
||||||
return;
|
return;
|
||||||
|
|||||||
+32
-1
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using VocaluxeLib.Log.Enricher;
|
using VocaluxeLib.Log.Enricher;
|
||||||
@@ -16,16 +17,43 @@ namespace VocaluxeLib.Log
|
|||||||
private static ILogger _MainLog = new SilentLogger();
|
private static ILogger _MainLog = new SilentLogger();
|
||||||
private static ILogger _SongLog = new SilentLogger();
|
private static ILogger _SongLog = new SilentLogger();
|
||||||
private static string _LogFolder;
|
private static string _LogFolder;
|
||||||
|
private static string _CrashMarkerFilePath;
|
||||||
|
|
||||||
private const string _MainLogTemplate = "[{TimeStampFromStart}] [{Level}] {Message}{NewLine}{Properties}{NewLine}{Exception}";
|
private const string _MainLogTemplate = "[{TimeStampFromStart}] [{Level}] {Message}{NewLine}{Properties}{NewLine}{Exception}";
|
||||||
private const string _SongLogTemplate = "{Message}{NewLine}Additional info:{Properties}{NewLine}{Exception}";
|
private const string _SongLogTemplate = "{Message}{NewLine}Additional info:{Properties}{NewLine}{Exception}";
|
||||||
|
|
||||||
public static void Init(string logFolder, string fileNameMainLog, string fileNameSongInfoLog)
|
public static void Init(string logFolder, string fileNameMainLog, string fileNameSongInfoLog, string fileNameCrashMarker, string currentVersion)
|
||||||
{
|
{
|
||||||
_LogFolder = logFolder;
|
_LogFolder = logFolder;
|
||||||
|
_CrashMarkerFilePath = Path.Combine(_LogFolder, fileNameCrashMarker);
|
||||||
|
|
||||||
|
|
||||||
|
// Creates the log directory if it does not exist
|
||||||
if (!Directory.Exists(_LogFolder))
|
if (!Directory.Exists(_LogFolder))
|
||||||
Directory.CreateDirectory(_LogFolder);
|
Directory.CreateDirectory(_LogFolder);
|
||||||
|
|
||||||
|
// Check if crash marker file
|
||||||
|
if (File.Exists(_CrashMarkerFilePath))
|
||||||
|
{
|
||||||
|
// There was a crash in the last run -> check version tag of the crashed application instance
|
||||||
|
string versionTag;
|
||||||
|
using (StreamReader reader = new StreamReader(_CrashMarkerFilePath, Encoding.UTF8))
|
||||||
|
{
|
||||||
|
versionTag = (reader.ReadLine() ?? "").Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete the old marker
|
||||||
|
File.Delete(_CrashMarkerFilePath);
|
||||||
|
|
||||||
|
if (currentVersion == versionTag)
|
||||||
|
{
|
||||||
|
// TODO: Load log + Crashreport
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write new marker
|
||||||
|
File.WriteAllText(_CrashMarkerFilePath, currentVersion, Encoding.UTF8);
|
||||||
|
|
||||||
LogFileRoller.RollLogs(Path.Combine(_LogFolder, fileNameMainLog), 2);
|
LogFileRoller.RollLogs(Path.Combine(_LogFolder, fileNameMainLog), 2);
|
||||||
LogFileRoller.RollLogs(Path.Combine(_LogFolder, fileNameSongInfoLog), 2);
|
LogFileRoller.RollLogs(Path.Combine(_LogFolder, fileNameSongInfoLog), 2);
|
||||||
|
|
||||||
@@ -67,6 +95,9 @@ namespace VocaluxeLib.Log
|
|||||||
(_SongLog as IDisposable)?.Dispose();
|
(_SongLog as IDisposable)?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete the crash marker
|
||||||
|
File.Delete(_CrashMarkerFilePath);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void _ShowLogAssistent(string messageTemplate, object[] propertyValues, string callerMethodeName = "", string callerFilePath = "", int callerLineNumer = -1)
|
private static void _ShowLogAssistent(string messageTemplate, object[] propertyValues, string callerMethodeName = "", string callerFilePath = "", int callerLineNumer = -1)
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace VocaluxeTests
|
|||||||
public void TestRoundGeneration()
|
public void TestRoundGeneration()
|
||||||
{
|
{
|
||||||
CBase.Game = new CBGame();
|
CBase.Game = new CBGame();
|
||||||
CLog.Init(CSettings.FolderNameLogs, CSettings.FileNameMainLog, CSettings.FileNameSongLog);
|
CLog.Init(CSettings.FolderNameLogs, CSettings.FileNameMainLog, CSettings.FileNameSongLog, CSettings.FileNameCrashMarker, CSettings.FullVersion);
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
for (int numPlayer = 1; numPlayer <= 20; numPlayer++)
|
for (int numPlayer = 1; numPlayer <= 20; numPlayer++)
|
||||||
|
|||||||
Reference in new issue
Block a user