[chronojump] If crashedBefore: log copied (with datetime) to logs/crash folder
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] If crashedBefore: log copied (with datetime) to logs/crash folder
- Date: Fri, 20 Oct 2017 20:08:32 +0000 (UTC)
commit dd0599c8ae2c6357303cfd348a97ad9a7a8d0cce
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Oct 20 22:06:48 2017 +0200
If crashedBefore: log copied (with datetime) to logs/crash folder
src/chronojump.cs | 2 ++
src/log.cs | 32 ++++++++++++++++++++++++++++++--
src/utilAll.cs | 14 +++++++++++++-
3 files changed, 45 insertions(+), 3 deletions(-)
---
diff --git a/src/chronojump.cs b/src/chronojump.cs
index 3a76974..bafd54e 100644
--- a/src/chronojump.cs
+++ b/src/chronojump.cs
@@ -665,6 +665,8 @@ public class ChronoJump
private void chronojumpCrashedBefore()
{
+ Log.CopyOldToCrashed();
+
/*
string windowsTextLog = "";
diff --git a/src/log.cs b/src/log.cs
index 3e23180..378d746 100644
--- a/src/log.cs
+++ b/src/log.cs
@@ -87,8 +87,36 @@ public class Log
}
*/
}
-
-
+
+ /*
+ * On Chronojump starts, Log.Start() is called, this copies chronojump_log.txt to
chronojump_log_old.txt
+ * a bit later sqliteThings calls: checkIfChronojumpExitAbnormally() and here detects if chrased
before
+ * if crashed then the log will be: chronojump_log_old.txt
+ * move this log to crashed logs folder
+ */
+ public static void CopyOldToCrashed()
+ {
+ //create dir if not exists
+ string dir = UtilAll.GetLogsCrashedDir();
+ if( ! Directory.Exists(dir)) {
+ try {
+ Directory.CreateDirectory (dir);
+ } catch {
+ return;
+ }
+ }
+
+ string filenameOld = UtilAll.GetLogFileOld();
+
+ //if exists, copy to old
+ if(File.Exists(filenameOld)) {
+ try {
+ File.Copy(filenameOld, UtilAll.GetLogCrashedFileTimeStamp(), true); //can be
overwritten
+ } catch {}
+ }
+ }
+
+
/*
//GetLast should NOT return the newer log: the just created and empty file,
//it should return the just before the last, that's the log of when chronojump crashed last time
diff --git a/src/utilAll.cs b/src/utilAll.cs
index c26c8df..80ba096 100644
--- a/src/utilAll.cs
+++ b/src/utilAll.cs
@@ -169,7 +169,19 @@ public class UtilAll
public static string GetLogFileOld() {
return Path.Combine(GetLogsDir() + Path.DirectorySeparatorChar + Constants.FileNameLogOld);
}
-
+
+ public static string GetLogsCrashedDir() {
+ return Path.Combine(
+ Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
+ "Chronojump" + Path.DirectorySeparatorChar + "logs" +
+ Path.DirectorySeparatorChar + "crashed");
+ }
+ public static string GetLogCrashedFileTimeStamp() {
+ return Path.Combine(GetLogsCrashedDir() + Path.DirectorySeparatorChar +
+ "crashed_log_" + UtilDate.ToFile(DateTime.Now) + ".txt");
+ }
+
+
public static string GetTempDir() {
string path = Path.GetTempPath();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]