Skip to content

Commit 7dc684c

Browse files
author
Christopher Remde
committed
Fixed new log system for Player
1 parent 3106c3c commit 7dc684c

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

LiveScanPlayer/PlayerWindowForm.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace LiveScanPlayer
1717
public partial class PlayerWindowForm : Form
1818
{
1919
OpenGLView oOpenGLWindow = null;
20+
Thread logThread;
2021
System.Windows.Forms.Timer tLiveViewTimer;
2122
float fTargetFPS = 30f;
2223
long lActualFPS = 30;
@@ -48,6 +49,10 @@ public PlayerWindowForm()
4849
updateWorker.RunWorkerAsync();
4950
lFrameFilesListView.Columns.Add("Files:", 300);
5051
this.Icon = Properties.Resources.Player_Icon;
52+
53+
Log.SetupLog(Log.LogLevel.Debug, "Log_Player");
54+
logThread = new Thread(() => { Log.RunLog(); });
55+
logThread.Start();
5156
}
5257

5358
private void PlayerWindowForm_Load(object sender, EventArgs e)
@@ -57,6 +62,10 @@ private void PlayerWindowForm_Load(object sender, EventArgs e)
5762

5863
private void PlayerWindowForm_FormClosing(object sender, FormClosingEventArgs e)
5964
{
65+
Log.LogInfo("Programm termined normally, exiting");
66+
Log.WriteLogBuffer();
67+
Log.CloseLog();
68+
logThread.Join();
6069
bAppOpen = false;
6170
StopUpdateWorker();
6271
}

LiveScanServer/LiveScanServer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public LiveScanServer(MainWindowForm UI)
8787

8888
}
8989

90-
if (!Log.SetupLog(loglevel))
90+
if (!Log.SetupLog(loglevel, "Log_Server"))
9191
{
9292
UI.RequestMessagBox(MessageBoxIcon.Error, "Could not access logging file, another Livescan Server instance is probably already open!", true);
9393
return;

LiveScanServer/Log.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
namespace LiveScanServer
1212
{
13-
static class Log
13+
public static class Log
1414
{
1515
[DllImport("kernel32.dll", EntryPoint = "AllocConsole", SetLastError = true, CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
1616
private static extern int AllocConsole();
1717

18-
const string logFilePath = "logs/Log_Server.txt";
18+
static string logFilePath = "Log";
1919

2020
public enum LogLevel { All, DebugCapture, Debug, Normal, None }
2121

@@ -34,7 +34,7 @@ public enum LogLevel { All, DebugCapture, Debug, Normal, None }
3434
/// </summary>
3535
/// <param name="loglevel"></param>
3636
/// <returns></returns>
37-
public static bool SetupLog(LogLevel loglevel)
37+
public static bool SetupLog(LogLevel loglevel, string logFileName)
3838
{
3939
#if DEBUG
4040
if (loglevel > LogLevel.Debug)
@@ -45,6 +45,8 @@ public static bool SetupLog(LogLevel loglevel)
4545
if (logLevel == LogLevel.None)
4646
return true;
4747

48+
logFilePath = "logs/" + logFileName + ".txt";
49+
4850
try
4951
{
5052
lock (writeLock)

LiveScanServer/Utils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public struct Joint
232232

233233
public enum EColorMode { RGB, BGR };
234234

235-
public class Utils
235+
public static class Utils
236236
{
237237
public static void saveToPly(string filename, List<Single> vertices, List<byte> colors, EColorMode colorMode,bool binary)
238238
{

0 commit comments

Comments
 (0)