Add more log files to distinguish between classes of messages

This commit is contained in:
Flamefire committed 2014-03-09 20:07:28 +01:00
1 parent 24ca4edab7
commit 90ba1188d3
5 files changed
+35 -5

No files matched your search

+20 -4
View File
@@ -28,7 +28,7 @@ namespace Vocaluxe.Base
private readonly string _LogFileName; private readonly string _LogFileName;
private readonly string _LogName; private readonly string _LogName;
private StreamWriter _LogFile; private StreamWriter _LogFile;
private Object _FileMutex = new Object(); private readonly Object _FileMutex = new Object();
public CLogFile(string fileName, string logName) public CLogFile(string fileName, string logName)
{ {
@@ -94,6 +94,8 @@ namespace Vocaluxe.Base
private static CLogFile _ErrorLog; private static CLogFile _ErrorLog;
private static CLogFile _PerformanceLog; private static CLogFile _PerformanceLog;
private static CLogFile _BenchmarkLog; private static CLogFile _BenchmarkLog;
private static CLogFile _DebugLog;
private static CLogFile _SongInfoLog;
private static int _NumErrors; private static int _NumErrors;
private static Stopwatch[] _BenchmarkTimer; private static Stopwatch[] _BenchmarkTimer;
@@ -101,9 +103,11 @@ namespace Vocaluxe.Base
public static void Init() public static void Init()
{ {
_ErrorLog = new CLogFile(CSettings.FileErrorLog, "ErrorLog"); _ErrorLog = new CLogFile(CSettings.FileErrorLog, "Error-Log");
_PerformanceLog = new CLogFile(CSettings.FilePerformanceLog, "PerformanceLog"); _PerformanceLog = new CLogFile(CSettings.FilePerformanceLog, "Performance-Log");
_BenchmarkLog = new CLogFile(CSettings.FileBenchmarkLog, "BenchmarkLog"); _BenchmarkLog = new CLogFile(CSettings.FileBenchmarkLog, "Benchmark-Log");
_DebugLog = new CLogFile(CSettings.FileDebugLog, "Debug-Log");
_SongInfoLog = new CLogFile(CSettings.FileSongInfoLog, "Song-Information-Log");
_NumErrors = 0; _NumErrors = 0;
_BenchmarkTimer = new Stopwatch[_MaxBenchmarks]; _BenchmarkTimer = new Stopwatch[_MaxBenchmarks];
@@ -116,6 +120,8 @@ namespace Vocaluxe.Base
_ErrorLog.Close(); _ErrorLog.Close();
_PerformanceLog.Close(); _PerformanceLog.Close();
_BenchmarkLog.Close(); _BenchmarkLog.Close();
_DebugLog.Close();
_SongInfoLog.Close();
} }
#region LogError #region LogError
@@ -132,6 +138,16 @@ namespace Vocaluxe.Base
} }
#endregion LogError #endregion LogError
public static void LogDebug(string text)
{
_DebugLog.Add(String.Format("{0:HH:mm:ss.ffff}", DateTime.Now) + ":" + text);
}
public static void LogSongInfo(string text)
{
_SongInfoLog.Add(text);
}
#region LogPerformance #region LogPerformance
public static void LogPerformance(string text) public static void LogPerformance(string text)
{ {
+10
View File
@@ -443,6 +443,16 @@ namespace Vocaluxe.Base
{ {
CLog.LogError(errorText); CLog.LogError(errorText);
} }
public void LogDebug(string text)
{
CLog.LogDebug(text);
}
public void LogSongInfo(string text)
{
CLog.LogSongInfo(text);
}
} }
class CBfonts : IFonts class CBfonts : IFonts
+2
View File
@@ -85,6 +85,8 @@ namespace Vocaluxe.Base
public const string FilePerformanceLog = "Performance.log"; public const string FilePerformanceLog = "Performance.log";
public const string FileErrorLog = "Error.log"; public const string FileErrorLog = "Error.log";
public const string FileBenchmarkLog = "Benchmark.log"; public const string FileBenchmarkLog = "Benchmark.log";
public const string FileDebugLog = "Debug.log";
public const string FileSongInfoLog = "SongInformation.log";
public const string SoundT440 = "440Hz.mp3"; public const string SoundT440 = "440Hz.mp3";
+2
View File
@@ -155,6 +155,8 @@ namespace VocaluxeLib
public interface ILog public interface ILog
{ {
void LogError(string errorText); void LogError(string errorText);
void LogDebug(string text);
void LogSongInfo(string text);
} }
public interface IFonts public interface IFonts
+1 -1
View File
@@ -81,7 +81,7 @@ namespace VocaluxeLib.Songs
msg = (error ? "Error: " : "Warning: ") + msg; msg = (error ? "Error: " : "Warning: ") + msg;
if (withLineNr) if (withLineNr)
msg += " in line #" + _LineNr; msg += " in line #" + _LineNr;
CBase.Log.LogError(msg + " (" + Path.Combine(_Song.Folder, _Song.FileName) + ")"); CBase.Log.LogSongInfo(msg + " (" + Path.Combine(_Song.Folder, _Song.FileName) + ")");
} }
private void _LogError(string msg, bool withLineNr = true) private void _LogError(string msg, bool withLineNr = true)