Merge pull request #369 from lukeIam/improvedLogging
Improved logging (closes #365)
This commit is contained in:
76 files changed
+5228
-792
No files matched your search
@@ -71,3 +71,4 @@ tx.exe
|
||||
/Output/x86
|
||||
/PitchTracker/bin
|
||||
/PitchTracker/obj
|
||||
/Logs
|
||||
@@ -242,4 +242,19 @@
|
||||
<string name="TR_SCREENPVOLUMECONTROL_VOLUME">Volume</string>
|
||||
<string name="TR_SCREENPSERVERQR_ADDRESS">Server address</string>
|
||||
<string name="TR_SCREENPSERVERQR_NOTRUNNING">Server is not running. Please check config.xml!</string>
|
||||
<string name="TR_REPORTER_TITLE_TEXT">We are sorry</string>
|
||||
<string name="TR_REPORTER_MESSAGE_CRASH_TEXT">that Vocaluxe run into an error and crashed.\r\nTo help us fix the problem please send us a report.\r\nEdit the following log before submitting to remove possibly sensitive information.</string>
|
||||
<string name="TR_REPORTER_MESSAGE_NO_CRASH_TEXT">that you experienced an error.\r\nTo help us fix the problem please send us a report.\r\nEdit the following log before submitting to remove possibly sensitive information.</string>
|
||||
<string name="TR_REPORTER_NO_UPLOAD_TEXT">Do not upload anything (you can still copy the error message above)</string>
|
||||
<string name="TR_REPORTER_GIST_AND_ISSUE_TEXT">Upload and open an issue (publicly visible + requires a github account)</string>
|
||||
<string name="TR_REPORTER_GIST_ONLY_TEXT">Upload and get a link to your report (publicly visible)</string>
|
||||
<string name="TR_REPORTER_SUBMIT_STEP0_TEXT">Submit</string>
|
||||
<string name="TR_REPORTER_SUBMIT_STEP1_TEXT">Uploading</string>
|
||||
<string name="TR_REPORTER_SUBMIT_STEP2_EXIT_TEXT">Exit</string>
|
||||
<string name="TR_REPORTER_SUBMIT_STEP2_CONTINUE_TEXT">Continue</string>
|
||||
<string name="TR_REPORTER_SUBMITED_MESSAGE_TEXT">The link to your report:</string>
|
||||
<string name="TR_REPORTER_LOGUPLOAD_ERROR_TEXT">Error uploading the log.</string>
|
||||
<string name="TR_REPORTER_LAST_ERROR_TITLE_TEXT">Last error</string>
|
||||
<string name="TR_REPORTER_LAST_ERROR_NA">Not available</string>
|
||||
<string name="TR_REPORTER_ISSUE_TEMPLATE">Describe your issue here.\n\n### Steps to reproduce\nTell us how to reproduce this issue.\n\n### Vocaluxe version and logfile\n{0}\n{1}</string>
|
||||
</resources>
|
||||
@@ -27,6 +27,7 @@ using System.Xml.Serialization;
|
||||
using Vocaluxe.Lib.Sound.Record;
|
||||
using Vocaluxe.Lib.Webcam;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Log;
|
||||
using VocaluxeLib.Profile;
|
||||
using VocaluxeLib.Xml;
|
||||
|
||||
@@ -376,7 +377,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
Config = xml.Deserialize<SConfig>(_FileConfig);
|
||||
if (_XmlErrorsOccured)
|
||||
CLog.LogError("There were some warnings or errors loading the config file. Some values might have been reset to their defaults.");
|
||||
CLog.Error("There were some warnings or errors loading the config file. Some values might have been reset to their defaults.");
|
||||
}
|
||||
else
|
||||
Config = xml.DeserializeString<SConfig>("<root />");
|
||||
|
||||
@@ -25,6 +25,7 @@ using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Log;
|
||||
using VocaluxeLib.Songs;
|
||||
using VocaluxeLib.Xml;
|
||||
|
||||
@@ -185,7 +186,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
catch (CXmlException e)
|
||||
{
|
||||
CLog.LogError("Error loading cover theme " + file + ": " + e);
|
||||
CLog.Error("Error loading cover theme " + file + ": " + e);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -218,7 +219,7 @@ namespace Vocaluxe.Base
|
||||
NoCover = _Covers[_NoCoverNameAlt];
|
||||
else
|
||||
{
|
||||
CBase.Log.LogError("Covertheme \"" + coverTheme.Info.Name + "\" does not include a cover file named \"" + _NoCoverName + "\" and cannot be used!", true, true);
|
||||
CLog.Fatal("Covertheme \"{ThemeName}\" does not include a cover file named \"{MissingFileName}\" and cannot be used!", CLog.Params(coverTheme.Info.Name, _NoCoverName));
|
||||
_UnloadCovers();
|
||||
// Remove current theme and recursively try the other themes
|
||||
_CoverThemes.Remove(coverTheme);
|
||||
|
||||
@@ -21,6 +21,7 @@ using System.IO;
|
||||
using Vocaluxe.Lib.Database;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Base
|
||||
{
|
||||
@@ -38,17 +39,17 @@ namespace Vocaluxe.Base
|
||||
|
||||
if (!_HighscoreDB.Init())
|
||||
{
|
||||
CLog.LogError("Error initializing Highscore-DB", true, true);
|
||||
CLog.Fatal("Error initializing Highscore-DB");
|
||||
return false;
|
||||
}
|
||||
if (!_CoverDB.Init())
|
||||
{
|
||||
CLog.LogError("Error initializing Cover-DB", true, true);
|
||||
CLog.Fatal("Error initializing Cover-DB");
|
||||
return false;
|
||||
}
|
||||
if (!_ResourceDB.Init())
|
||||
{
|
||||
CLog.LogError("Error initializing Credits-DB", true, true);
|
||||
CLog.Fatal("Error initializing Credits-DB");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -20,6 +20,7 @@ using System.Drawing;
|
||||
using Vocaluxe.Lib.Draw;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Base
|
||||
{
|
||||
@@ -48,8 +49,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError(e.Message + " - Error in initializing of OpenGL. Please check whether" +
|
||||
" your graphic card drivers are up to date.", true, true);
|
||||
CLog.Fatal(e, "Error in initializing of OpenGL. Please check whether your graphic card drivers are up to date.");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@@ -62,9 +62,8 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError(e.Message + " - Error in initializing of Direct3D. Please check if " +
|
||||
"your DirectX redistributables and graphic card drivers are up to date. You can " +
|
||||
"download the DirectX runtimes at http://www.microsoft.com/download/en/details.aspx?id=8109", true, true);
|
||||
CLog.Fatal(e, "Error in initializing of Direct3D. Please check if your DirectX redistributables and graphic card drivers are up to date. You can " +
|
||||
"download the DirectX runtimes at http://www.microsoft.com/download/en/details.aspx?id=8109");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
+41
-35
@@ -24,6 +24,7 @@ using Vocaluxe.Base.Fonts;
|
||||
using Vocaluxe.Base.ThemeSystem;
|
||||
using Vocaluxe.Screens;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Log;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
namespace Vocaluxe.Base
|
||||
@@ -61,36 +62,34 @@ namespace Vocaluxe.Base
|
||||
public static void Init()
|
||||
{
|
||||
// Add Screens, must be the same order as in EScreens!
|
||||
CLog.StartBenchmark("Build Screen List");
|
||||
using (CBenchmark.Time("Build Screen List"))
|
||||
{
|
||||
_Screens.Add(new CScreenTest());
|
||||
_Screens.Add(new CScreenLoad());
|
||||
_Screens.Add(new CScreenMain());
|
||||
_Screens.Add(new CScreenSong());
|
||||
_Screens.Add(new CScreenOptions());
|
||||
_Screens.Add(new CScreenSing());
|
||||
_Screens.Add(new CScreenProfiles());
|
||||
_Screens.Add(new CScreenScore());
|
||||
_Screens.Add(new CScreenHighscore());
|
||||
_Screens.Add(new CScreenOptionsGame());
|
||||
_Screens.Add(new CScreenOptionsSound());
|
||||
_Screens.Add(new CScreenOptionsRecord());
|
||||
_Screens.Add(new CScreenOptionsVideo());
|
||||
_Screens.Add(new CScreenOptionsVideoAdjustments());
|
||||
_Screens.Add(new CScreenOptionsLyrics());
|
||||
_Screens.Add(new CScreenOptionsTheme());
|
||||
_Screens.Add(new CScreenNames());
|
||||
_Screens.Add(new CScreenCredits());
|
||||
_Screens.Add(new CScreenParty());
|
||||
|
||||
_Screens.Add(new CScreenTest());
|
||||
_Screens.Add(new CScreenLoad());
|
||||
_Screens.Add(new CScreenMain());
|
||||
_Screens.Add(new CScreenSong());
|
||||
_Screens.Add(new CScreenOptions());
|
||||
_Screens.Add(new CScreenSing());
|
||||
_Screens.Add(new CScreenProfiles());
|
||||
_Screens.Add(new CScreenScore());
|
||||
_Screens.Add(new CScreenHighscore());
|
||||
_Screens.Add(new CScreenOptionsGame());
|
||||
_Screens.Add(new CScreenOptionsSound());
|
||||
_Screens.Add(new CScreenOptionsRecord());
|
||||
_Screens.Add(new CScreenOptionsVideo());
|
||||
_Screens.Add(new CScreenOptionsVideoAdjustments());
|
||||
_Screens.Add(new CScreenOptionsLyrics());
|
||||
_Screens.Add(new CScreenOptionsTheme());
|
||||
_Screens.Add(new CScreenNames());
|
||||
_Screens.Add(new CScreenCredits());
|
||||
_Screens.Add(new CScreenParty());
|
||||
|
||||
Debug.Assert(_Screens.Count == (int)EScreen.CountEntry, "Screen list and screens enum do not match");
|
||||
|
||||
_PopupScreens.Add(new CPopupScreenPlayerControl());
|
||||
_PopupScreens.Add(new CPopupScreenVolumeControl());
|
||||
_PopupScreens.Add(new CPopupScreenServerQR());
|
||||
|
||||
CLog.StopBenchmark("Build Screen List");
|
||||
Debug.Assert(_Screens.Count == (int)EScreen.CountEntry, "Screen list and screens enum do not match");
|
||||
|
||||
_PopupScreens.Add(new CPopupScreenPlayerControl());
|
||||
_PopupScreens.Add(new CPopupScreenVolumeControl());
|
||||
_PopupScreens.Add(new CPopupScreenServerQR());
|
||||
}
|
||||
CurrentScreen = _Screens[(int)EScreen.Load];
|
||||
NextScreen = null;
|
||||
_CurrentPopupScreen = EPopupScreens.NoPopup;
|
||||
@@ -99,9 +98,10 @@ namespace Vocaluxe.Base
|
||||
GlobalAlpha = 1f;
|
||||
ZOffset = 0f;
|
||||
|
||||
CLog.StartBenchmark("Load Theme");
|
||||
LoadTheme();
|
||||
CLog.StopBenchmark("Load Theme");
|
||||
using (CBenchmark.Time("Load Theme"))
|
||||
{
|
||||
LoadTheme();
|
||||
}
|
||||
}
|
||||
|
||||
public static void Close()
|
||||
@@ -118,10 +118,11 @@ namespace Vocaluxe.Base
|
||||
|
||||
for (int i = 0; i < _Screens.Count; i++)
|
||||
{
|
||||
CLog.StartBenchmark("Load Theme " + Enum.GetNames(typeof(EScreen))[i]);
|
||||
_Screens[i].Init();
|
||||
_Screens[i].LoadTheme(CThemes.GetThemeScreensPath(_Screens[i].PartyModeID));
|
||||
CLog.StopBenchmark("Load Theme " + Enum.GetNames(typeof(EScreen))[i]);
|
||||
using (CBenchmark.Time("Load Theme " + Enum.GetNames(typeof(EScreen))[i]))
|
||||
{
|
||||
_Screens[i].Init();
|
||||
_Screens[i].LoadTheme(CThemes.GetThemeScreensPath(_Screens[i].PartyModeID));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (IMenu popup in _PopupScreens)
|
||||
@@ -438,6 +439,11 @@ namespace Vocaluxe.Base
|
||||
HidePopup(EPopupScreens.PopupServerQR);
|
||||
}
|
||||
|
||||
if (keyEvent.Key == Keys.F8)
|
||||
{
|
||||
CLog.ShowLogAssistant("", null);
|
||||
}
|
||||
|
||||
if (popupPlayerControlAllowed && keyEvent.Key == Keys.Tab)
|
||||
{
|
||||
if (_CurrentPopupScreen == EPopupScreens.NoPopup && CConfig.Config.Sound.BackgroundMusic == EBackgroundMusicOffOn.TR_CONFIG_ON)
|
||||
|
||||
@@ -20,6 +20,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Log;
|
||||
using VocaluxeLib.Xml;
|
||||
|
||||
namespace Vocaluxe.Base
|
||||
@@ -170,7 +171,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error reading language file " + filePath + ": " + e.Message);
|
||||
CLog.Error("Error reading language file " + filePath + ": " + e.Message);
|
||||
texts = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,225 +0,0 @@
|
||||
#region license
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Vocaluxe.Base
|
||||
{
|
||||
class CLogFile : IDisposable
|
||||
{
|
||||
private readonly string _LogFileName;
|
||||
private readonly string _LogName;
|
||||
private StreamWriter _LogFile;
|
||||
private readonly Object _FileMutex = new Object();
|
||||
|
||||
public CLogFile(string fileName, string logName)
|
||||
{
|
||||
_LogName = logName;
|
||||
_LogFileName = fileName;
|
||||
}
|
||||
|
||||
private void _Open()
|
||||
{
|
||||
lock (_FileMutex)
|
||||
{
|
||||
if (_LogFile != null)
|
||||
return;
|
||||
_LogFile = new StreamWriter(Path.Combine(CSettings.DataFolder, _LogFileName), false, Encoding.UTF8);
|
||||
|
||||
_LogFile.WriteLine(_LogName + " " + CSettings.GetFullVersionText() + " " + DateTime.Now);
|
||||
_LogFile.WriteLine("----------------------------------------");
|
||||
_LogFile.WriteLine();
|
||||
}
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
lock (_FileMutex)
|
||||
{
|
||||
if (_LogFile == null)
|
||||
return;
|
||||
try
|
||||
{
|
||||
_LogFile.Flush();
|
||||
_LogFile.Close();
|
||||
}
|
||||
catch (Exception) {}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Add(string text)
|
||||
{
|
||||
if (_LogFile == null)
|
||||
_Open();
|
||||
|
||||
// ReSharper disable PossibleNullReferenceException
|
||||
_LogFile.WriteLine(text);
|
||||
// ReSharper restore PossibleNullReferenceException
|
||||
_LogFile.Flush();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Close();
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
||||
class CErrorLogFile : CLogFile
|
||||
{
|
||||
private int _NumErrors;
|
||||
private readonly Object _WriteMutex = new Object();
|
||||
|
||||
public CErrorLogFile(string fileName, string logName) : base(fileName, logName) {}
|
||||
|
||||
public override void Add(string errorText)
|
||||
{
|
||||
lock (_WriteMutex)
|
||||
{
|
||||
_NumErrors++;
|
||||
base.Add(_NumErrors + ") " + errorText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class CLog
|
||||
{
|
||||
private const int _MaxBenchmarks = 10;
|
||||
private static int _BenchmarksRunning;
|
||||
private static bool _Initialized;
|
||||
|
||||
private static CLogFile _ErrorLog;
|
||||
private static CLogFile _PerformanceLog;
|
||||
private static CLogFile _BenchmarkLog;
|
||||
private static CLogFile _DebugLog;
|
||||
private static CLogFile _SongInfoLog;
|
||||
|
||||
private static Stopwatch[] _BenchmarkTimer;
|
||||
private static readonly double _NanosecPerTick = (1000.0 * 1000.0 * 1000.0) / Stopwatch.Frequency;
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
_ErrorLog = new CErrorLogFile(CSettings.FileNameErrorLog, "Error-Log");
|
||||
_PerformanceLog = new CLogFile(CSettings.FileNamePerformanceLog, "Performance-Log");
|
||||
_BenchmarkLog = new CLogFile(CSettings.FileNameBenchmarkLog, "Benchmark-Log");
|
||||
_DebugLog = new CLogFile(CSettings.FileNameDebugLog, "Debug-Log");
|
||||
_SongInfoLog = new CLogFile(CSettings.FileNameSongInfoLog, "Song-Information-Log");
|
||||
|
||||
_BenchmarkTimer = new Stopwatch[_MaxBenchmarks];
|
||||
for (int i = 0; i < _BenchmarkTimer.Length; i++)
|
||||
_BenchmarkTimer[i] = new Stopwatch();
|
||||
_BenchmarksRunning = 0;
|
||||
_Initialized = true;
|
||||
}
|
||||
|
||||
public static void Close()
|
||||
{
|
||||
if (_Initialized)
|
||||
{
|
||||
_ErrorLog.Dispose();
|
||||
_ErrorLog = null;
|
||||
_PerformanceLog.Dispose();
|
||||
_PerformanceLog = null;
|
||||
_BenchmarkLog.Dispose();
|
||||
_BenchmarkLog = null;
|
||||
_DebugLog.Dispose();
|
||||
_DebugLog = null;
|
||||
_SongInfoLog.Dispose();
|
||||
_SongInfoLog = null;
|
||||
_Initialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
#region LogError
|
||||
public static void LogError(string errorText, bool show = false, bool exit = false, Exception e = null)
|
||||
{
|
||||
if (show)
|
||||
MessageBox.Show(errorText, CSettings.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
if (e != null)
|
||||
errorText += ": " + e;
|
||||
_ErrorLog.Add(errorText);
|
||||
if (exit)
|
||||
Environment.Exit(Environment.ExitCode);
|
||||
}
|
||||
#endregion LogError
|
||||
|
||||
public static void LogDebug(string text)
|
||||
{
|
||||
_DebugLog.Add(String.Format("{0:HH:mm:ss.ffff}", DateTime.Now) + ":" + text);
|
||||
#if DEBUG
|
||||
Console.WriteLine(text);
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void LogSongInfo(string text)
|
||||
{
|
||||
_SongInfoLog.Add(text);
|
||||
}
|
||||
|
||||
public static void LogPerformance(string text)
|
||||
{
|
||||
_PerformanceLog.Add(text);
|
||||
_PerformanceLog.Add("-------------------------------");
|
||||
}
|
||||
|
||||
#region LogBenchmark
|
||||
public static void StartBenchmark(string text)
|
||||
{
|
||||
if (_BenchmarksRunning < _MaxBenchmarks)
|
||||
{
|
||||
string space = String.Empty;
|
||||
for (int i = 0; i < _BenchmarksRunning; i++)
|
||||
space += " ";
|
||||
_BenchmarkLog.Add(space + "Start " + text);
|
||||
|
||||
_BenchmarkTimer[_BenchmarksRunning].Restart();
|
||||
}
|
||||
else
|
||||
LogError("Tried to start to many benchmarks at once"); //Log and ignore
|
||||
_BenchmarksRunning++; //Inc even if not started to correct right Stop() call
|
||||
}
|
||||
|
||||
public static void StopBenchmark(string text)
|
||||
{
|
||||
if (_BenchmarksRunning > 0 && _BenchmarksRunning <= _MaxBenchmarks)
|
||||
{
|
||||
_BenchmarksRunning--;
|
||||
_BenchmarkTimer[_BenchmarksRunning].Stop();
|
||||
|
||||
string space = String.Empty;
|
||||
for (int i = 0; i < _BenchmarksRunning; i++)
|
||||
space += " ";
|
||||
|
||||
float ms;
|
||||
if (Stopwatch.IsHighResolution && _NanosecPerTick > 0)
|
||||
ms = (float)((_NanosecPerTick * _BenchmarkTimer[_BenchmarksRunning].ElapsedTicks) / (1000.0 * 1000.0));
|
||||
else
|
||||
ms = _BenchmarkTimer[_BenchmarksRunning].ElapsedMilliseconds;
|
||||
|
||||
_BenchmarkLog.Add(space + "Stop " + text + ", Elapsed Time: " + ms.ToString("0.000") + "ms");
|
||||
_BenchmarkLog.Add(String.Empty);
|
||||
}
|
||||
else
|
||||
_BenchmarksRunning--;
|
||||
}
|
||||
#endregion LogBenchmark
|
||||
}
|
||||
}
|
||||
+6
-23
@@ -19,11 +19,13 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Drawing;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Vocaluxe.Base.Fonts;
|
||||
using Vocaluxe.Base.ThemeSystem;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Game;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Log;
|
||||
using VocaluxeLib.Menu;
|
||||
using VocaluxeLib.Songs;
|
||||
using VocaluxeLib.Profile;
|
||||
@@ -38,7 +40,6 @@ namespace Vocaluxe.Base
|
||||
private static readonly IBackgroundMusic _BackgroundMusic = new CBbackgroundMusic();
|
||||
private static readonly IDrawing _Draw = new CBdraw();
|
||||
private static readonly IGraphics _Graphics = new CBGraphics();
|
||||
private static readonly ILog _Log = new CBlog();
|
||||
private static readonly IFonts _Fonts = new CBfonts();
|
||||
private static readonly ILanguage _Language = new CBlanguage();
|
||||
private static readonly IGame _Game = new CBGame();
|
||||
@@ -54,7 +55,7 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
CBase.Assign(_Config, _Settings, _Themes, _Log, _BackgroundMusic, _Draw, _Graphics, _Fonts, _Language,
|
||||
CBase.Assign(_Config, _Settings, _Themes, _BackgroundMusic, _Draw, _Graphics, _Fonts, _Language,
|
||||
_Game, _Profiles, _Record, _Songs, _Video, _Sound, _Cover, _DataBase, _Controller, _Playlist);
|
||||
}
|
||||
}
|
||||
@@ -507,24 +508,6 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
}
|
||||
|
||||
class CBlog : ILog
|
||||
{
|
||||
public void LogError(string errorText, bool showMsg = false, bool exit = false)
|
||||
{
|
||||
CLog.LogError(errorText, showMsg, exit);
|
||||
}
|
||||
|
||||
public void LogDebug(string text)
|
||||
{
|
||||
CLog.LogDebug(text);
|
||||
}
|
||||
|
||||
public void LogSongInfo(string text)
|
||||
{
|
||||
CLog.LogSongInfo(text);
|
||||
}
|
||||
}
|
||||
|
||||
class CBfonts : IFonts
|
||||
{
|
||||
public RectangleF GetTextBounds(CText text)
|
||||
@@ -848,7 +831,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
catch (NotSupportedException e)
|
||||
{
|
||||
CLog.LogError($"Clould not close the background video: {e.Message}");
|
||||
CLog.Error($"Clould not close the background video: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -865,7 +848,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
catch (NotSupportedException e)
|
||||
{
|
||||
CLog.LogError($"Clould not pause the background video: {e.Message}");
|
||||
CLog.Error($"Clould not pause the background video: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -877,7 +860,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
catch (NotSupportedException e)
|
||||
{
|
||||
CLog.LogError($"Clould not resume the background video: {e.Message}");
|
||||
CLog.Error($"Clould not resume the background video: {e.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+10
-9
@@ -23,6 +23,7 @@ using System.IO;
|
||||
using System.Reflection;
|
||||
using Vocaluxe.Base.ThemeSystem;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Log;
|
||||
using VocaluxeLib.Menu;
|
||||
using VocaluxeLib.PartyModes;
|
||||
using VocaluxeLib.Xml;
|
||||
@@ -74,7 +75,7 @@ namespace Vocaluxe.Base
|
||||
_CurrentPartyMode = pm;
|
||||
else
|
||||
{
|
||||
CLog.LogError("Could not init PartyMode \"" + _PartyModes[value].Info.Name + "\"! Removing...", true);
|
||||
CLog.Error("Could not init PartyMode \"" + _PartyModes[value].Info.Name + "\"! Removing...", true);
|
||||
_PartyModes.Remove(value);
|
||||
}
|
||||
}
|
||||
@@ -212,7 +213,7 @@ namespace Vocaluxe.Base
|
||||
catch (Exception e)
|
||||
{
|
||||
pm = new SPartyMode();
|
||||
CLog.LogError("Error loading PartyMode file " + filePath + ": " + e.Message);
|
||||
CLog.Error("Error loading PartyMode file " + filePath + ": " + e.Message);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -230,7 +231,7 @@ namespace Vocaluxe.Base
|
||||
BindingFlags.Public | BindingFlags.Instance, null, new object[] {_NextID++}, null, null);
|
||||
if (instance == null)
|
||||
{
|
||||
CLog.LogError("Error creating Instance of PartyMode file: " + filePath);
|
||||
CLog.Error("Error creating Instance of PartyMode file: " + filePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -240,13 +241,13 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error casting PartyMode file: " + filePath + "; " + e.Message);
|
||||
CLog.Error("Error casting PartyMode file: " + filePath + "; " + e.Message);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CLanguage.LoadPartyLanguageFiles(pm.PartyMode.ID, Path.Combine(pathToPm, CSettings.FolderNamePartyModeLanguages)))
|
||||
{
|
||||
CLog.LogError("Error loading language files for PartyMode: " + filePath);
|
||||
CLog.Error("Error loading language files for PartyMode: " + filePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -299,14 +300,14 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error Compiling Source (" + CHelper.ListStrings(files) + "): " + e.Message);
|
||||
CLog.Error("Error Compiling Source (" + CHelper.ListStrings(files) + "): " + e.Message);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (compileResult.Errors.Count > 0)
|
||||
{
|
||||
foreach (CompilerError e in compileResult.Errors)
|
||||
CLog.LogError("Error Compiling Source (" + CHelper.ListStrings(files) + "): " + e.ErrorText + " in '" + e.FileName + "' (" + e.Line + ")");
|
||||
CLog.Error("Error Compiling Source (" + CHelper.ListStrings(files) + "): " + e.ErrorText + " in '" + e.FileName + "' (" + e.Line + ")");
|
||||
return null;
|
||||
}
|
||||
return compileResult.CompiledAssembly;
|
||||
@@ -321,7 +322,7 @@ namespace Vocaluxe.Base
|
||||
object instance = assembly.CreateInstance(typeof(IPartyMode).Namespace + "." + partyModeName + "." + screenName);
|
||||
if (instance == null)
|
||||
{
|
||||
CLog.LogError("Error creating Instance of PartyScreen: " + screenName);
|
||||
CLog.Error("Error creating Instance of PartyScreen: " + screenName);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -332,7 +333,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error casting PartyScreen: " + screenName + "; " + e.Message);
|
||||
CLog.Error("Error casting PartyScreen: " + screenName + "; " + e.Message);
|
||||
return null;
|
||||
}
|
||||
return screen;
|
||||
|
||||
@@ -23,6 +23,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using Vocaluxe.Lib.Playlist;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Log;
|
||||
using VocaluxeLib.Menu;
|
||||
using VocaluxeLib.Songs;
|
||||
|
||||
@@ -120,7 +121,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CLog.LogError("Can't delete Playlist File " + _Playlists[playlistID].File + ".xml");
|
||||
CLog.Error("Can't delete Playlist File " + _Playlists[playlistID].File + ".xml");
|
||||
}
|
||||
}
|
||||
_Playlists.Remove(pl);
|
||||
@@ -256,7 +257,7 @@ namespace Vocaluxe.Base
|
||||
if (plSong != null)
|
||||
pl.AddSong(plSong.ID);
|
||||
else
|
||||
CLog.LogError("Can't find song '" + title + "' from '" + artist + "' in playlist file: " + file);
|
||||
CLog.Error("Can't find song '" + title + "' from '" + artist + "' in playlist file: " + file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Log;
|
||||
using VocaluxeLib.Profile;
|
||||
|
||||
namespace Vocaluxe.Base
|
||||
@@ -625,7 +626,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CLog.LogError("Can't delete Profile File " + _Profiles[profileID].FilePath);
|
||||
CLog.Error("Can't delete Profile File " + _Profiles[profileID].FilePath);
|
||||
}
|
||||
_ProfilesChanged = true;
|
||||
}
|
||||
|
||||
+19
-11
@@ -23,6 +23,7 @@ using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Log;
|
||||
using VocaluxeLib.Xml;
|
||||
|
||||
namespace Vocaluxe.Base
|
||||
@@ -62,15 +63,15 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Version.ToLower().Contains("alpha"))
|
||||
if (Version.ToLower().Contains("alpha"))
|
||||
{
|
||||
return ERevision.Alpha;
|
||||
}
|
||||
if (_Version.ToLower().Contains("beta"))
|
||||
if (Version.ToLower().Contains("beta"))
|
||||
{
|
||||
return ERevision.Beta;
|
||||
}
|
||||
if (_Version.ToLower().Contains("rc"))
|
||||
if (Version.ToLower().Contains("rc"))
|
||||
{
|
||||
return ERevision.RC;
|
||||
}
|
||||
@@ -111,12 +112,10 @@ namespace Vocaluxe.Base
|
||||
public const string FileNameOldHighscoreDB = "Ultrastar.db";
|
||||
public const string FileNameCoverDB = "CoverDB.sqlite";
|
||||
public const string FileNameCreditsRessourcesDB = "CreditsRessourcesDB.sqlite";
|
||||
|
||||
public const string FileNamePerformanceLog = "Performance.log";
|
||||
public const string FileNameErrorLog = "Error.log";
|
||||
public const string FileNameBenchmarkLog = "Benchmark.log";
|
||||
public const string FileNameDebugLog = "Debug.log";
|
||||
public const string FileNameSongInfoLog = "SongInformation.log";
|
||||
|
||||
public const string FileNameMainLog = "Vocaluxe.log";
|
||||
public const string FileNameSongLog = "Song.log";
|
||||
public const string FileNameCrashMarker = "Marker";
|
||||
|
||||
public const string FileNameRequiredSkinElements = "RequiredSkinElements.xml";
|
||||
|
||||
@@ -135,6 +134,7 @@ namespace Vocaluxe.Base
|
||||
public const string FolderNameLanguages = "Languages";
|
||||
public const string FolderNameScreenshots = "Screenshots";
|
||||
public const string FolderNameBackgroundMusic = "BackgroundMusic";
|
||||
public const string FolderNameLogs = "Logs";
|
||||
|
||||
public const string FolderNamePartyModes = "PartyModes";
|
||||
public const string FolderNamePartyModeCode = "Code";
|
||||
@@ -195,13 +195,21 @@ namespace Vocaluxe.Base
|
||||
get { return _Assembly.Name; }
|
||||
}
|
||||
|
||||
private static string _Version
|
||||
public static string Version
|
||||
{
|
||||
get
|
||||
{
|
||||
return Application.ProductVersion.Split('-').First();
|
||||
}
|
||||
}
|
||||
|
||||
public static string FullVersion
|
||||
{
|
||||
get
|
||||
{
|
||||
return Application.ProductVersion;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetFullVersionText()
|
||||
{
|
||||
@@ -241,7 +249,7 @@ namespace Vocaluxe.Base
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Cannot create directory \"" + path + "\": " + e.Message);
|
||||
CLog.Error("Cannot create directory \"" + path + "\": " + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+66
-56
@@ -23,6 +23,7 @@ using System.Threading;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Log;
|
||||
using VocaluxeLib.Songs;
|
||||
|
||||
namespace Vocaluxe.Base
|
||||
@@ -333,54 +334,61 @@ namespace Vocaluxe.Base
|
||||
|
||||
public static void LoadSongs()
|
||||
{
|
||||
CLog.StartBenchmark("Load Songs");
|
||||
SongsLoaded = false;
|
||||
_Songs.Clear();
|
||||
|
||||
CLog.StartBenchmark("List Songs");
|
||||
var files = new List<string>();
|
||||
foreach (string p in CConfig.SongFolders)
|
||||
using (CBenchmark.Time("Load Songs"))
|
||||
{
|
||||
if (Directory.Exists(p))
|
||||
SongsLoaded = false;
|
||||
_Songs.Clear();
|
||||
|
||||
var files = new List<string>();
|
||||
|
||||
using (CBenchmark.Time("List Songs"))
|
||||
{
|
||||
string path = p;
|
||||
files.AddRange(CHelper.ListFiles(path, "*.txt", true, true));
|
||||
files.AddRange(CHelper.ListFiles(path, "*.txd", true, true));
|
||||
|
||||
foreach (string p in CConfig.SongFolders)
|
||||
{
|
||||
if (Directory.Exists(p))
|
||||
{
|
||||
string path = p;
|
||||
files.AddRange(CHelper.ListFiles(path, "*.txt", true, true));
|
||||
files.AddRange(CHelper.ListFiles(path, "*.txd", true, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using (CBenchmark.Time("Read TXTs"))
|
||||
{
|
||||
foreach (string file in files)
|
||||
{
|
||||
CSong song = CSong.LoadSong(file);
|
||||
if (song == null)
|
||||
continue;
|
||||
song.ID = _Songs.Count;
|
||||
if (song.LoadNotes())
|
||||
_Songs.Add(song);
|
||||
}
|
||||
}
|
||||
|
||||
using (CBenchmark.Time("Sorted Songs"))
|
||||
{
|
||||
Sorter.SongSorting = CConfig.Config.Game.SongSorting;
|
||||
Sorter.IgnoreArticles = CConfig.Config.Game.IgnoreArticles;
|
||||
Categorizer.Tabs = CConfig.Config.Game.Tabs;
|
||||
Categorizer.ObjectChanged += _HandleCategoriesChanged;
|
||||
}
|
||||
|
||||
Category = -1;
|
||||
SongsLoaded = true;
|
||||
|
||||
switch (CConfig.Config.Theme.CoverLoading)
|
||||
{
|
||||
case ECoverLoading.TR_CONFIG_COVERLOADING_ATSTART:
|
||||
_LoadCovers();
|
||||
break;
|
||||
case ECoverLoading.TR_CONFIG_COVERLOADING_DYNAMIC:
|
||||
_LoadCoversAsync();
|
||||
break;
|
||||
}
|
||||
}
|
||||
CLog.StopBenchmark("List Songs");
|
||||
|
||||
CLog.StartBenchmark("Read TXTs");
|
||||
foreach (string file in files)
|
||||
{
|
||||
CSong song = CSong.LoadSong(file);
|
||||
if (song == null)
|
||||
continue;
|
||||
song.ID = _Songs.Count;
|
||||
if (song.LoadNotes())
|
||||
_Songs.Add(song);
|
||||
}
|
||||
CLog.StopBenchmark("Read TXTs");
|
||||
|
||||
CLog.StartBenchmark("Sort Songs");
|
||||
Sorter.SongSorting = CConfig.Config.Game.SongSorting;
|
||||
Sorter.IgnoreArticles = CConfig.Config.Game.IgnoreArticles;
|
||||
Categorizer.Tabs = CConfig.Config.Game.Tabs;
|
||||
Categorizer.ObjectChanged += _HandleCategoriesChanged;
|
||||
CLog.StopBenchmark("Sort Songs");
|
||||
Category = -1;
|
||||
SongsLoaded = true;
|
||||
|
||||
switch (CConfig.Config.Theme.CoverLoading)
|
||||
{
|
||||
case ECoverLoading.TR_CONFIG_COVERLOADING_ATSTART:
|
||||
_LoadCovers();
|
||||
break;
|
||||
case ECoverLoading.TR_CONFIG_COVERLOADING_DYNAMIC:
|
||||
_LoadCoversAsync();
|
||||
break;
|
||||
}
|
||||
CLog.StopBenchmark("Load Songs");
|
||||
}
|
||||
|
||||
private static void _LoadCoversAsync()
|
||||
@@ -396,25 +404,27 @@ namespace Vocaluxe.Base
|
||||
|
||||
private static void _LoadCovers()
|
||||
{
|
||||
CLog.StartBenchmark("Load Covers");
|
||||
int songCount = _Songs.Count;
|
||||
AutoResetEvent ev = new AutoResetEvent(songCount == 0);
|
||||
|
||||
NumSongsWithCoverLoaded = 0;
|
||||
foreach (CSong song in _Songs)
|
||||
using (CBenchmark.Time("Loaded Covers"))
|
||||
{
|
||||
CSong tmp = song;
|
||||
Task.Factory.StartNew(() =>
|
||||
int songCount = _Songs.Count;
|
||||
AutoResetEvent ev = new AutoResetEvent(songCount == 0);
|
||||
|
||||
NumSongsWithCoverLoaded = 0;
|
||||
foreach (CSong song in _Songs)
|
||||
{
|
||||
CSong tmp = song;
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
tmp.LoadSmallCover();
|
||||
if (Interlocked.Increment(ref _NumSongsWithCoverLoaded) >= songCount)
|
||||
ev.Set();
|
||||
});
|
||||
}
|
||||
|
||||
ev.WaitOne();
|
||||
_CoverLoaded = true;
|
||||
CDataBase.CommitCovers();
|
||||
}
|
||||
ev.WaitOne();
|
||||
_CoverLoaded = true;
|
||||
CDataBase.CommitCovers();
|
||||
CLog.StopBenchmark("Load Covers");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ using System.Drawing;
|
||||
using System.Drawing.Text;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Base.Fonts
|
||||
{
|
||||
@@ -93,7 +94,7 @@ namespace Vocaluxe.Base.Fonts
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error opening font file " + _FilePath + ": " + e.Message);
|
||||
CLog.Error("Error opening font file " + _FilePath + ": " + e.Message);
|
||||
}
|
||||
}
|
||||
return new Font(_Family, height, _GetSystemFontStyle(), GraphicsUnit.Pixel);
|
||||
|
||||
@@ -22,6 +22,7 @@ using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Log;
|
||||
using VocaluxeLib.Menu;
|
||||
using VocaluxeLib.Xml;
|
||||
|
||||
@@ -213,14 +214,14 @@ namespace Vocaluxe.Base.Fonts
|
||||
if (!_LoggedMissingFonts.Contains(fontName))
|
||||
{
|
||||
_LoggedMissingFonts.Add(fontName);
|
||||
CLog.LogError("Font \"" + fontName + "\" not found!");
|
||||
CLog.Error("Font \"" + fontName + "\" not found!");
|
||||
}
|
||||
}
|
||||
else
|
||||
CLog.LogError("Empty fontName requested", false, false, new Exception());
|
||||
CLog.Error("Empty fontName requested");
|
||||
|
||||
if (_FontFamilies.Count == 0)
|
||||
CLog.LogError("No fonts found!", true, true);
|
||||
CLog.Fatal("No fonts found!");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -265,7 +266,7 @@ namespace Vocaluxe.Base.Fonts
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error loading default Fonts", false, false, e);
|
||||
CLog.Error(e, "Error loading default Fonts");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -283,13 +284,16 @@ namespace Vocaluxe.Base.Fonts
|
||||
{
|
||||
if (!_LoadFont(fontFamily, fontFolder, themeName, partyModeId))
|
||||
{
|
||||
CLog.LogError("Error loading fonts for Theme " + themeName + "(" + partyModeId + ")");
|
||||
CLog.Error("Error loading fonts for Theme " + themeName + "(" + partyModeId + ")");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
CLog.StartBenchmark("BuildGlyphs");
|
||||
_BuildGlyphs();
|
||||
CLog.StopBenchmark("BuildGlyphs");
|
||||
|
||||
using (CBenchmark.Time("Build Glyphs"))
|
||||
{
|
||||
_BuildGlyphs();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Base.ThemeSystem
|
||||
{
|
||||
@@ -52,7 +53,7 @@ namespace Vocaluxe.Base.ThemeSystem
|
||||
msg += Environment.NewLine + "Videos: " + String.Join(", ", missingVideos);
|
||||
if (missingColors.Count > 0)
|
||||
msg += Environment.NewLine + "Colors: " + String.Join(", ", missingColors);
|
||||
CLog.LogError(msg);
|
||||
CLog.Error(msg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Vocaluxe.Base.Fonts;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Base.ThemeSystem
|
||||
{
|
||||
@@ -64,7 +65,7 @@ namespace Vocaluxe.Base.ThemeSystem
|
||||
if (skin.Load())
|
||||
break;
|
||||
skin.Unload();
|
||||
CLog.LogError("Failed to load skin " + skin + "! Removing...", true);
|
||||
CLog.Error("Failed to load skin " + skin + "! Removing...", true);
|
||||
_Skins.Remove(skin.Name);
|
||||
skin = _Skins.Values.FirstOrDefault();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Base.ThemeSystem
|
||||
{
|
||||
@@ -35,7 +36,7 @@ namespace Vocaluxe.Base.ThemeSystem
|
||||
{
|
||||
if (!_Data.Colors.ContainsKey("Player" + i))
|
||||
continue;
|
||||
CLog.LogDebug("Party themes cannot contain player colors. They will be ignored!");
|
||||
CLog.Debug("Party themes cannot contain player colors. They will be ignored!");
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
@@ -44,21 +45,21 @@ namespace Vocaluxe.Base.ThemeSystem
|
||||
public override bool GetColor(string name, out SColorF color)
|
||||
{
|
||||
if (_Parent.Name == "Default" && !_Required.Colors.Contains(name))
|
||||
CLog.LogDebug("Non-Default color: " + name);
|
||||
CLog.Debug("Non-Default color: " + name);
|
||||
return base.GetColor(name, out color) || _BaseSkin.GetColor(name, out color);
|
||||
}
|
||||
|
||||
public override CVideoStream GetVideo(string name, bool loop)
|
||||
{
|
||||
if (_Parent.Name == "Default" && !_Required.Videos.Contains(name))
|
||||
CLog.LogDebug("Non-Default color: " + name);
|
||||
CLog.Debug("Non-Default color: " + name);
|
||||
return base.GetVideo(name, loop) ?? _BaseSkin.GetVideo(name, loop);
|
||||
}
|
||||
|
||||
public override CTextureRef GetTexture(string name)
|
||||
{
|
||||
if (_Parent.Name == "Default" && !_Required.Textures.Contains(name))
|
||||
CLog.LogDebug("Non-Default color: " + name);
|
||||
CLog.Debug("Non-Default color: " + name);
|
||||
return base.GetTexture(name) ?? _BaseSkin.GetTexture(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Vocaluxe.Base.Fonts;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Base.ThemeSystem
|
||||
{
|
||||
@@ -73,7 +74,7 @@ namespace Vocaluxe.Base.ThemeSystem
|
||||
if (skin.Load())
|
||||
break;
|
||||
skin.Unload();
|
||||
CLog.LogError("Failed to load skin " + skin + "! Removing...", true);
|
||||
CLog.Error("Failed to load skin " + skin + "! Removing...", true);
|
||||
_Skins.Remove(skin.Name);
|
||||
}
|
||||
if (skin == null)
|
||||
|
||||
@@ -24,6 +24,7 @@ using VocaluxeLib;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Xml;
|
||||
using System.Linq;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Base.ThemeSystem
|
||||
{
|
||||
@@ -99,7 +100,7 @@ namespace Vocaluxe.Base.ThemeSystem
|
||||
}
|
||||
catch (CXmlException e)
|
||||
{
|
||||
CLog.LogError("Error reading required elements: " + e);
|
||||
CLog.Error("Error reading required elements: " + e);
|
||||
return false;
|
||||
}
|
||||
for (int i = 1; i <= CSettings.MaxNumPlayer; i++)
|
||||
@@ -147,7 +148,7 @@ namespace Vocaluxe.Base.ThemeSystem
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Can't load skin file \"" + Path.Combine(_Folder, _FileName) + "\". Invalid file!", false, false, e);
|
||||
CLog.Error(e, "Can't load skin file \"" + Path.Combine(_Folder, _FileName) + "\". Invalid file!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -166,7 +167,7 @@ namespace Vocaluxe.Base.ThemeSystem
|
||||
CTextureRef texture = CDraw.AddTexture(Path.Combine(_Folder, kvp.Value));
|
||||
if (texture == null)
|
||||
{
|
||||
CLog.LogError("Error on loading texture \"" + kvp.Key + "\": " + kvp.Value, true);
|
||||
CLog.Error("Error on loading texture \"" + kvp.Key + "\": " + kvp.Value, true);
|
||||
return false;
|
||||
}
|
||||
_Textures.Add(kvp.Key, texture);
|
||||
@@ -178,7 +179,7 @@ namespace Vocaluxe.Base.ThemeSystem
|
||||
CVideoSkinElement sk = new CVideoSkinElement {FileName = kvp.Value};
|
||||
if (!File.Exists(Path.Combine(_Folder, sk.FileName)))
|
||||
{
|
||||
CLog.LogError("Video \"" + kvp.Key + "\": (" + sk.FileName + ") not found!");
|
||||
CLog.Error("Video \"" + kvp.Key + "\": (" + sk.FileName + ") not found!");
|
||||
continue;
|
||||
}
|
||||
_Videos.Add(kvp.Key, sk);
|
||||
|
||||
@@ -21,6 +21,7 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Log;
|
||||
using VocaluxeLib.Xml;
|
||||
|
||||
namespace Vocaluxe.Base.ThemeSystem
|
||||
@@ -80,7 +81,7 @@ namespace Vocaluxe.Base.ThemeSystem
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Can't load theme \"" + _FileName + "\". Invalid file!", false, false, e);
|
||||
CLog.Error(e, "Can't load theme \"" + _FileName + "\". Invalid file!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ using System.Linq;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Draw;
|
||||
using System.Diagnostics;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Base.ThemeSystem
|
||||
{
|
||||
@@ -75,13 +76,13 @@ namespace Vocaluxe.Base.ThemeSystem
|
||||
if (theme.Load())
|
||||
break;
|
||||
theme.Unload();
|
||||
CLog.LogError("Failed to load theme " + theme + "! Removing...", true);
|
||||
CLog.Error("Failed to load theme {ThemeName}! Removing...", CLog.Params(theme.Name, theme), true);
|
||||
_Themes.Remove(theme);
|
||||
theme = _Themes.FirstOrDefault(th => th is CBaseTheme);
|
||||
}
|
||||
CurrentThemes.Add(-1, theme);
|
||||
if (theme == null)
|
||||
CLog.LogError("No themes found! Cannot continue!", true, true);
|
||||
CLog.Fatal("No themes found! Cannot continue!");
|
||||
else
|
||||
{
|
||||
CConfig.Config.Theme.Theme = theme.Name;
|
||||
@@ -104,7 +105,7 @@ namespace Vocaluxe.Base.ThemeSystem
|
||||
return true;
|
||||
}
|
||||
theme.Unload();
|
||||
CLog.LogError("Failed to load theme " + theme + " for partymode! Removing...", true);
|
||||
CLog.Error("Failed to load theme " + theme + " for partymode! Removing...", true);
|
||||
_Themes.Remove(theme);
|
||||
}
|
||||
theme = _Themes.First(th => th.PartyModeID == partyModeID && th.Name == CSettings.DefaultName);
|
||||
@@ -113,7 +114,7 @@ namespace Vocaluxe.Base.ThemeSystem
|
||||
CurrentThemes.Add(partyModeID, theme);
|
||||
return true;
|
||||
}
|
||||
CLog.LogError("Failed to load default theme for partymode! Unloading partymode!", true);
|
||||
CLog.Error("Failed to load default theme for partymode! Unloading partymode!", true);
|
||||
foreach (CPartyTheme th in _Themes.Where(th => th.PartyModeID == partyModeID))
|
||||
th.Unload();
|
||||
_Themes.RemoveAll(th => th.PartyModeID == partyModeID);
|
||||
@@ -149,12 +150,12 @@ namespace Vocaluxe.Base.ThemeSystem
|
||||
}
|
||||
if (newThemes.Count == 0)
|
||||
{
|
||||
CLog.LogError("No valid themes found in " + path);
|
||||
CLog.Error("No valid themes found in " + path);
|
||||
return false;
|
||||
}
|
||||
if (partyModeID >= 0 && newThemes.Count(th => th.Name == CSettings.DefaultName) == 0)
|
||||
{
|
||||
CLog.LogError("Partymode misses default theme in " + path);
|
||||
CLog.Error("Partymode misses default theme in " + path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -170,7 +171,7 @@ namespace Vocaluxe.Base.ThemeSystem
|
||||
|
||||
private static void _LogMissingElement(int partyModeID, string elType, string elName)
|
||||
{
|
||||
CLog.LogError("Skin " + CurrentThemes[partyModeID].CurrentSkin + " is missing the " + elType + " \"" + elName + "\"! Expect visual problems!");
|
||||
CLog.Error("Skin " + CurrentThemes[partyModeID].CurrentSkin + " is missing the " + elType + " \"" + elName + "\"! Expect visual problems!");
|
||||
}
|
||||
|
||||
public static CTextureRef GetSkinTexture(string textureName, int partyModeID)
|
||||
@@ -212,7 +213,7 @@ namespace Vocaluxe.Base.ThemeSystem
|
||||
{
|
||||
SColorF color;
|
||||
if (!GetColor("Player" + playerNr, -1, out color))
|
||||
CLog.LogError("Invalid color requested: Color for player " + playerNr + ". Expect visual problems!", true);
|
||||
CLog.Error("Invalid color requested: Color for player " + playerNr + ". Expect visual problems!", true);
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
+12
-14
@@ -21,6 +21,7 @@ using System.Reflection;
|
||||
using System.Security;
|
||||
using Microsoft.Win32;
|
||||
using Vocaluxe.Base;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe
|
||||
{
|
||||
@@ -118,30 +119,27 @@ namespace Vocaluxe
|
||||
#if WIN
|
||||
if (!_IsVC2010Installed())
|
||||
{
|
||||
CLog.LogError(
|
||||
"VC++ 2010 Redistributables are missing. Please install them first. \r\nDownload(x86): https://www.microsoft.com/de-de/download/details.aspx?id=5555 \r\nDownload(x64): https://www.microsoft.com/de-de/download/details.aspx?id=14632",
|
||||
true, true);
|
||||
CLog.Fatal(
|
||||
"VC++ 2010 Redistributables are missing. Please install them first. \r\nDownload(x86): https://www.microsoft.com/de-de/download/details.aspx?id=5555 \r\nDownload(x64): https://www.microsoft.com/de-de/download/details.aspx?id=14632");
|
||||
return false;
|
||||
}
|
||||
/*if (!_IsVC2012Installed())
|
||||
{
|
||||
CLog.LogError(
|
||||
"VC++ 2012 Redistributables are missing. Please install them first.\r\nDownload: http://www.microsoft.com/de-de/download/details.aspx?id=30679",
|
||||
true, true);
|
||||
return false;
|
||||
}*/
|
||||
/*
|
||||
if (!_IsVC2012Installed())
|
||||
{
|
||||
CLog.Fatal(
|
||||
"VC++ 2012 Redistributables are missing. Please install them first.\r\nDownload: http://www.microsoft.com/de-de/download/details.aspx?id=30679");
|
||||
return false;
|
||||
}
|
||||
bool vc2008Installed = _IsVC2008Installed();
|
||||
if (!vc2008Installed)
|
||||
{
|
||||
CLog.LogError(
|
||||
CLog.Fatal(
|
||||
"VC++ 2008 Redistributables are missing. Portaudio might not be working.\r\nDownload: http://www.microsoft.com/de-de/download/details.aspx?id=29");
|
||||
}
|
||||
if (!vc2008Installed && !_IsVC2010Installed())
|
||||
{
|
||||
CLog.LogError(
|
||||
"VC++ 2010 and 2008 Redistributables are missing. Please install them first. VC++ 2008 is preferred as Portaudio doesn't work with VC++ 2010.\r\nDownload(2008): http://www.microsoft.com/de-de/download/details.aspx?id=29 \r\nDownload(2010): http://www.microsoft.com/de-de/download/details.aspx?id=5555",
|
||||
true, true);
|
||||
CLog.Fatal(
|
||||
"VC++ 2010 and 2008 Redistributables are missing. Please install them first. VC++ 2008 is preferred as Portaudio doesn't work with VC++ 2010.\r\nDownload(2008): http://www.microsoft.com/de-de/download/details.aspx?id=29 \r\nDownload(2010): http://www.microsoft.com/de-de/download/details.aspx?id=5555");
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -20,6 +20,7 @@ using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using Vocaluxe.Base;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe
|
||||
{
|
||||
@@ -39,11 +40,11 @@ namespace Vocaluxe
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error loading logo: " + e.Message);
|
||||
CLog.Error("Error loading logo: " + e.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
CLog.LogError("Can't find " + path);
|
||||
CLog.Error("Can't find " + path);
|
||||
|
||||
path = Path.Combine(CSettings.ProgramFolder, CSettings.FileNameIcon);
|
||||
if (File.Exists(path))
|
||||
@@ -54,11 +55,11 @@ namespace Vocaluxe
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error loading icon: " + e.Message);
|
||||
CLog.Error("Error loading icon: " + e.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
CLog.LogError("Can't find " + path);
|
||||
CLog.Error("Can't find " + path);
|
||||
|
||||
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
|
||||
BackColor = Color.Transparent;
|
||||
|
||||
@@ -24,6 +24,7 @@ using System.Runtime.InteropServices;
|
||||
using Vocaluxe.Base;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Log;
|
||||
#if WIN
|
||||
using System.Data.SQLite;
|
||||
|
||||
@@ -74,7 +75,7 @@ namespace Vocaluxe.Lib.Database
|
||||
return false;
|
||||
if (!File.Exists(coverPath))
|
||||
{
|
||||
CLog.LogError("Can't find File: " + coverPath);
|
||||
CLog.Error("Can't find File: " + coverPath);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -230,7 +231,7 @@ namespace Vocaluxe.Lib.Database
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error creating Cover DB " + e);
|
||||
CLog.Error("Error creating Cover DB " + e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -23,6 +23,7 @@ using System.Text;
|
||||
using Community.CsharpSqlite;
|
||||
using Vocaluxe.Base;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Log;
|
||||
using VocaluxeLib.Songs;
|
||||
#if WIN
|
||||
using System.Data.SQLite;
|
||||
@@ -58,17 +59,17 @@ namespace Vocaluxe.Lib.Database
|
||||
{
|
||||
if (!_CreateOrConvert(oldDBFilePath))
|
||||
{
|
||||
CLog.LogError("Cannot init Highscore DB: Error opening database: " + oldDBFilePath, true, true);
|
||||
CLog.Fatal("Cannot init Highscore DB: Error opening old database: {DBFile}" + CLog.Params(oldDBFilePath));
|
||||
return false;
|
||||
}
|
||||
if (!_CreateOrConvert(_FilePath))
|
||||
{
|
||||
CLog.LogError("Cannot init Highscore DB: Error opening database: " + _FilePath, true, true);
|
||||
CLog.Fatal("Cannot init Highscore DB: Error opening database: {DBFile}", CLog.Params(_FilePath));
|
||||
return false;
|
||||
}
|
||||
if (!_ImportData(oldDBFilePath))
|
||||
{
|
||||
CLog.LogError("Cannot init Highscore DB: Error importing data", true, true);
|
||||
CLog.Fatal("Cannot init Highscore DB: Error importing data");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -77,7 +78,7 @@ namespace Vocaluxe.Lib.Database
|
||||
File.Copy(oldDBFilePath, _FilePath);
|
||||
if (!_CreateOrConvert(_FilePath))
|
||||
{
|
||||
CLog.LogError("Cannot init Highscore DB: Error opening database: " + _FilePath, true, true);
|
||||
CLog.Fatal("Cannot init Highscore DB: Error opening database: {DBFile}" + CLog.Params(_FilePath));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -85,7 +86,7 @@ namespace Vocaluxe.Lib.Database
|
||||
}
|
||||
else if (!_CreateOrConvert(_FilePath))
|
||||
{
|
||||
CLog.LogError("Cannot init Highscore DB: Error opening database: " + _FilePath, true, true);
|
||||
CLog.Fatal("Cannot init Highscore DB: Error opening database: {DBFile}", CLog.Params(_FilePath));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -827,14 +828,14 @@ namespace Vocaluxe.Lib.Database
|
||||
int res = Sqlite3.sqlite3_open(filePath, out oldDB);
|
||||
|
||||
if (res != Sqlite3.SQLITE_OK)
|
||||
CLog.LogError("Error opening Database: " + filePath + " (" + Sqlite3.sqlite3_errmsg(oldDB) + ")");
|
||||
CLog.Error("Error opening Database: " + filePath + " (" + Sqlite3.sqlite3_errmsg(oldDB) + ")");
|
||||
else
|
||||
{
|
||||
var stmt = new Sqlite3.Vdbe();
|
||||
res = Sqlite3.sqlite3_prepare_v2(oldDB, "SELECT id, Artist, Title FROM Songs", -1, ref stmt, 0);
|
||||
|
||||
if (res != Sqlite3.SQLITE_OK)
|
||||
CLog.LogError("Error query Database: " + filePath + " (" + Sqlite3.sqlite3_errmsg(oldDB) + ")");
|
||||
CLog.Error("Error query Database: " + filePath + " (" + Sqlite3.sqlite3_errmsg(oldDB) + ")");
|
||||
else
|
||||
{
|
||||
//Sqlite3.sqlite3_step(Stmt);
|
||||
@@ -866,7 +867,7 @@ namespace Vocaluxe.Lib.Database
|
||||
res = Sqlite3.sqlite3_prepare_v2(oldDB, "SELECT id, PlayerName, Date FROM Scores", -1, ref stmt, 0);
|
||||
|
||||
if (res != Sqlite3.SQLITE_OK)
|
||||
CLog.LogError("Error query Database: " + filePath + " (" + Sqlite3.sqlite3_errmsg(oldDB) + ")");
|
||||
CLog.Error("Error query Database: " + filePath + " (" + Sqlite3.sqlite3_errmsg(oldDB) + ")");
|
||||
else
|
||||
{
|
||||
//Sqlite3.sqlite3_step(Stmt);
|
||||
@@ -1022,7 +1023,7 @@ namespace Vocaluxe.Lib.Database
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error on import high score data. Can't open source database \"" + sourceDBPath + "\" (" + e.Message + ")");
|
||||
CLog.Error("Error on import high score data. Can't open source database \"" + sourceDBPath + "\" (" + e.Message + ")");
|
||||
return false;
|
||||
}
|
||||
#endregion open db
|
||||
|
||||
@@ -23,6 +23,7 @@ using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Vocaluxe.Base;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Log;
|
||||
#if WIN
|
||||
using System.Data.SQLite;
|
||||
|
||||
@@ -53,7 +54,7 @@ namespace Vocaluxe.Lib.Database
|
||||
return false;
|
||||
if (_Version < 0)
|
||||
{
|
||||
CLog.LogError("Can't find Ressource-DB!");
|
||||
CLog.Error("Can't find Ressource-DB!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -62,7 +63,7 @@ namespace Vocaluxe.Lib.Database
|
||||
#if DEBUG
|
||||
return _CreateDB() && _UpdateV1();
|
||||
#else
|
||||
CLog.LogError("Upgrading Ressource-DB not possible");
|
||||
CLog.Error("Upgrading Ressource-DB not possible");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
@@ -161,7 +162,7 @@ namespace Vocaluxe.Lib.Database
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CLog.LogError("Error loading image: " + imagePath);
|
||||
CLog.Error("Error loading image: " + imagePath);
|
||||
return false;
|
||||
}
|
||||
try
|
||||
@@ -247,7 +248,7 @@ namespace Vocaluxe.Lib.Database
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error creating Ressource DB " + e);
|
||||
CLog.Error("Error creating Ressource DB " + e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -28,6 +28,7 @@ using SlimDX.Windows;
|
||||
using Vocaluxe.Base;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Lib.Draw
|
||||
{
|
||||
@@ -94,7 +95,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
}
|
||||
catch (Direct3DX9NotFoundException e)
|
||||
{
|
||||
CLog.LogError("No DirectX runtimes were found, please download and install them from http://www.microsoft.com/download/en/details.aspx?id=8109", true, true, e);
|
||||
CLog.Error(e, "No DirectX runtimes were found, please download and install them from http://www.microsoft.com/download/en/details.aspx?id=8109");
|
||||
}
|
||||
|
||||
_Form.KeyDown += _OnKeyDown;
|
||||
@@ -149,7 +150,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
!_D3D.CheckDeviceMultisampleType(_D3D.Adapters.DefaultAdapter.Adapter, DeviceType.Hardware, _D3D.Adapters.DefaultAdapter.CurrentDisplayMode.Format, false, msType,
|
||||
out quality))
|
||||
{
|
||||
CLog.LogError("[Direct3D] This AAMode is not supported by this device or driver, fallback to no AA");
|
||||
CLog.Error("[Direct3D] This AAMode is not supported by this device or driver, fallback to no AA");
|
||||
msType = MultisampleType.None;
|
||||
quality = 1;
|
||||
}
|
||||
@@ -177,15 +178,14 @@ namespace Vocaluxe.Lib.Draw
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error during D3D device creation.", false, false, e);
|
||||
CLog.Error(e, "Error during D3D device creation.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (_Device == null || _Device.Disposed)
|
||||
{
|
||||
CLog.LogError(
|
||||
"Something went wrong during device creating, please check if your DirectX redistributables and grafic card drivers are up to date. You can download the DirectX runtimes at http://www.microsoft.com/download/en/details.aspx?id=8109",
|
||||
true, true);
|
||||
CLog.Fatal(
|
||||
"Something went wrong during device creating, please check if your DirectX redistributables and grafic card drivers are up to date. You can download the DirectX runtimes at http://www.microsoft.com/download/en/details.aspx?id=8109");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -278,40 +278,40 @@ namespace Vocaluxe.Lib.Draw
|
||||
VertexFormat.Position | VertexFormat.Texture1 | VertexFormat.Diffuse, Pool.Default);
|
||||
|
||||
if (_Device.SetStreamSource(0, _VertexBuffer, 0, Marshal.SizeOf(typeof(STexturedColoredVertex))).IsFailure)
|
||||
CLog.LogError("Failed to set stream source");
|
||||
CLog.Error("Failed to set stream source");
|
||||
_Device.VertexDeclaration = STexturedColoredVertex.GetDeclaration(_Device);
|
||||
|
||||
if (_Device.SetRenderState(RenderState.CullMode, Cull.None).IsFailure)
|
||||
CLog.LogError("Failed to set cull mode");
|
||||
CLog.Error("Failed to set cull mode");
|
||||
if (_Device.SetRenderState(RenderState.AlphaBlendEnable, true).IsFailure)
|
||||
CLog.LogError("Failed to enable alpha blending");
|
||||
CLog.Error("Failed to enable alpha blending");
|
||||
if (_Device.SetRenderState(RenderState.Lighting, false).IsFailure)
|
||||
CLog.LogError("Failed to disable lighting");
|
||||
CLog.Error("Failed to disable lighting");
|
||||
if (_Device.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha).IsFailure)
|
||||
CLog.LogError("Failed to set destination blend");
|
||||
CLog.Error("Failed to set destination blend");
|
||||
if (_Device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha).IsFailure)
|
||||
CLog.LogError("Failed to set source blend");
|
||||
CLog.Error("Failed to set source blend");
|
||||
if (_PresentParameters.Multisample != MultisampleType.None)
|
||||
{
|
||||
if (_Device.SetRenderState(RenderState.MultisampleAntialias, true).IsFailure)
|
||||
CLog.LogError("Failed to set antialiasing");
|
||||
CLog.Error("Failed to set antialiasing");
|
||||
}
|
||||
if (_Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear).IsFailure)
|
||||
CLog.LogError("Failed to set min filter");
|
||||
CLog.Error("Failed to set min filter");
|
||||
if (_Device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear).IsFailure)
|
||||
CLog.LogError("Failed to set mag filter");
|
||||
CLog.Error("Failed to set mag filter");
|
||||
if (_Device.SetSamplerState(0, SamplerState.MipFilter, TextureFilter.Linear).IsFailure)
|
||||
CLog.LogError("Failed to set mip filter");
|
||||
CLog.Error("Failed to set mip filter");
|
||||
if (_Device.SetSamplerState(0, SamplerState.AddressU, TextureAddress.Clamp).IsFailure)
|
||||
CLog.LogError("Failed to set clamping on u");
|
||||
CLog.Error("Failed to set clamping on u");
|
||||
if (_Device.SetSamplerState(0, SamplerState.AddressV, TextureAddress.Clamp).IsFailure)
|
||||
CLog.LogError("Failed to set claming on v");
|
||||
CLog.Error("Failed to set claming on v");
|
||||
if (_Device.SetTextureStageState(0, TextureStage.AlphaArg1, TextureArgument.Texture).IsFailure)
|
||||
CLog.LogError("Failed to set alpha argument 1");
|
||||
CLog.Error("Failed to set alpha argument 1");
|
||||
if (_Device.SetTextureStageState(0, TextureStage.AlphaArg2, TextureArgument.Diffuse).IsFailure)
|
||||
CLog.LogError("Failed to set alpha argument 2");
|
||||
CLog.Error("Failed to set alpha argument 2");
|
||||
if (_Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate).IsFailure)
|
||||
CLog.LogError("Failed to set alpha operation");
|
||||
CLog.Error("Failed to set alpha operation");
|
||||
|
||||
var indices = new Int16[6];
|
||||
indices[0] = 0;
|
||||
@@ -332,14 +332,14 @@ namespace Vocaluxe.Lib.Draw
|
||||
protected override void _OnBeforeDraw()
|
||||
{
|
||||
if (_Device.BeginScene().IsFailure)
|
||||
CLog.LogError("Failed to begin scene");
|
||||
CLog.Error("Failed to begin scene");
|
||||
}
|
||||
|
||||
protected override void _OnAfterDraw()
|
||||
{
|
||||
_RenderVertexBuffer();
|
||||
if (_Device.EndScene().IsFailure)
|
||||
CLog.LogError("Failed to end scene");
|
||||
CLog.Error("Failed to end scene");
|
||||
try
|
||||
{
|
||||
//Now push the frame to the Viewport
|
||||
@@ -370,7 +370,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
_VertexBuffer.Dispose();
|
||||
_IndexBuffer.Dispose();
|
||||
if (_Device.Reset(_PresentParameters).IsFailure)
|
||||
CLog.LogError("Failed to reset the device");
|
||||
CLog.Error("Failed to reset the device");
|
||||
}
|
||||
|
||||
protected override void _AdjustNewBorders()
|
||||
@@ -384,9 +384,9 @@ namespace Vocaluxe.Lib.Draw
|
||||
CSettings.ZNear, CSettings.ZFar);
|
||||
|
||||
if (_Device.SetTransform(TransformState.Projection, projection).IsFailure)
|
||||
CLog.LogError("Failed to set orthogonal matrix");
|
||||
CLog.Error("Failed to set orthogonal matrix");
|
||||
if (_Device.SetTransform(TransformState.World, translate).IsFailure)
|
||||
CLog.LogError("Failed to set translation matrix");
|
||||
CLog.Error("Failed to set translation matrix");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -491,13 +491,13 @@ namespace Vocaluxe.Lib.Draw
|
||||
{
|
||||
//Apply rotation
|
||||
if (_Device.SetTransform(TransformState.World, _VerticesRotationMatrices.Dequeue()).IsFailure)
|
||||
CLog.LogError("Failed to set world transformation");
|
||||
CLog.Error("Failed to set world transformation");
|
||||
//Apply texture
|
||||
if (_Device.SetTexture(0, _VerticesTextures.Dequeue()).IsFailure)
|
||||
CLog.LogError("Failed to set texture");
|
||||
CLog.Error("Failed to set texture");
|
||||
//Draw 2 triangles from vertexbuffer
|
||||
if (_Device.DrawIndexedPrimitives(PrimitiveType.TriangleList, i, 0, 4, 0, 2).IsFailure)
|
||||
CLog.LogError("Failed to draw quad");
|
||||
CLog.Error("Failed to draw quad");
|
||||
}
|
||||
//Clear the queues for the next frame
|
||||
_Vertices.Clear();
|
||||
@@ -512,7 +512,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
protected override void _ClearScreen()
|
||||
{
|
||||
if (_Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0).IsFailure)
|
||||
CLog.LogError("Failed to clear the backbuffer");
|
||||
CLog.Error("Failed to clear the backbuffer");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Vocaluxe.Base;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Lib.Input
|
||||
{
|
||||
@@ -73,7 +74,7 @@ namespace Vocaluxe.Lib.Input
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error CHIDAPI.Init(): " + e);
|
||||
CLog.Error("Error CHIDAPI.Init(): " + e);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -92,7 +93,7 @@ namespace Vocaluxe.Lib.Input
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error CHIDAPI.Exit(): " + e);
|
||||
CLog.Error("Error CHIDAPI.Exit(): " + e);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -129,7 +130,7 @@ namespace Vocaluxe.Lib.Input
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error CHIDAPI.Open(): " + e);
|
||||
CLog.Error("Error CHIDAPI.Open(): " + e);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -169,7 +170,7 @@ namespace Vocaluxe.Lib.Input
|
||||
catch (Exception e)
|
||||
{
|
||||
bytesRead = -1;
|
||||
CLog.LogError("Error CHIDAPI.ReadTimeout(): " + e);
|
||||
CLog.Error("Error CHIDAPI.ReadTimeout(): " + e);
|
||||
}
|
||||
|
||||
if (bytesRead != -1)
|
||||
@@ -198,7 +199,7 @@ namespace Vocaluxe.Lib.Input
|
||||
catch (Exception e)
|
||||
{
|
||||
result = -1;
|
||||
CLog.LogError("Error CHIDAPI.Read(): " + e);
|
||||
CLog.Error("Error CHIDAPI.Read(): " + e);
|
||||
}
|
||||
|
||||
if (result != -1)
|
||||
@@ -245,7 +246,7 @@ namespace Vocaluxe.Lib.Input
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error CHIDAPI.Close(): " + e);
|
||||
CLog.Error("Error CHIDAPI.Close(): " + e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -20,6 +20,7 @@ using System.Drawing;
|
||||
using System.Threading;
|
||||
using Vocaluxe.Base;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Lib.Input.WiiMote
|
||||
{
|
||||
@@ -213,8 +214,8 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
{
|
||||
if (!CHIDApi.Init())
|
||||
{
|
||||
CLog.LogError("WiiMoteLib: Can't initialize HID API");
|
||||
CLog.LogError("Please install the Visual C++ Redistributable Packages 2008!");
|
||||
CLog.Error("WiiMoteLib: Can't initialize HID API");
|
||||
CLog.Error("Please install the Visual C++ Redistributable Packages 2008!");
|
||||
|
||||
_Error = true;
|
||||
}
|
||||
@@ -353,7 +354,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("(WiiMoteLib) Error reading from device: " + e);
|
||||
CLog.Error("(WiiMoteLib) Error reading from device: " + e);
|
||||
Connected = false;
|
||||
break;
|
||||
}
|
||||
@@ -414,7 +415,7 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
break;
|
||||
|
||||
default:
|
||||
//CLog.LogError("(WiiMoteLib) Unknown report type: " + type.ToString("x"));
|
||||
//CLog.Error("(WiiMoteLib) Unknown report type: " + type.ToString("x"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -519,13 +520,13 @@ namespace Vocaluxe.Lib.Input.WiiMote
|
||||
{
|
||||
if ((buff[3] & 0x08) != 0)
|
||||
{
|
||||
CLog.LogError("Error reading data from WiiMote: Bytes do not exist");
|
||||
CLog.Error("Error reading data from WiiMote: Bytes do not exist");
|
||||
Connected = false;
|
||||
}
|
||||
|
||||
if ((buff[3] & 0x07) != 0)
|
||||
{
|
||||
CLog.LogError("Error reading data from WiiMote: Attempt to read from write-only registers.");
|
||||
CLog.Error("Error reading data from WiiMote: Attempt to read from write-only registers.");
|
||||
Connected = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using Vocaluxe.Base;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Log;
|
||||
using VocaluxeLib.Menu;
|
||||
using VocaluxeLib.Songs;
|
||||
using VocaluxeLib.Xml;
|
||||
@@ -77,7 +78,7 @@ namespace Vocaluxe.Lib.Playlist
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Cannot load playlist from " + file + ": " + e.Message);
|
||||
CLog.Error("Cannot load playlist from " + file + ": " + e.Message);
|
||||
return false;
|
||||
}
|
||||
Name = data.Info.Name;
|
||||
@@ -86,7 +87,7 @@ namespace Vocaluxe.Lib.Playlist
|
||||
{
|
||||
CSong plSong = CSongs.AllSongs.FirstOrDefault(song => song.Artist == songEntry.Artist && song.Title == songEntry.Title);
|
||||
if (plSong == null)
|
||||
CLog.LogError("Can't find song '" + songEntry.Title + "' from '" + songEntry.Artist + "' in playlist file: " + File);
|
||||
CLog.Error("Can't find song '" + songEntry.Title + "' from '" + songEntry.Artist + "' in playlist file: " + File);
|
||||
else
|
||||
{
|
||||
var playlistSong = new CPlaylistSong(plSong.ID, songEntry.GameMode);
|
||||
|
||||
@@ -20,6 +20,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using PortAudioSharp;
|
||||
using Vocaluxe.Base;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Lib.Sound
|
||||
{
|
||||
@@ -64,11 +65,11 @@ namespace Vocaluxe.Lib.Sound
|
||||
if (_Disposed)
|
||||
return;
|
||||
if (!disposing)
|
||||
CLog.LogDebug("Did not close CPortAudioHandle");
|
||||
CLog.Debug("Did not close CPortAudioHandle");
|
||||
//Make sure we do not leek any streams as we may keep PA open
|
||||
if (_Streams.Count > 0)
|
||||
{
|
||||
CLog.LogDebug("Did not close " + _Streams.Count + "PortAudio-Stream(s)");
|
||||
CLog.Debug("Did not close " + _Streams.Count + "PortAudio-Stream(s)");
|
||||
while (_Streams.Count > 0)
|
||||
CloseStream(_Streams[0]);
|
||||
}
|
||||
@@ -86,7 +87,7 @@ namespace Vocaluxe.Lib.Sound
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
CLog.LogError(errorText: $"Error disposing PortAudio: {ex.Message}", e: ex);
|
||||
CLog.Error(ex, "Error disposing PortAudio");
|
||||
}
|
||||
}
|
||||
_Disposed = true;
|
||||
@@ -179,7 +180,7 @@ namespace Vocaluxe.Lib.Sound
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
CLog.LogError(errorText:$"Error closing stream: {ex.Message}", e:ex);
|
||||
CLog.Error(ex, "Error closing stream:");
|
||||
}
|
||||
_Streams.Remove(stream);
|
||||
}
|
||||
@@ -199,13 +200,13 @@ namespace Vocaluxe.Lib.Sound
|
||||
|
||||
if (errorCode != PortAudio.PaError.paNoError)
|
||||
{
|
||||
CLog.LogError(action + " error: " + PortAudio.Pa_GetErrorText(errorCode));
|
||||
CLog.Error(action + " error: " + PortAudio.Pa_GetErrorText(errorCode));
|
||||
if (errorCode == PortAudio.PaError.paUnanticipatedHostError)
|
||||
{
|
||||
PortAudio.PaHostErrorInfo errorInfo = PortAudio.Pa_GetLastHostErrorInfo();
|
||||
CLog.LogError("- Host error API type: " + errorInfo.hostApiType);
|
||||
CLog.LogError("- Host error code: " + errorInfo.errorCode);
|
||||
CLog.LogError("- Host error text: " + errorInfo.errorText);
|
||||
CLog.Error("- Host error API type: " + errorInfo.hostApiType);
|
||||
CLog.Error("- Host error code: " + errorInfo.errorCode);
|
||||
CLog.Error("- Host error text: " + errorInfo.errorText);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
using System;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Lib.Sound.Playback
|
||||
{
|
||||
@@ -71,7 +72,7 @@ namespace Vocaluxe.Lib.Sound.Playback
|
||||
protected virtual void _Dispose(bool disposing)
|
||||
{
|
||||
if (!disposing)
|
||||
CBase.Log.LogDebug("Audio stream " + _Medium + " was not closed.");
|
||||
CLog.Debug("Audio stream " + _Medium + " was not closed.");
|
||||
}
|
||||
|
||||
public void Close()
|
||||
|
||||
@@ -19,6 +19,7 @@ using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using Vocaluxe.Base;
|
||||
using Vocaluxe.Lib.Video.Acinerella;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Lib.Sound.Playback.Decoder
|
||||
{
|
||||
@@ -46,7 +47,7 @@ namespace Vocaluxe.Lib.Sound.Playback.Decoder
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CLog.LogError("Error opening audio file: " + _FileName);
|
||||
CLog.Error("Error opening audio file: " + _FileName);
|
||||
Close();
|
||||
return false;
|
||||
}
|
||||
@@ -68,7 +69,7 @@ namespace Vocaluxe.Lib.Sound.Playback.Decoder
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CLog.LogError("Error opening audio file (can't find decoder): " + _FileName);
|
||||
CLog.Error("Error opening audio file (can't find decoder): " + _FileName);
|
||||
Close();
|
||||
return false;
|
||||
}
|
||||
@@ -90,7 +91,7 @@ namespace Vocaluxe.Lib.Sound.Playback.Decoder
|
||||
|
||||
if (_FormatInfo.BitDepth != 16)
|
||||
{
|
||||
CLog.LogError("Unsupported BitDepth in file " + fileName);
|
||||
CLog.Error("Unsupported BitDepth in file " + fileName);
|
||||
Close();
|
||||
return false;
|
||||
}
|
||||
@@ -136,7 +137,7 @@ namespace Vocaluxe.Lib.Sound.Playback.Decoder
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CLog.LogError("Error seeking in file: " + _FileName);
|
||||
CLog.Error("Error seeking in file: " + _FileName);
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ using Gst;
|
||||
using System;
|
||||
using Vocaluxe.Base;
|
||||
using System.IO;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Lib.Sound.Playback.GstreamerSharp
|
||||
{
|
||||
@@ -49,7 +50,7 @@ namespace Vocaluxe.Lib.Sound.Playback.GstreamerSharp
|
||||
|
||||
if (gstreamerEnvVar == null || !Directory.Exists(gstreamerEnvVar))
|
||||
{
|
||||
CLog.LogError("Gstreamer not found! Make sure you installed it correctly and if it set the environment variable '" + varName + "'!", true);
|
||||
CLog.Error("Gstreamer not found! Make sure you installed it correctly and if it set the environment variable '" + varName + "'!", true);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -20,6 +20,7 @@ using GLib;
|
||||
using Gst;
|
||||
using Vocaluxe.Base;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Lib.Sound.Playback.GstreamerSharp
|
||||
{
|
||||
@@ -79,7 +80,7 @@ namespace Vocaluxe.Lib.Sound.Playback.GstreamerSharp
|
||||
|
||||
long position;
|
||||
if (!_Element.QueryPosition(Format.Time, out position))
|
||||
CLog.LogError("Could not query position");
|
||||
CLog.Error("Could not query position");
|
||||
else
|
||||
_Position = ((float)position / Constants.SECOND);
|
||||
|
||||
@@ -121,7 +122,7 @@ namespace Vocaluxe.Lib.Sound.Playback.GstreamerSharp
|
||||
|
||||
if (convert == null || audiosink == null)
|
||||
{
|
||||
CLog.LogError("Could not create pipeline");
|
||||
CLog.Error("Could not create pipeline");
|
||||
if (convert != null)
|
||||
convert.Dispose();
|
||||
if (audiosink != null)
|
||||
@@ -158,7 +159,7 @@ namespace Vocaluxe.Lib.Sound.Playback.GstreamerSharp
|
||||
|
||||
if (pad == null)
|
||||
{
|
||||
CLog.LogError("Could not create pads");
|
||||
CLog.Error("Could not create pads");
|
||||
convert.Dispose();
|
||||
audiosink.Dispose();
|
||||
audioSinkBin.Dispose();
|
||||
@@ -171,7 +172,7 @@ namespace Vocaluxe.Lib.Sound.Playback.GstreamerSharp
|
||||
|
||||
if (!ghostpad.SetActive(true))
|
||||
{
|
||||
CLog.LogError("Could not link pads");
|
||||
CLog.Error("Could not link pads");
|
||||
convert.Dispose();
|
||||
audiosink.Dispose();
|
||||
audioSinkBin.Dispose();
|
||||
@@ -184,7 +185,7 @@ namespace Vocaluxe.Lib.Sound.Playback.GstreamerSharp
|
||||
}
|
||||
if (!audioSinkBin.AddPad(ghostpad))
|
||||
{
|
||||
CLog.LogError("Could not add pad");
|
||||
CLog.Error("Could not add pad");
|
||||
convert.Dispose();
|
||||
audiosink.Dispose();
|
||||
audioSinkBin.Dispose();
|
||||
@@ -199,7 +200,7 @@ namespace Vocaluxe.Lib.Sound.Playback.GstreamerSharp
|
||||
_Element = ElementFactory.Make("playbin", "playbin");
|
||||
if (_Element == null)
|
||||
{
|
||||
CLog.LogError("Could not create playbin");
|
||||
CLog.Error("Could not create playbin");
|
||||
convert.Dispose();
|
||||
audiosink.Dispose();
|
||||
audioSinkBin.Dispose();
|
||||
@@ -299,7 +300,7 @@ namespace Vocaluxe.Lib.Sound.Playback.GstreamerSharp
|
||||
GException error;
|
||||
string debug;
|
||||
msg.ParseError(out error, out debug);
|
||||
CLog.LogError("Gstreamer error: message" + error.Message + ", code" + error.Code + " ,debug information" + debug);
|
||||
CLog.Error("Gstreamer error: message" + error.Message + ", code" + error.Code + " ,debug information" + debug);
|
||||
return false;
|
||||
case MessageType.DurationChanged:
|
||||
_UpdateDuration();
|
||||
|
||||
@@ -22,6 +22,7 @@ using System.Threading;
|
||||
using OpenTK.Audio;
|
||||
using Vocaluxe.Base;
|
||||
using Vocaluxe.Lib.Sound.Playback.Decoder;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Lib.Sound.Playback.OpenAL
|
||||
{
|
||||
@@ -178,7 +179,7 @@ namespace Vocaluxe.Lib.Sound.Playback.OpenAL
|
||||
if (!ok)
|
||||
{
|
||||
Dispose();
|
||||
CLog.LogError("Error Init OpenAL Playback");
|
||||
CLog.Error("Error Init OpenAL Playback");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -187,14 +188,14 @@ namespace Vocaluxe.Lib.Sound.Playback.OpenAL
|
||||
if (!_Decoder.Open(_Medium))
|
||||
{
|
||||
Dispose();
|
||||
CLog.LogError("Error opening audio file: " + _Medium);
|
||||
CLog.Error("Error opening audio file: " + _Medium);
|
||||
return false;
|
||||
}
|
||||
_Format = _Decoder.GetFormatInfo();
|
||||
if (_Format.SamplesPerSecond == 0)
|
||||
{
|
||||
Dispose();
|
||||
CLog.LogError("Error Init OpenAL Playback (samples=0)");
|
||||
CLog.Error("Error Init OpenAL Playback (samples=0)");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using Vocaluxe.Base;
|
||||
using Vocaluxe.Lib.Sound.Playback.Decoder;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Lib.Sound.Playback.PortAudio
|
||||
{
|
||||
@@ -160,7 +161,7 @@ namespace Vocaluxe.Lib.Sound.Playback.PortAudio
|
||||
catch (Exception)
|
||||
{
|
||||
Dispose();
|
||||
CLog.LogError("Error Init PortAudio Playback");
|
||||
CLog.Error("Error Init PortAudio Playback");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -168,7 +169,7 @@ namespace Vocaluxe.Lib.Sound.Playback.PortAudio
|
||||
if (!_Decoder.Open(_Medium))
|
||||
{
|
||||
Dispose();
|
||||
CLog.LogError("Error opening audio file: " + _Medium);
|
||||
CLog.Error("Error opening audio file: " + _Medium);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -176,7 +177,7 @@ namespace Vocaluxe.Lib.Sound.Playback.PortAudio
|
||||
if (format.SamplesPerSecond == 0)
|
||||
{
|
||||
Dispose();
|
||||
CLog.LogError("Error Init PortAudio Playback (samples=0)");
|
||||
CLog.Error("Error Init PortAudio Playback (samples=0)");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -413,7 +414,7 @@ namespace Vocaluxe.Lib.Sound.Playback.PortAudio
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error PortAudio.StreamCallback: " + e.Message);
|
||||
CLog.Error("Error PortAudio.StreamCallback: " + e.Message);
|
||||
}
|
||||
|
||||
return PortAudioSharp.PortAudio.PaStreamCallbackResult.paContinue;
|
||||
|
||||
@@ -20,6 +20,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Log;
|
||||
using VocaluxeLib.Utils;
|
||||
|
||||
namespace Vocaluxe.Lib.Sound.Record.PitchTracker
|
||||
@@ -71,7 +72,7 @@ namespace Vocaluxe.Lib.Sound.Record.PitchTracker
|
||||
_CurPassedCount[i] = 0;
|
||||
}
|
||||
msg += "of " + _CurTestCount;
|
||||
CBase.Log.LogDebug(msg);
|
||||
CLog.Debug(msg);
|
||||
_TestCount += _CurTestCount;
|
||||
_CurTestCount = 0;
|
||||
//Do a reset first as we actually have an impossible situation (drop by multiple octaves)
|
||||
@@ -107,7 +108,7 @@ namespace Vocaluxe.Lib.Sound.Record.PitchTracker
|
||||
_InitNext("Real song");
|
||||
|
||||
_TestSpeed();
|
||||
CBase.Log.LogDebug("Finished: ");
|
||||
CLog.Debug("Finished: ");
|
||||
for (int i = 0; i < _Analyzers.Count; i++)
|
||||
{
|
||||
string msg = _Analyzers[i].GetType().Name + ":";
|
||||
@@ -115,7 +116,7 @@ namespace Vocaluxe.Lib.Sound.Record.PitchTracker
|
||||
msg += " Passed=" + _PassedCount[i];
|
||||
msg += " Total=" + _TestCount;
|
||||
msg += " Speed=" + _SamplesPerSec[i] / 1000 + "kSamples/s (=" + (_SamplesPerSec[i] / 44100) + "rec.s/s)";
|
||||
CBase.Log.LogDebug(msg);
|
||||
CLog.Debug(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +209,7 @@ namespace Vocaluxe.Lib.Sound.Record.PitchTracker
|
||||
string msg = "Note " + _ToneToNote(tone) + "(" + distort + ") at buffer " + (i + 1) + "/" + (sampleCt / batchCt) + " detected as ";
|
||||
for (int j = 0; j < valids.Length; j++)
|
||||
msg += _ToneToNote(_Tones[j]) + (valids[j] ? "" : "(!)") + "; ";
|
||||
CBase.Log.LogDebug(msg);
|
||||
CLog.Debug(msg);
|
||||
/*CWavFile w = new CWavFile();
|
||||
w.Create(tone + "-" + distort + ".wav", 1, 44100, 16);
|
||||
w.Write16BitSamples(data);
|
||||
@@ -401,7 +402,7 @@ namespace Vocaluxe.Lib.Sound.Record.PitchTracker
|
||||
string msg = "Note " + _ToneToNote(curNote) + " at " + time + "ms detected as ";
|
||||
for (int i = 0; i < _Tones.Length; i++)
|
||||
msg += _ToneToNote(_Tones[i]) + (valids[i] ? "" : "(!)") + "; ";
|
||||
CBase.Log.LogDebug(msg);
|
||||
CLog.Debug(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using Vocaluxe.Base;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Lib.Sound.Record.PortAudio
|
||||
{
|
||||
@@ -64,7 +65,7 @@ namespace Vocaluxe.Lib.Sound.Record.PortAudio
|
||||
catch (Exception e)
|
||||
{
|
||||
_Initialized = false;
|
||||
CLog.LogError("Error initializing PortAudio: " + e.Message);
|
||||
CLog.Error("Error initializing PortAudio: " + e.Message);
|
||||
Close();
|
||||
return false;
|
||||
}
|
||||
@@ -207,7 +208,7 @@ namespace Vocaluxe.Lib.Sound.Record.PortAudio
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error on Stream Callback (rec): " + e);
|
||||
CLog.Error("Error on Stream Callback (rec): " + e);
|
||||
}
|
||||
|
||||
return PortAudioSharp.PortAudio.PaStreamCallbackResult.paContinue;
|
||||
|
||||
@@ -21,6 +21,7 @@ using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using Vocaluxe.Base;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Lib.Video.Acinerella
|
||||
{
|
||||
@@ -87,7 +88,7 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
||||
_Free();
|
||||
}
|
||||
catch (Exception) {}
|
||||
CLog.LogError("Error opening video file: " + _FileName);
|
||||
CLog.Error("Error opening video file: " + _FileName);
|
||||
_Instance = IntPtr.Zero;
|
||||
return false;
|
||||
}
|
||||
@@ -96,12 +97,12 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
||||
{
|
||||
if (_Instance == IntPtr.Zero)
|
||||
{
|
||||
CLog.LogError("Tried to start a video file that is not open: " + _FileName);
|
||||
CLog.Error("Tried to start a video file that is not open: " + _FileName);
|
||||
return false;
|
||||
}
|
||||
if (_Thread != null)
|
||||
{
|
||||
CLog.LogError("Tried to start a video file that is already started: " + _FileName);
|
||||
CLog.Error("Tried to start a video file that is already started: " + _FileName);
|
||||
return false;
|
||||
}
|
||||
RequestTime = 0f;
|
||||
@@ -281,7 +282,7 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CLog.LogError("Error opening video file (can't find decoder): " + _FileName);
|
||||
CLog.Error("Error opening video file (can't find decoder): " + _FileName);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -325,7 +326,7 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error seeking video file \"" + _FileName + "\": " + e.Message);
|
||||
CLog.Error("Error seeking video file \"" + _FileName + "\": " + e.Message);
|
||||
}
|
||||
_LastDecodedTime = skipTime;
|
||||
|
||||
@@ -369,7 +370,7 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CLog.LogError("Error AcGetFrame " + _FileName);
|
||||
CLog.Error("Error AcGetFrame " + _FileName);
|
||||
}
|
||||
}
|
||||
if (hasFrameDecoded)
|
||||
@@ -395,7 +396,7 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CLog.LogError("Error AcSeek " + _FileName);
|
||||
CLog.Error("Error AcSeek " + _FileName);
|
||||
}
|
||||
|
||||
if (!hasFrameDecoded)
|
||||
@@ -419,7 +420,7 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CLog.LogError("Error AcSkipFrame " + _FileName);
|
||||
CLog.Error("Error AcSkipFrame " + _FileName);
|
||||
}
|
||||
return hasFrameDecoded;
|
||||
}
|
||||
@@ -437,7 +438,7 @@ namespace Vocaluxe.Lib.Video.Acinerella
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Couldn't copy the frame to the managed environment.", false, false, e);
|
||||
CLog.Error(e, "Couldn't copy the frame to the managed environment.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+162
-149
@@ -28,6 +28,8 @@ using Vocaluxe.Base;
|
||||
using Vocaluxe.Base.Fonts;
|
||||
using Vocaluxe.Base.Server;
|
||||
using Vocaluxe.Base.ThemeSystem;
|
||||
using Vocaluxe.Reporting;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
[assembly: InternalsVisibleTo("VocaluxeTests")]
|
||||
|
||||
@@ -78,7 +80,7 @@ namespace Vocaluxe
|
||||
}
|
||||
catch {}
|
||||
MessageBox.Show("Unhandled error: " + e.Message + stackTrace);
|
||||
CLog.LogError("Unhandled error: " + e.Message + stackTrace);
|
||||
CLog.Error("Unhandled error: " + e.Message + stackTrace);
|
||||
}
|
||||
#else
|
||||
_Run(args);
|
||||
@@ -96,175 +98,194 @@ namespace Vocaluxe
|
||||
Directory.CreateDirectory(CSettings.DataFolder);
|
||||
|
||||
// Init Log
|
||||
CLog.Init();
|
||||
CLog.Init(CSettings.FolderNameLogs, CSettings.FileNameMainLog, CSettings.FileNameSongLog, CSettings.FileNameCrashMarker, CSettings.GetFullVersionText(), CReporter.ShowReporterFunc);
|
||||
|
||||
if (!CProgrammHelper.CheckRequirements())
|
||||
return;
|
||||
CProgrammHelper.Init();
|
||||
|
||||
using (CBenchmark.Time("Init Program"))
|
||||
{
|
||||
CMain.Init();
|
||||
Application.DoEvents();
|
||||
|
||||
CLog.StartBenchmark("Init Program");
|
||||
CMain.Init();
|
||||
Application.DoEvents();
|
||||
// Init Language
|
||||
using (CBenchmark.Time("Init Language"))
|
||||
{
|
||||
if (!CLanguage.Init())
|
||||
throw new CLoadingException("Language");
|
||||
}
|
||||
|
||||
// Init Language
|
||||
CLog.StartBenchmark("Init Language");
|
||||
if (!CLanguage.Init())
|
||||
throw new CLoadingException("Language");
|
||||
CLog.StopBenchmark("Init Language");
|
||||
Application.DoEvents();
|
||||
|
||||
Application.DoEvents();
|
||||
// load config
|
||||
using (CBenchmark.Time("Init Config"))
|
||||
{
|
||||
CConfig.LoadCommandLineParams(args);
|
||||
CConfig.UseCommandLineParamsBefore();
|
||||
CConfig.Init();
|
||||
CConfig.UseCommandLineParamsAfter();
|
||||
}
|
||||
|
||||
// load config
|
||||
CLog.StartBenchmark("Init Config");
|
||||
CConfig.LoadCommandLineParams(args);
|
||||
CConfig.UseCommandLineParamsBefore();
|
||||
CConfig.Init();
|
||||
CConfig.UseCommandLineParamsAfter();
|
||||
CLog.StopBenchmark("Init Config");
|
||||
// Create folders
|
||||
CSettings.CreateFolders();
|
||||
|
||||
// Create folders
|
||||
CSettings.CreateFolders();
|
||||
_SplashScreen = new CSplashScreen();
|
||||
Application.DoEvents();
|
||||
|
||||
_SplashScreen = new CSplashScreen();
|
||||
Application.DoEvents();
|
||||
// Init Draw
|
||||
using (CBenchmark.Time("Init Draw"))
|
||||
{
|
||||
if (!CDraw.Init())
|
||||
throw new CLoadingException("drawing");
|
||||
}
|
||||
|
||||
// Init Draw
|
||||
CLog.StartBenchmark("Init Draw");
|
||||
if (!CDraw.Init())
|
||||
throw new CLoadingException("drawing");
|
||||
CLog.StopBenchmark("Init Draw");
|
||||
Application.DoEvents();
|
||||
|
||||
Application.DoEvents();
|
||||
// Init Playback
|
||||
using (CBenchmark.Time("Init Playback"))
|
||||
{
|
||||
if (!CSound.Init())
|
||||
throw new CLoadingException("playback");
|
||||
}
|
||||
|
||||
// Init Playback
|
||||
CLog.StartBenchmark("Init Playback");
|
||||
if (!CSound.Init())
|
||||
throw new CLoadingException("playback");
|
||||
CLog.StopBenchmark("Init Playback");
|
||||
Application.DoEvents();
|
||||
|
||||
Application.DoEvents();
|
||||
// Init Record
|
||||
using (CBenchmark.Time("Init Record"))
|
||||
{
|
||||
if (!CRecord.Init())
|
||||
throw new CLoadingException("record");
|
||||
}
|
||||
|
||||
// Init Record
|
||||
CLog.StartBenchmark("Init Record");
|
||||
if (!CRecord.Init())
|
||||
throw new CLoadingException("record");
|
||||
CLog.StopBenchmark("Init Record");
|
||||
Application.DoEvents();
|
||||
|
||||
Application.DoEvents();
|
||||
// Init VideoDecoder
|
||||
using (CBenchmark.Time("Init Videodecoder"))
|
||||
{
|
||||
if (!CVideo.Init())
|
||||
throw new CLoadingException("video");
|
||||
}
|
||||
|
||||
// Init VideoDecoder
|
||||
CLog.StartBenchmark("Init Videodecoder");
|
||||
if (!CVideo.Init())
|
||||
throw new CLoadingException("video");
|
||||
CLog.StopBenchmark("Init Videodecoder");
|
||||
Application.DoEvents();
|
||||
|
||||
Application.DoEvents();
|
||||
// Init Database
|
||||
using (CBenchmark.Time("Init Database"))
|
||||
{
|
||||
if (!CDataBase.Init())
|
||||
throw new CLoadingException("database");
|
||||
}
|
||||
|
||||
// Init Database
|
||||
CLog.StartBenchmark("Init Database");
|
||||
if (!CDataBase.Init())
|
||||
throw new CLoadingException("database");
|
||||
CLog.StopBenchmark("Init Database");
|
||||
Application.DoEvents();
|
||||
|
||||
Application.DoEvents();
|
||||
//Init Webcam
|
||||
using (CBenchmark.Time("Init Webcam"))
|
||||
{
|
||||
if (!CWebcam.Init())
|
||||
throw new CLoadingException("webcam");
|
||||
}
|
||||
|
||||
//Init Webcam
|
||||
CLog.StartBenchmark("Init Webcam");
|
||||
if (!CWebcam.Init())
|
||||
throw new CLoadingException("webcam");
|
||||
CLog.StopBenchmark("Init Webcam");
|
||||
Application.DoEvents();
|
||||
|
||||
Application.DoEvents();
|
||||
// Init Background Music
|
||||
using (CBenchmark.Time("Init Background Music"))
|
||||
{
|
||||
CBackgroundMusic.Init();
|
||||
}
|
||||
|
||||
// Init Background Music
|
||||
CLog.StartBenchmark("Init Background Music");
|
||||
CBackgroundMusic.Init();
|
||||
CLog.StopBenchmark("Init Background Music");
|
||||
Application.DoEvents();
|
||||
|
||||
Application.DoEvents();
|
||||
// Init Profiles
|
||||
using (CBenchmark.Time("Init Profiles"))
|
||||
{
|
||||
CProfiles.Init();
|
||||
}
|
||||
|
||||
// Init Profiles
|
||||
CLog.StartBenchmark("Init Profiles");
|
||||
CProfiles.Init();
|
||||
CLog.StopBenchmark("Init Profiles");
|
||||
Application.DoEvents();
|
||||
|
||||
Application.DoEvents();
|
||||
// Init Fonts
|
||||
using (CBenchmark.Time("Init Fonts"))
|
||||
{
|
||||
if (!CFonts.Init())
|
||||
throw new CLoadingException("fonts");
|
||||
}
|
||||
|
||||
// Init Fonts
|
||||
CLog.StartBenchmark("Init Fonts");
|
||||
if (!CFonts.Init())
|
||||
throw new CLoadingException("fonts");
|
||||
CLog.StopBenchmark("Init Fonts");
|
||||
Application.DoEvents();
|
||||
|
||||
Application.DoEvents();
|
||||
// Theme System
|
||||
using (CBenchmark.Time("Init Theme"))
|
||||
{
|
||||
if (!CThemes.Init())
|
||||
throw new CLoadingException("theme");
|
||||
}
|
||||
|
||||
using (CBenchmark.Time("Load Theme"))
|
||||
{
|
||||
CThemes.Load();
|
||||
}
|
||||
|
||||
// Theme System
|
||||
CLog.StartBenchmark("Init Theme");
|
||||
if (!CThemes.Init())
|
||||
throw new CLoadingException("theme");
|
||||
CLog.StopBenchmark("Init Theme");
|
||||
Application.DoEvents();
|
||||
|
||||
CLog.StartBenchmark("Load Theme");
|
||||
CThemes.Load();
|
||||
CLog.StopBenchmark("Load Theme");
|
||||
// Load Cover
|
||||
using (CBenchmark.Time("Init Cover"))
|
||||
{
|
||||
if (!CCover.Init())
|
||||
throw new CLoadingException("covertheme");
|
||||
}
|
||||
|
||||
Application.DoEvents();
|
||||
Application.DoEvents();
|
||||
|
||||
// Load Cover
|
||||
CLog.StartBenchmark("Init Cover");
|
||||
if (!CCover.Init())
|
||||
throw new CLoadingException("covertheme");
|
||||
CLog.StopBenchmark("Init Cover");
|
||||
// Init Screens
|
||||
using (CBenchmark.Time("Init Screens"))
|
||||
{
|
||||
CGraphics.Init();
|
||||
}
|
||||
|
||||
Application.DoEvents();
|
||||
Application.DoEvents();
|
||||
|
||||
// Init Screens
|
||||
CLog.StartBenchmark("Init Screens");
|
||||
CGraphics.Init();
|
||||
CLog.StopBenchmark("Init Screens");
|
||||
// Init Server
|
||||
using (CBenchmark.Time("Init Server"))
|
||||
{
|
||||
CVocaluxeServer.Init();
|
||||
}
|
||||
|
||||
Application.DoEvents();
|
||||
Application.DoEvents();
|
||||
|
||||
// Init Server
|
||||
CLog.StartBenchmark("Init Server");
|
||||
CVocaluxeServer.Init();
|
||||
CLog.StopBenchmark("Init Server");
|
||||
// Init Input
|
||||
using (CBenchmark.Time("Init Input"))
|
||||
{
|
||||
CController.Init();
|
||||
CController.Connect();
|
||||
}
|
||||
|
||||
Application.DoEvents();
|
||||
Application.DoEvents();
|
||||
|
||||
// Init Input
|
||||
CLog.StartBenchmark("Init Input");
|
||||
CController.Init();
|
||||
CController.Connect();
|
||||
CLog.StopBenchmark("Init Input");
|
||||
// Init Game
|
||||
using (CBenchmark.Time("Init Game"))
|
||||
{
|
||||
CGame.Init();
|
||||
CProfiles.Update();
|
||||
CConfig.UsePlayers();
|
||||
}
|
||||
|
||||
Application.DoEvents();
|
||||
Application.DoEvents();
|
||||
|
||||
// Init Game;
|
||||
CLog.StartBenchmark("Init Game");
|
||||
CGame.Init();
|
||||
CProfiles.Update();
|
||||
CConfig.UsePlayers();
|
||||
CLog.StopBenchmark("Init Game");
|
||||
// Init Party Modes
|
||||
using (CBenchmark.Time("Init Party Modes"))
|
||||
{
|
||||
if (!CParty.Init())
|
||||
throw new CLoadingException("Party Modes");
|
||||
}
|
||||
|
||||
Application.DoEvents();
|
||||
|
||||
// Init Party Modes;
|
||||
CLog.StartBenchmark("Init Party Modes");
|
||||
if (!CParty.Init())
|
||||
throw new CLoadingException("Party Modes");
|
||||
CLog.StopBenchmark("Init Party Modes");
|
||||
|
||||
Application.DoEvents();
|
||||
//Only reasonable point to call GC.Collect() because initialization may cause lots of garbage
|
||||
//Rely on GC doing its job afterwards and call Dispose methods where appropriate
|
||||
GC.Collect();
|
||||
CLog.StopBenchmark("Init Program");
|
||||
Application.DoEvents();
|
||||
//Only reasonable point to call GC.Collect() because initialization may cause lots of garbage
|
||||
//Rely on GC doing its job afterwards and call Dispose methods where appropriate
|
||||
GC.Collect();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show("Error on start up: " + e.Message);
|
||||
CLog.LogError("Error on start up: " + e);
|
||||
CLog.Error(e, "Error on start up: {ExceptionMessage}", CLog.Params(e.Message), show:true);
|
||||
if (_SplashScreen != null)
|
||||
_SplashScreen.Close();
|
||||
_CloseProgram();
|
||||
@@ -288,7 +309,7 @@ namespace Vocaluxe
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error during shutdown! (CController)", false, false, e);
|
||||
CLog.Error(e, "Error during shutdown! (CController)");
|
||||
}
|
||||
|
||||
try
|
||||
@@ -297,7 +318,7 @@ namespace Vocaluxe
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error during shutdown! (CVocaluxeServer)", false, false, e);
|
||||
CLog.Error(e, "Error during shutdown! (CVocaluxeServer)");
|
||||
}
|
||||
|
||||
try
|
||||
@@ -306,7 +327,7 @@ namespace Vocaluxe
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error during shutdown! (CGraphics)", false, false, e);
|
||||
CLog.Error(e, "Error during shutdown! (CGraphics)");
|
||||
}
|
||||
|
||||
try
|
||||
@@ -315,7 +336,7 @@ namespace Vocaluxe
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error during shutdown! (CThemes)", false, false, e);
|
||||
CLog.Error(e, "Error during shutdown! (CThemes)");
|
||||
}
|
||||
|
||||
try
|
||||
@@ -324,7 +345,7 @@ namespace Vocaluxe
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error during shutdown! (CCover)", false, false, e);
|
||||
CLog.Error(e, "Error during shutdown! (CCover)");
|
||||
}
|
||||
|
||||
try
|
||||
@@ -333,7 +354,7 @@ namespace Vocaluxe
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error during shutdown! (CFonts)", false, false, e);
|
||||
CLog.Error(e, "Error during shutdown! (CFonts)");
|
||||
}
|
||||
|
||||
try
|
||||
@@ -342,7 +363,7 @@ namespace Vocaluxe
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error during shutdown! (CBackgroundMusic)", false, false, e);
|
||||
CLog.Error(e, "Error during shutdown! (CBackgroundMusic)");
|
||||
}
|
||||
|
||||
try
|
||||
@@ -351,7 +372,7 @@ namespace Vocaluxe
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error during shutdown! (CWebcam)", false, false, e);
|
||||
CLog.Error(e, "Error during shutdown! (CWebcam)");
|
||||
}
|
||||
|
||||
try
|
||||
@@ -360,7 +381,7 @@ namespace Vocaluxe
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error during shutdown! (CDataBase)", false, false, e);
|
||||
CLog.Error(e, "Error during shutdown! (CDataBase)");
|
||||
}
|
||||
|
||||
try
|
||||
@@ -369,7 +390,7 @@ namespace Vocaluxe
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error during shutdown! (CVideo)", false, false, e);
|
||||
CLog.Error(e, "Error during shutdown! (CVideo)");
|
||||
}
|
||||
|
||||
try
|
||||
@@ -378,7 +399,7 @@ namespace Vocaluxe
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error during shutdown! (CRecord)", false, false, e);
|
||||
CLog.Error(e, "Error during shutdown! (CRecord)");
|
||||
}
|
||||
|
||||
try
|
||||
@@ -387,7 +408,7 @@ namespace Vocaluxe
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error during shutdown! (CSound)", false, false, e);
|
||||
CLog.Error(e, "Error during shutdown! (CSound)");
|
||||
}
|
||||
|
||||
try
|
||||
@@ -396,7 +417,7 @@ namespace Vocaluxe
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error during shutdown! (CDraw)", false, false, e);
|
||||
CLog.Error(e, "Error during shutdown! (CDraw)");
|
||||
}
|
||||
|
||||
GC.Collect(); // Do a GC run here before we close logs to have finalizers run
|
||||
@@ -413,15 +434,7 @@ namespace Vocaluxe
|
||||
private static void UnhandledExceptionHandler(object sender, UnhandledExceptionEventArgs args)
|
||||
{
|
||||
var e = (Exception)args.ExceptionObject;
|
||||
string stackTrace = "";
|
||||
try
|
||||
{
|
||||
stackTrace = e.StackTrace;
|
||||
}
|
||||
catch {}
|
||||
MessageBox.Show("Unhandled exception: " + e.Message + stackTrace);
|
||||
CLog.LogError("Unhandled exception: " + e.Message + stackTrace);
|
||||
_CloseProgram();
|
||||
CLog.Fatal(e, "Unhandled exception: {ExceptionMessage}", CLog.Params(e.Message));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -456,7 +469,7 @@ namespace Vocaluxe
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Cannot load assembly " + args.Name + " from " + path + ": " + e + "\r\nOuter Error: " + e1);
|
||||
CLog.Error("Cannot load assembly " + args.Name + " from " + path + ": " + e + "\r\nOuter Error: " + e1);
|
||||
}
|
||||
}
|
||||
#if LINUX
|
||||
|
||||
@@ -27,7 +27,7 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Vocaluxe")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
|
||||
Generated
+220
@@ -0,0 +1,220 @@
|
||||
namespace Vocaluxe.Reporting
|
||||
{
|
||||
partial class CReporter
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CReporter));
|
||||
this.TitleLabel = new System.Windows.Forms.Label();
|
||||
this.MessageText = new System.Windows.Forms.TextBox();
|
||||
this.LogBox = new System.Windows.Forms.TextBox();
|
||||
this.GistOnlySelect = new System.Windows.Forms.RadioButton();
|
||||
this.GistAndIssueSelect = new System.Windows.Forms.RadioButton();
|
||||
this.NoUploadSelect = new System.Windows.Forms.RadioButton();
|
||||
this.SubmitButton = new System.Windows.Forms.Button();
|
||||
this.Url = new System.Windows.Forms.TextBox();
|
||||
this.SubmitedTitleLabel = new System.Windows.Forms.Label();
|
||||
this.LastErrorTitleLabel = new System.Windows.Forms.Label();
|
||||
this.LastErrorBox = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// TitleLabel
|
||||
//
|
||||
this.TitleLabel.AutoSize = true;
|
||||
this.TitleLabel.Enabled = false;
|
||||
this.TitleLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.TitleLabel.Location = new System.Drawing.Point(9, 8);
|
||||
this.TitleLabel.Name = "TitleLabel";
|
||||
this.TitleLabel.Size = new System.Drawing.Size(110, 20);
|
||||
this.TitleLabel.TabIndex = 0;
|
||||
this.TitleLabel.Text = "We are sorry";
|
||||
//
|
||||
// MessageText
|
||||
//
|
||||
this.MessageText.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.MessageText.Enabled = false;
|
||||
this.MessageText.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.MessageText.Location = new System.Drawing.Point(13, 31);
|
||||
this.MessageText.Multiline = true;
|
||||
this.MessageText.Name = "MessageText";
|
||||
this.MessageText.ReadOnly = true;
|
||||
this.MessageText.Size = new System.Drawing.Size(625, 63);
|
||||
this.MessageText.TabIndex = 0;
|
||||
this.MessageText.TabStop = false;
|
||||
this.MessageText.Text = "that Vocaluxe run into an error and crashed.\r\nTo help us fix the problem please s" +
|
||||
"end us a report.\r\nEdit the following log before submitting to remove possibly se" +
|
||||
"nsitive information.";
|
||||
//
|
||||
// LogBox
|
||||
//
|
||||
this.LogBox.AcceptsReturn = true;
|
||||
this.LogBox.AcceptsTab = true;
|
||||
this.LogBox.Location = new System.Drawing.Point(13, 182);
|
||||
this.LogBox.Multiline = true;
|
||||
this.LogBox.Name = "LogBox";
|
||||
this.LogBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||
this.LogBox.Size = new System.Drawing.Size(625, 189);
|
||||
this.LogBox.TabIndex = 1;
|
||||
this.LogBox.WordWrap = false;
|
||||
//
|
||||
// GistOnlySelect
|
||||
//
|
||||
this.GistOnlySelect.AutoSize = true;
|
||||
this.GistOnlySelect.Checked = true;
|
||||
this.GistOnlySelect.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.GistOnlySelect.Location = new System.Drawing.Point(12, 377);
|
||||
this.GistOnlySelect.Name = "GistOnlySelect";
|
||||
this.GistOnlySelect.Size = new System.Drawing.Size(385, 24);
|
||||
this.GistOnlySelect.TabIndex = 2;
|
||||
this.GistOnlySelect.TabStop = true;
|
||||
this.GistOnlySelect.Text = "Upload and get a link to your report (publicly visible)";
|
||||
this.GistOnlySelect.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// GistAndIssueSelect
|
||||
//
|
||||
this.GistAndIssueSelect.AutoSize = true;
|
||||
this.GistAndIssueSelect.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.GistAndIssueSelect.Location = new System.Drawing.Point(12, 407);
|
||||
this.GistAndIssueSelect.Name = "GistAndIssueSelect";
|
||||
this.GistAndIssueSelect.Size = new System.Drawing.Size(519, 24);
|
||||
this.GistAndIssueSelect.TabIndex = 3;
|
||||
this.GistAndIssueSelect.TabStop = true;
|
||||
this.GistAndIssueSelect.Text = "Upload and open an issue (publicly visible + requires a github account)";
|
||||
this.GistAndIssueSelect.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// NoUploadSelect
|
||||
//
|
||||
this.NoUploadSelect.AutoSize = true;
|
||||
this.NoUploadSelect.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.NoUploadSelect.Location = new System.Drawing.Point(12, 437);
|
||||
this.NoUploadSelect.Name = "NoUploadSelect";
|
||||
this.NoUploadSelect.Size = new System.Drawing.Size(493, 24);
|
||||
this.NoUploadSelect.TabIndex = 4;
|
||||
this.NoUploadSelect.TabStop = true;
|
||||
this.NoUploadSelect.Text = "Don\'t upload anything (you can still copy the error message above)";
|
||||
this.NoUploadSelect.UseVisualStyleBackColor = true;
|
||||
this.NoUploadSelect.CheckedChanged += new System.EventHandler(this.NoUpload_CheckedChanged);
|
||||
//
|
||||
// SubmitButton
|
||||
//
|
||||
this.SubmitButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.SubmitButton.Location = new System.Drawing.Point(537, 388);
|
||||
this.SubmitButton.Name = "SubmitButton";
|
||||
this.SubmitButton.Size = new System.Drawing.Size(101, 73);
|
||||
this.SubmitButton.TabIndex = 5;
|
||||
this.SubmitButton.Text = "Submit";
|
||||
this.SubmitButton.UseVisualStyleBackColor = true;
|
||||
this.SubmitButton.Click += new System.EventHandler(this.Submit_Click);
|
||||
//
|
||||
// Url
|
||||
//
|
||||
this.Url.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.Url.Location = new System.Drawing.Point(12, 409);
|
||||
this.Url.Name = "Url";
|
||||
this.Url.ReadOnly = true;
|
||||
this.Url.Size = new System.Drawing.Size(519, 22);
|
||||
this.Url.TabIndex = 6;
|
||||
this.Url.Text = "https://gist.github.com/lukeIam/cc81f7ef3545ef2baf0ca9a28ffe4bd8";
|
||||
this.Url.Visible = false;
|
||||
//
|
||||
// SubmitedTitleLabel
|
||||
//
|
||||
this.SubmitedTitleLabel.AutoSize = true;
|
||||
this.SubmitedTitleLabel.Enabled = false;
|
||||
this.SubmitedTitleLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.SubmitedTitleLabel.Location = new System.Drawing.Point(9, 381);
|
||||
this.SubmitedTitleLabel.Name = "SubmitedTitleLabel";
|
||||
this.SubmitedTitleLabel.Size = new System.Drawing.Size(189, 20);
|
||||
this.SubmitedTitleLabel.TabIndex = 8;
|
||||
this.SubmitedTitleLabel.Text = "The link to your report:";
|
||||
this.SubmitedTitleLabel.Visible = false;
|
||||
//
|
||||
// LastErrorTitleLabel
|
||||
//
|
||||
this.LastErrorTitleLabel.AutoSize = true;
|
||||
this.LastErrorTitleLabel.Enabled = false;
|
||||
this.LastErrorTitleLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.LastErrorTitleLabel.Location = new System.Drawing.Point(9, 97);
|
||||
this.LastErrorTitleLabel.Name = "LastErrorTitleLabel";
|
||||
this.LastErrorTitleLabel.Size = new System.Drawing.Size(87, 20);
|
||||
this.LastErrorTitleLabel.TabIndex = 9;
|
||||
this.LastErrorTitleLabel.Text = "Last error";
|
||||
//
|
||||
// LastErrorBox
|
||||
//
|
||||
this.LastErrorBox.AcceptsReturn = true;
|
||||
this.LastErrorBox.AcceptsTab = true;
|
||||
this.LastErrorBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.LastErrorBox.Location = new System.Drawing.Point(12, 120);
|
||||
this.LastErrorBox.Multiline = true;
|
||||
this.LastErrorBox.Name = "LastErrorBox";
|
||||
this.LastErrorBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.LastErrorBox.Size = new System.Drawing.Size(626, 38);
|
||||
this.LastErrorBox.TabIndex = 10;
|
||||
//
|
||||
// CReporter
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(650, 467);
|
||||
this.Controls.Add(this.LastErrorBox);
|
||||
this.Controls.Add(this.LastErrorTitleLabel);
|
||||
this.Controls.Add(this.SubmitedTitleLabel);
|
||||
this.Controls.Add(this.Url);
|
||||
this.Controls.Add(this.SubmitButton);
|
||||
this.Controls.Add(this.NoUploadSelect);
|
||||
this.Controls.Add(this.GistAndIssueSelect);
|
||||
this.Controls.Add(this.GistOnlySelect);
|
||||
this.Controls.Add(this.LogBox);
|
||||
this.Controls.Add(this.MessageText);
|
||||
this.Controls.Add(this.TitleLabel);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "CReporter";
|
||||
this.Text = "Vocaluxe Issue Reporter";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Label TitleLabel;
|
||||
private System.Windows.Forms.TextBox MessageText;
|
||||
private System.Windows.Forms.TextBox LogBox;
|
||||
private System.Windows.Forms.RadioButton GistOnlySelect;
|
||||
private System.Windows.Forms.RadioButton GistAndIssueSelect;
|
||||
private System.Windows.Forms.RadioButton NoUploadSelect;
|
||||
private System.Windows.Forms.Button SubmitButton;
|
||||
private System.Windows.Forms.TextBox Url;
|
||||
private System.Windows.Forms.Label SubmitedTitleLabel;
|
||||
private System.Windows.Forms.Label LastErrorTitleLabel;
|
||||
private System.Windows.Forms.TextBox LastErrorBox;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,329 @@
|
||||
#region license
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Newtonsoft.Json;
|
||||
using Vocaluxe.Base;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Reporting
|
||||
{
|
||||
public partial class CReporter : Form
|
||||
{
|
||||
// Init string with defaults for the case that loading localizations caused the problem
|
||||
private string _TitleText = "We are sorry";
|
||||
private string _MessageCrashText = "that Vocaluxe run into an error and crashed.\r\nTo help us fix the problem please send us a report.\r\nEdit the following log before submitting to remove possibly sensitive information.";
|
||||
private string _MessageNoCrashText = "that you experienced an error.\r\nTo help us fix the problem please send us a report.\r\nEdit the following log before submitting to remove possibly sensitive information.";
|
||||
private string _NoUploadText = "Don\'t upload anything (you can still copy the error message above)";
|
||||
private string _GistAndIssueText = "Upload and open an issue (publicly visible + requires a github account)";
|
||||
private string _GistOnlyText = "Upload and get a link to your report (publicly visible)";
|
||||
private string _SubmitStep0Text = "Submit";
|
||||
private string _SubmitStep1Text = "Uploading";
|
||||
private string _SubmitStep2ExitText = "Exit";
|
||||
private string _SubmitStep2ContinueText = "Continue";
|
||||
private string _SubmitedMessageText = "The link to your report:";
|
||||
private string _LogUploadErrorText = "Error uploading the log.";
|
||||
private string _LastErrorTitleText = "Last error";
|
||||
private string _LastErrorNa = "Not available";
|
||||
private string _IssueTemplate = "Describe your issue here.\n\n### Steps to reproduce\nTell us how to reproduce this issue.\n\n### Vocaluxe version and logfile\n{0}\n{1}";
|
||||
|
||||
|
||||
|
||||
private int _Step = 0;
|
||||
private readonly bool _Crash;
|
||||
private readonly string _VocaluxeVersionTag;
|
||||
private readonly bool _ShowContinue;
|
||||
|
||||
private static readonly HttpClient _Client = new HttpClient();
|
||||
private static readonly Regex _GetGistUrlRegex = new Regex("\"html_url\": *\"([^\"]+)\"");
|
||||
|
||||
|
||||
public static ShowReporterDelegate ShowReporterFunc
|
||||
{
|
||||
get { return _ShowReporter; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows a new instance of the log file reporter.
|
||||
/// </summary>
|
||||
/// <param name="crash">True if we are submitting a crash, false otherwise (e.g. error).</param>
|
||||
/// <param name="showContinue">True if the reporter show show a continue message, false if it should show an exit message.</param>
|
||||
/// <param name="vocaluxeVersionTag">The full version tag of this instance (like it is diplayed in the main menu).</param>
|
||||
/// <param name="log">The log to submit.</param>
|
||||
/// <param name="lastError">The last error message.</param>
|
||||
private static void _ShowReporter(bool crash, bool showContinue, string vocaluxeVersionTag, string log, string lastError)
|
||||
{
|
||||
using (var reporter = new CReporter(crash, showContinue, vocaluxeVersionTag, log, lastError))
|
||||
{
|
||||
reporter.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the log file reporter.
|
||||
/// </summary>
|
||||
/// <param name="crash">True if we are submitting a crash, false otherwise (e.g. error).</param>
|
||||
/// <param name="showContinue">True if the reporter show show a continue message, false if it should show an exit message.</param>
|
||||
/// <param name="vocaluxeVersionTag">The full version tag of this instance (like it is diplayed in the main menu).</param>
|
||||
/// <param name="log">The log to submit.</param>
|
||||
/// <param name="lastError">The last error message.</param>
|
||||
public CReporter(bool crash, bool showContinue, string vocaluxeVersionTag, string log, string lastError)
|
||||
{
|
||||
InitializeComponent();
|
||||
_Crash = crash;
|
||||
_ShowContinue = showContinue;
|
||||
_VocaluxeVersionTag = vocaluxeVersionTag;
|
||||
_Init(log, lastError);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initilaize the gui.
|
||||
/// </summary>
|
||||
/// <param name="log">The Log to submit.</param>
|
||||
/// <param name="lastError">The last error message.</param>
|
||||
private void _Init(string log, string lastError)
|
||||
{
|
||||
// Try to load localized strings
|
||||
try
|
||||
{
|
||||
_TitleText = CLanguage.Translate("TR_REPORTER_TITLE_TEXT");
|
||||
_MessageCrashText = CLanguage.Translate("TR_REPORTER_MESSAGE_CRASH_TEXT").Replace("\\n", "\n").Replace("\\r", "\r");
|
||||
_MessageNoCrashText = CLanguage.Translate("TR_REPORTER_MESSAGE_NO_CRASH_TEXT").Replace("\\n", "\n").Replace("\\r", "\r");
|
||||
_NoUploadText = CLanguage.Translate("TR_REPORTER_NO_UPLOAD_TEXT");
|
||||
_GistAndIssueText = CLanguage.Translate("TR_REPORTER_GIST_AND_ISSUE_TEXT");
|
||||
_GistOnlyText = CLanguage.Translate("TR_REPORTER_GIST_ONLY_TEXT");
|
||||
_SubmitStep0Text = CLanguage.Translate("TR_REPORTER_SUBMIT_STEP0_TEXT");
|
||||
_SubmitStep1Text = CLanguage.Translate("TR_REPORTER_SUBMIT_STEP1_TEXT");
|
||||
_SubmitStep2ExitText = CLanguage.Translate("TR_REPORTER_SUBMIT_STEP2_EXIT_TEXT");
|
||||
_SubmitStep2ContinueText = CLanguage.Translate("TR_REPORTER_SUBMIT_STEP2_CONTINUE_TEXT");
|
||||
_SubmitedMessageText = CLanguage.Translate("TR_REPORTER_SUBMITED_MESSAGE_TEXT");
|
||||
_LogUploadErrorText = CLanguage.Translate("TR_REPORTER_LOGUPLOAD_ERROR_TEXT");
|
||||
_LastErrorTitleText = CLanguage.Translate("TR_REPORTER_LAST_ERROR_TITLE_TEXT");
|
||||
_LastErrorNa = CLanguage.Translate("TR_REPORTER_LAST_ERROR_NA");
|
||||
_IssueTemplate = CLanguage.Translate("TR_REPORTER_ISSUE_TEMPLATE").Replace("\\n", "\n").Replace("\\r", "\r");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine($"Unable to load translation for report assistant: {e.Message}");
|
||||
#endif
|
||||
}
|
||||
|
||||
_Client.DefaultRequestHeaders.Add("accept", "application/json");
|
||||
_Client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)");
|
||||
|
||||
this.TitleLabel.Text = _TitleText;
|
||||
this.MessageText.Text = _Crash ? _MessageCrashText : _MessageNoCrashText;
|
||||
this.NoUploadSelect.Text = _NoUploadText;
|
||||
this.GistAndIssueSelect.Text = _GistAndIssueText;
|
||||
this.GistOnlySelect.Text = _GistOnlyText;
|
||||
this.SubmitButton.Text = _SubmitStep0Text;
|
||||
this.SubmitedTitleLabel.Text = _SubmitedMessageText;
|
||||
this.LastErrorTitleLabel.Text = _LastErrorTitleText;
|
||||
this.LastErrorBox.Text = string.IsNullOrWhiteSpace(lastError) ? _LastErrorNa : lastError;
|
||||
this.LogBox.Text = log.Replace("\n","\r\n");
|
||||
this.LogBox.SelectionStart = 0;
|
||||
}
|
||||
|
||||
private async void Submit_Click(object sender, EventArgs e)
|
||||
{
|
||||
switch (_Step)
|
||||
{
|
||||
case 0:
|
||||
if (this.NoUploadSelect.Checked)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
_Step = 1;
|
||||
this.SubmitButton.Text = _SubmitStep1Text;
|
||||
this.SubmitButton.Enabled = false;
|
||||
this.NoUploadSelect.Visible = false;
|
||||
this.GistAndIssueSelect.Visible = false;
|
||||
this.GistOnlySelect.Visible = false;
|
||||
this.LogBox.Enabled = false;
|
||||
this.LastErrorBox.Enabled = false;
|
||||
|
||||
if (this.GistOnlySelect.Checked)
|
||||
{
|
||||
await Task.Run(() => _StartGistUpload(this.LogBox.Text, this.LastErrorBox.Text));
|
||||
}
|
||||
else if (this.GistAndIssueSelect.Checked)
|
||||
{
|
||||
await Task.Run(() => _StartIssueUpload(this.LogBox.Text, this.LastErrorBox.Text));
|
||||
}
|
||||
else
|
||||
{
|
||||
_Step = 0;
|
||||
this.SubmitButton.Text = _SubmitStep0Text;
|
||||
this.SubmitButton.Enabled = true;
|
||||
this.NoUploadSelect.Visible = true;
|
||||
this.GistAndIssueSelect.Visible = true;
|
||||
this.GistOnlySelect.Visible = true;
|
||||
this.LogBox.Enabled = true;
|
||||
this.LastErrorBox.Enabled = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
case 2:
|
||||
this.Close();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void NoUpload_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.SubmitButton.Text = this.NoUploadSelect.Checked ? (_ShowContinue ? _SubmitStep2ContinueText : _SubmitStep2ExitText) : _SubmitStep0Text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the gui after the upload finished.
|
||||
/// </summary>
|
||||
/// <param name="url">Url to show, if null or empty an error message is shown.</param>
|
||||
private void _UploadFinished(string url)
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new MethodInvoker(() => { _UploadFinished(url); }));
|
||||
}
|
||||
else
|
||||
{
|
||||
_Step = 2;
|
||||
this.SubmitButton.Text = _ShowContinue ? _SubmitStep2ContinueText : _SubmitStep2ExitText;
|
||||
this.SubmitButton.Enabled = true;
|
||||
this.SubmitedTitleLabel.Visible = true;
|
||||
this.Url.Text = string.IsNullOrWhiteSpace(url)?_LogUploadErrorText:url;
|
||||
this.Url.Visible = true;
|
||||
this.Url.SelectAll();
|
||||
this.Url.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Upload a log to gist and updates the gui.
|
||||
/// </summary>
|
||||
/// <param name="log">The log to upload.</param>
|
||||
/// <param name="lastError">The error message displayed to the user (if available).</param>
|
||||
private async void _StartGistUpload(string log, string lastError= "not available")
|
||||
{
|
||||
// Upload log to github gist and show the link
|
||||
_UploadFinished(await _UploadLogToGist(log, lastError));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Upload a log to gist, opens an issue template on github and updates the gui.
|
||||
/// </summary>
|
||||
/// <param name="log">The log to upload.</param>
|
||||
/// <param name="lastError">The error message displayed to the user (if available).</param>
|
||||
private async void _StartIssueUpload(string log, string lastError = "not available")
|
||||
{
|
||||
// Upload log to github gist
|
||||
string gistUrl = await _UploadLogToGist(log, lastError);
|
||||
|
||||
// Build issue body
|
||||
string template = string.Format(_IssueTemplate, _VocaluxeVersionTag, gistUrl);
|
||||
|
||||
// Build url for github issue template
|
||||
string issueUrl = $"https://github.com/Vocaluxe/Vocaluxe/issues/new?title=Give%20me%20a%20meaningful%20title&body={ Uri.EscapeDataString(template) }";
|
||||
|
||||
// Show the link
|
||||
_UploadFinished(issueUrl);
|
||||
|
||||
// Start the browser with the issue template url
|
||||
System.Diagnostics.Process.Start(issueUrl);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Uploads a log to a new anonymous gist.
|
||||
/// </summary>
|
||||
/// <param name="log">The log that should be uploaded.</param>
|
||||
/// <param name="lastError">The error message displayed to the user (if available).</param>
|
||||
/// <returns>The link to the uploaded file.</returns>
|
||||
private async Task<string> _UploadLogToGist(string log, string lastError= "not available")
|
||||
{
|
||||
string json = JsonConvert.SerializeObject(new CGistCreateData()
|
||||
{
|
||||
Description = $"An { (_Crash ? "crash" : "error") } log submission for { _VocaluxeVersionTag }",
|
||||
Public = false,
|
||||
Files = new Dictionary<string, CGistFileData>()
|
||||
{
|
||||
{
|
||||
"Vocaluxe.log",
|
||||
new CGistFileData()
|
||||
{
|
||||
Content = log
|
||||
}
|
||||
},
|
||||
{
|
||||
"LastError.txt",
|
||||
new CGistFileData()
|
||||
{
|
||||
Content = lastError
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
string responseString = "";
|
||||
try
|
||||
{
|
||||
var response = await _Client.PostAsync("https://api.github.com/gists", content);
|
||||
|
||||
responseString = await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
catch (HttpRequestException e)
|
||||
{
|
||||
CLog.Error(e, "Couldn't upload log", show:true, propertyValues:CLog.Params(json));
|
||||
}
|
||||
|
||||
return _GetGistUrlRegex.Match(responseString)?.Groups[1]?.Value??"";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper class for gist creation.
|
||||
/// </summary>
|
||||
private class CGistCreateData
|
||||
{
|
||||
[JsonProperty("description")]
|
||||
public string Description { get; set; }
|
||||
[JsonProperty("public")]
|
||||
public bool Public { get; set; }
|
||||
[JsonProperty("files")]
|
||||
public Dictionary<string, CGistFileData> Files { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper class for gist creation.
|
||||
/// </summary>
|
||||
private class CGistFileData
|
||||
{
|
||||
[JsonProperty("content")]
|
||||
public string Content { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -23,6 +23,7 @@ using Vocaluxe.Base;
|
||||
using Vocaluxe.Base.Fonts;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Log;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
namespace Vocaluxe.Screens
|
||||
@@ -284,7 +285,7 @@ namespace Vocaluxe.Screens
|
||||
ressourceOK &= CDataBase.GetCreditsRessource("babene03.png", ref _TexNameBabene03);
|
||||
|
||||
if (!ressourceOK)
|
||||
CLog.LogError("Could not load all ressources!", true, true);
|
||||
CLog.Fatal("Could not load all ressources!");
|
||||
|
||||
//Prepare Text
|
||||
int lastY = 280;
|
||||
|
||||
@@ -15,10 +15,12 @@
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using Vocaluxe.Base;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Log;
|
||||
using VocaluxeLib.Menu;
|
||||
|
||||
namespace Vocaluxe.Screens
|
||||
@@ -42,6 +44,8 @@ namespace Vocaluxe.Screens
|
||||
private bool _IntroOutPlayed;
|
||||
private CVideoPlayer[] _Intros;
|
||||
|
||||
private IDisposable _TimerLoadSongsFull;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
@@ -122,8 +126,9 @@ namespace Vocaluxe.Screens
|
||||
foreach (CVideoPlayer videoPlayer in _Intros)
|
||||
videoPlayer.PreLoad();
|
||||
}
|
||||
|
||||
CLog.StartBenchmark("Load Songs Full");
|
||||
|
||||
_TimerLoadSongsFull = CBenchmark.Time("Loaded Songs Full");
|
||||
|
||||
_SongLoaderThread = new Thread(CSongs.LoadSongs) {Name = "SongLoader", IsBackground = true};
|
||||
_SongLoaderThread.Start();
|
||||
CBackgroundMusic.OwnSongsAvailable = false;
|
||||
@@ -176,12 +181,14 @@ namespace Vocaluxe.Screens
|
||||
foreach (CVideoPlayer videoPlayer in _Intros)
|
||||
videoPlayer.Close();
|
||||
|
||||
CLog.StopBenchmark("Load Songs Full");
|
||||
// Stop the song full load timer
|
||||
_TimerLoadSongsFull.Dispose();
|
||||
|
||||
//Init Playlists
|
||||
CLog.StartBenchmark("Init Playlists");
|
||||
CPlaylists.Init();
|
||||
CLog.StopBenchmark("Init Playlists");
|
||||
using (CBenchmark.Time("Init Playlists"))
|
||||
{
|
||||
CPlaylists.Init();
|
||||
}
|
||||
}
|
||||
|
||||
private void _CheckStartIntroVideos()
|
||||
|
||||
@@ -22,6 +22,7 @@ using Vocaluxe.Lib.Webcam;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Menu;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace Vocaluxe.Screens
|
||||
{
|
||||
@@ -205,7 +206,7 @@ namespace Vocaluxe.Screens
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CLog.LogError("Error on listing webcam capabilities: " + e.Message);
|
||||
CLog.Error("Error on listing webcam capabilities: " + e.Message);
|
||||
}
|
||||
|
||||
_SelectSlides[_SelectSlideWebcamDevices].Visible = ssVisible;
|
||||
|
||||
@@ -27,6 +27,7 @@ using Vocaluxe.Base.Fonts;
|
||||
using Vocaluxe.Lib.Sound;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Log;
|
||||
using VocaluxeLib.Menu;
|
||||
using VocaluxeLib.Menu.SingNotes;
|
||||
using VocaluxeLib.Songs;
|
||||
@@ -1043,7 +1044,7 @@ namespace Vocaluxe.Screens
|
||||
|
||||
if (song == null)
|
||||
{
|
||||
CLog.LogError("Critical Error! ScreenSing.LoadNextSong() song is null!");
|
||||
CLog.Error("Critical Error! ScreenSing.LoadNextSong() song is null!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -158,9 +158,15 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.ServiceModel.Web" />
|
||||
@@ -220,7 +226,6 @@
|
||||
<Compile Include="Base\CGame.cs" />
|
||||
<Compile Include="Base\CController.cs" />
|
||||
<Compile Include="Base\CLanguage.cs" />
|
||||
<Compile Include="Base\CLog.cs" />
|
||||
<Compile Include="Base\CMain.cs" />
|
||||
<Compile Include="Base\CObservable.cs" />
|
||||
<Compile Include="Base\CParty.cs" />
|
||||
@@ -258,6 +263,12 @@
|
||||
<Compile Include="Lib\Video\Acinerella\CDecoderThread.cs" />
|
||||
<Compile Include="Lib\Video\Acinerella\CFramebuffer.cs" />
|
||||
<Compile Include="Lib\Sound\Record\CDelayTest.cs" />
|
||||
<Compile Include="Reporting\Reporter.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Reporting\Reporter.Designer.cs">
|
||||
<DependentUpon>Reporter.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Screens\CPopupScreenServerQR.cs" />
|
||||
<Compile Include="Screens\CScreenOptionsVideoAdjustments.cs" />
|
||||
<Compile Include="SongQueue\CSongQueue.cs" />
|
||||
@@ -488,6 +499,11 @@
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Service References\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Reporting\Reporter.resx">
|
||||
<DependentUpon>Reporter.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">xcopy /E /D /Y "$(ProjectDir)\Website" "$(SolutionDir)\PhoneGap"</PostBuildEvent>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net471" />
|
||||
<package id="vocaluxe.dependencies" version="1.0.11" targetFramework="net40" />
|
||||
<package id="vocaluxe.dependencies.acinerella" version="1.0.5" targetFramework="net40" />
|
||||
<package id="vocaluxe.dependencies.aforgevideo" version="1.0.1" targetFramework="net40" />
|
||||
|
||||
@@ -22,7 +22,6 @@ namespace VocaluxeLib
|
||||
public static IConfig Config;
|
||||
public static ISettings Settings;
|
||||
public static IThemes Themes;
|
||||
public static ILog Log;
|
||||
public static IBackgroundMusic BackgroundMusic;
|
||||
public static IDrawing Drawing;
|
||||
public static IGraphics Graphics;
|
||||
@@ -39,14 +38,13 @@ namespace VocaluxeLib
|
||||
public static IControllers Controller;
|
||||
public static IPlaylist Playlist;
|
||||
|
||||
public static void Assign(IConfig config, ISettings settings, IThemes themes, ILog log, IBackgroundMusic backgroundMusic,
|
||||
public static void Assign(IConfig config, ISettings settings, IThemes themes, IBackgroundMusic backgroundMusic,
|
||||
IDrawing draw, IGraphics graphics, IFonts fonts, ILanguage language, IGame game, IProfiles profiles, IRecording record,
|
||||
ISongs songs, IVideo video, ISound sound, ICover cover, IDataBase dataBase, IControllers controller, IPlaylist playlist)
|
||||
{
|
||||
Config = config;
|
||||
Settings = settings;
|
||||
Themes = themes;
|
||||
Log = log;
|
||||
BackgroundMusic = backgroundMusic;
|
||||
Drawing = draw;
|
||||
Graphics = graphics;
|
||||
|
||||
@@ -20,6 +20,7 @@ using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace VocaluxeLib
|
||||
{
|
||||
@@ -297,7 +298,7 @@ namespace VocaluxeLib
|
||||
{
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
CBase.Log.LogError("Can't find File: " + filePath);
|
||||
CLog.Error("Can't find File: " + filePath);
|
||||
return null;
|
||||
}
|
||||
Bitmap bmp;
|
||||
@@ -307,7 +308,7 @@ namespace VocaluxeLib
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CBase.Log.LogError("Error loading bitmap: " + filePath);
|
||||
CLog.Error("Error loading bitmap: " + filePath);
|
||||
return null;
|
||||
}
|
||||
return bmp;
|
||||
|
||||
@@ -19,6 +19,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Drawing;
|
||||
using System.Runtime.CompilerServices;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Game;
|
||||
using VocaluxeLib.Menu;
|
||||
@@ -165,13 +166,6 @@ namespace VocaluxeLib
|
||||
IMenu GetScreen(EScreen screen);
|
||||
}
|
||||
|
||||
public interface ILog
|
||||
{
|
||||
void LogError(string errorText, bool showMsg = false, bool exit = false);
|
||||
void LogDebug(string text);
|
||||
void LogSongInfo(string text);
|
||||
}
|
||||
|
||||
public interface IFonts
|
||||
{
|
||||
RectangleF GetTextBounds(CText text);
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
#region license
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using VocaluxeLib.Utils;
|
||||
|
||||
namespace VocaluxeLib.Log
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for Benchmarks.
|
||||
/// Can be used as instance or through the static wrappers.
|
||||
/// </summary>
|
||||
public class CBenchmark : IDisposable
|
||||
{
|
||||
// Pool of stop watches shared between all instances (we can get more than 5 but it only keeps 5)
|
||||
private static readonly CObjectPool<Stopwatch> _WatchesPool = new CObjectPool<Stopwatch>(() => new Stopwatch(), 5);
|
||||
private static readonly double _NanosecPerTick = (1000.0 * 1000.0 * 1000.0) / Stopwatch.Frequency;
|
||||
|
||||
// The stop watch used by this instance
|
||||
private Stopwatch _Watch = null;
|
||||
// The operation name the will be written to the log on events for this instance
|
||||
private readonly string _OperationName;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new benchmark instance.
|
||||
/// </summary>
|
||||
/// <param name="operationName">The name of the operation (will be used for log messages).</param>
|
||||
public CBenchmark(string operationName)
|
||||
{
|
||||
_OperationName = operationName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts this benchmark.
|
||||
/// </summary>
|
||||
public void Start()
|
||||
{
|
||||
if (_Watch != null)
|
||||
throw new InvalidOperationException("Timer is already running.");
|
||||
_Watch = _WatchesPool.GetObject();
|
||||
_Watch.Restart();
|
||||
CLog.Information("Started {StartedOperation}", CLog.Params(_OperationName));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops this benchmark.
|
||||
/// </summary>
|
||||
/// <param name="success">If true a success message will be added to the log otherwise a message for failure.</param>
|
||||
public void Stop(bool success = true)
|
||||
{
|
||||
if (_Watch == null)
|
||||
throw new InvalidOperationException("Timer is not running.");
|
||||
_Watch.Stop();
|
||||
double duration = _GetElapsedTime(_Watch);
|
||||
|
||||
_WatchesPool.PutObject(_Watch);
|
||||
_Watch = null;
|
||||
if (success)
|
||||
CLog.Information("Finished {StartedOperation} successfully in {Duration:#,##0.00}ms", CLog.Params(_OperationName, duration));
|
||||
else
|
||||
CLog.Information("Failed {StartedOperation} in {Duration:#,##0.00}ms", CLog.Params(_OperationName, duration));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method to extract the elapsed time from a stopwatch.
|
||||
/// </summary>
|
||||
/// <param name="watch">The stopwatch.</param>
|
||||
/// <returns>The elapsed time of the given stop watch.</returns>
|
||||
private double _GetElapsedTime(Stopwatch watch)
|
||||
{
|
||||
if (Stopwatch.IsHighResolution && _NanosecPerTick > 0)
|
||||
return (float)((_NanosecPerTick * watch.ElapsedTicks) / (1000.0 * 1000.0));
|
||||
else
|
||||
return watch.ElapsedMilliseconds;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ends a possibly running benchmark (sucessfully).
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (_Watch != null)
|
||||
Stop();
|
||||
}
|
||||
|
||||
#region Static functions
|
||||
|
||||
/// <summary>
|
||||
/// Logs the time from now to disposal of the returned object.
|
||||
/// </summary>
|
||||
/// <param name="operationName">The name of the operation (will be used for log messages).</param>
|
||||
/// <returns>Object which needs to be disposed to stop the benchmark.</returns>
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// using(CBenchmark.Time("TestOperation")){
|
||||
/// //do someting
|
||||
/// }
|
||||
/// </code>
|
||||
/// </example>
|
||||
public static IDisposable Time(string operationName)
|
||||
{
|
||||
CBenchmark benchmark = new CBenchmark(operationName);
|
||||
benchmark.Start();
|
||||
return benchmark;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs the time from now to the call of End() on the returned object (== success) or it's disposal (== failure).
|
||||
/// </summary>
|
||||
/// <param name="operationName">The name of the operation (will be used for log messages).</param>
|
||||
/// <returns>Object to stop the benchmark.</returns>
|
||||
/// <example>
|
||||
/// <code>
|
||||
/// using(var op = CBenchmark.Begin("TestOperation")){
|
||||
/// //do someting that could fail
|
||||
/// op.End();
|
||||
/// }
|
||||
/// </code>
|
||||
/// </example>
|
||||
public static COperation Begin(string operationName)
|
||||
{
|
||||
CBenchmark benchmark = new CBenchmark(operationName);
|
||||
benchmark.Start();
|
||||
return new COperation(benchmark);
|
||||
}
|
||||
|
||||
#region Helper class for operation
|
||||
|
||||
/// <summary>
|
||||
/// Helper object to end a benchmark (End() for success and Dispose() for failure).
|
||||
/// </summary>
|
||||
public class COperation : IDisposable
|
||||
{
|
||||
private readonly CBenchmark _Benchmark;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the benchmark helper object.
|
||||
/// </summary>
|
||||
/// <param name="benchmark">The associated benchmark object.</param>
|
||||
internal COperation(CBenchmark benchmark)
|
||||
{
|
||||
_Benchmark = benchmark;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// End the associated benchmark sucessfully.
|
||||
/// </summary>
|
||||
public void End()
|
||||
{
|
||||
_Benchmark.Stop(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// End the associated benchmark not sucessfully.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
_Benchmark.Stop(false);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
#region license
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Serilog;
|
||||
using VocaluxeLib.Log.Enricher;
|
||||
using VocaluxeLib.Log.Rolling;
|
||||
using VocaluxeLib.Log.Serilog;
|
||||
|
||||
namespace VocaluxeLib.Log
|
||||
{
|
||||
public static partial class CLog
|
||||
{
|
||||
private static readonly StringBuilder _MainLogStringBuilder = new StringBuilder();
|
||||
private static readonly StringWriter _MainLogStringWriter = new StringWriter(_MainLogStringBuilder);
|
||||
|
||||
private static ILogger _MainLog = new CSilentLogger();
|
||||
private static ILogger _SongLog = new CSilentLogger();
|
||||
private static string _LogFolder;
|
||||
private static string _CrashMarkerFilePath;
|
||||
private static ShowReporterDelegate _ShowReporterFunc;
|
||||
private static string _CurrentVersion;
|
||||
|
||||
private const string _MainLogTemplate = "[{TimeStampFromStart}] [{Level}] {Message}{NewLine}{Properties}{NewLine}{Exception}";
|
||||
private const string _SongLogTemplate = "{Message}{NewLine}Additional info:{Properties}{NewLine}{Exception}";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the logging framework.
|
||||
/// </summary>
|
||||
/// <param name="logFolder">The folder where to write the log files.</param>
|
||||
/// <param name="fileNameMainLog">The name of the main log.</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="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>
|
||||
public static void Init(string logFolder, string fileNameMainLog, string fileNameSongInfoLog, string fileNameCrashMarker, string currentVersion, ShowReporterDelegate showReporterFunc)
|
||||
{
|
||||
_LogFolder = logFolder;
|
||||
_ShowReporterFunc = showReporterFunc;
|
||||
_CurrentVersion = currentVersion;
|
||||
|
||||
_CrashMarkerFilePath = Path.Combine(_LogFolder, fileNameCrashMarker);
|
||||
|
||||
// Creates the log directory if it does not exist
|
||||
if (!Directory.Exists(_LogFolder))
|
||||
Directory.CreateDirectory(_LogFolder);
|
||||
|
||||
var mainLogFilePath = Path.Combine(_LogFolder, fileNameMainLog);
|
||||
var songLogFilePath = Path.Combine(_LogFolder, fileNameSongInfoLog);
|
||||
|
||||
// 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 && File.Exists(mainLogFilePath))
|
||||
{
|
||||
string logContent = File.ReadAllText(mainLogFilePath, Encoding.UTF8);
|
||||
_ShowReporterFunc(crash:true, showContinue:true, vocaluxeVersionTag:versionTag, log:logContent, lastError:"Vocaluxe crashed while the last execution.");
|
||||
}
|
||||
}
|
||||
|
||||
// Write new marker
|
||||
File.WriteAllText(_CrashMarkerFilePath, _CurrentVersion, Encoding.UTF8);
|
||||
|
||||
CLogFileRoller.RollLogs(mainLogFilePath, 2);
|
||||
CLogFileRoller.RollLogs(songLogFilePath, 2);
|
||||
|
||||
_MainLog = new LoggerConfiguration()
|
||||
.Enrich.WithThreadId()
|
||||
.Enrich.FromLogContext()
|
||||
.Enrich.WithTimeStampFromStart()
|
||||
.WriteTo.TextWriter(_MainLogStringWriter, outputTemplate: _MainLogTemplate)
|
||||
// Json can be activated by adding "new CompactJsonFormatter()" as first argument
|
||||
.WriteTo.File(mainLogFilePath, flushToDiskInterval: TimeSpan.FromSeconds(30), outputTemplate: _MainLogTemplate)
|
||||
#if DEBUG
|
||||
.WriteTo.Console(outputTemplate: _MainLogTemplate)
|
||||
#endif
|
||||
.CreateLogger();
|
||||
|
||||
_SongLog = new LoggerConfiguration()
|
||||
.WriteTo.File(songLogFilePath, flushToDiskInterval: TimeSpan.FromSeconds(60), outputTemplate: _SongLogTemplate)
|
||||
#if DEBUG
|
||||
.WriteTo.Console(outputTemplate: "[SongInfo] " + _SongLogTemplate)
|
||||
#endif
|
||||
.CreateLogger();
|
||||
|
||||
// Adding first line to log with information about this run
|
||||
Information("Starting to log", Params( new { Version = _CurrentVersion}, new { StartDate = DateTime.Now}, new { Id = Guid.NewGuid() } ) );
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Close all log files and the close the logging framework.
|
||||
/// </summary>
|
||||
public static void Close()
|
||||
{
|
||||
if (!(_MainLog is CSilentLogger))
|
||||
{
|
||||
ILogger loggerToDispose = _MainLog;
|
||||
|
||||
_MainLog = new CSilentLogger();
|
||||
(_MainLog as IDisposable)?.Dispose();
|
||||
}
|
||||
|
||||
if (!(_SongLog is CSilentLogger))
|
||||
{
|
||||
ILogger loggerToDispose = _MainLog;
|
||||
|
||||
_SongLog = new CSilentLogger();
|
||||
(_SongLog as IDisposable)?.Dispose();
|
||||
}
|
||||
|
||||
// Delete the crash marker
|
||||
File.Delete(_CrashMarkerFilePath);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show the report assistant.
|
||||
/// </summary>
|
||||
/// <param name="messageTemplate">Last error message template.</param>
|
||||
/// <param name="propertyValues">Data to fill the last error message template.</param>
|
||||
/// <param name="crash">True if the crash version of the message should be shown.</param>
|
||||
/// <param name="showContinue">True if the assistant should show a continue butoon, exit button otherwise.</param>
|
||||
public static void ShowLogAssistant(string messageTemplate, object[] propertyValues, bool crash = false, bool showContinue = true)
|
||||
{
|
||||
// Flush the _MainLogStringWriter to get the latest entries to _MainLogStringBuilder
|
||||
_MainLogStringWriter.Flush();
|
||||
// Show the Reporter
|
||||
_ShowReporterFunc(crash: crash, showContinue: showContinue, vocaluxeVersionTag: _CurrentVersion, log: _MainLogStringBuilder.ToString(), lastError: _FormatMessageTemplate(messageTemplate, propertyValues));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Simple version of inserting values into a message template (have not the same result as the original)
|
||||
/// </summary>
|
||||
/// <param name="template">The template to fill in the data.</param>
|
||||
/// <param name="propertyValues">The values to fill in.</param>
|
||||
/// <returns>The filled template.</returns>
|
||||
private static string _FormatMessageTemplate(string template, object[] propertyValues)
|
||||
{
|
||||
if (propertyValues == null)
|
||||
{
|
||||
return template;
|
||||
}
|
||||
|
||||
Regex theRegex = new Regex(@"{[^}]+}");
|
||||
|
||||
int i = 0;
|
||||
return theRegex.Replace(template, delegate(Match match)
|
||||
{
|
||||
if (propertyValues.Length >= i)
|
||||
return match.Value;
|
||||
return propertyValues[i++].ToString();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,224 @@
|
||||
<#
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
#>
|
||||
<#@ template debug="false" hostspecific="false" language="C#" #>
|
||||
<#@ assembly name="System.Core" #>
|
||||
<#@ import namespace="System.Linq" #>
|
||||
<#@ import namespace="System.Text" #>
|
||||
<#@ import namespace="System.Collections.Generic" #>
|
||||
<#@ output extension=".cs" #>
|
||||
#region license
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using Serilog.Context;
|
||||
using Serilog.Core;
|
||||
|
||||
namespace VocaluxeLib.Log
|
||||
{
|
||||
public static partial class CLog
|
||||
{
|
||||
private static Regex _PropertiesRegex = new Regex("{[^}]+}");
|
||||
|
||||
public static object[] Params(params object[] propertyValues)
|
||||
{
|
||||
return propertyValues;
|
||||
}
|
||||
|
||||
<# foreach (var Log in new[]{"Main","Song"}) { #>
|
||||
<# if(Log == "Song") { #>
|
||||
<# PushIndent(" "); #>
|
||||
|
||||
[SuppressMessage("ReSharper", "MemberHidesStaticFromOuterClass")]
|
||||
public static class CSongLog
|
||||
{
|
||||
<# } #>
|
||||
<# foreach (var LogLevel in new[]{"Verbose","Debug", "Information", "Warning", "Error", "Fatal"}) { #>
|
||||
<# if(LogLevel == "Fatal" && Log == "Song") continue; #>
|
||||
|
||||
#region <#= LogLevel #> functions
|
||||
|
||||
/// <summary>
|
||||
/// Write an event with the <#= LogLevel #> level to the <#= LogLevel #> log<#= LogLevel == "Fatal"?" and TERMINATES the appication":"" #>.
|
||||
/// </summary>
|
||||
/// <param name="messageTemplate">Message template for this event.</param>
|
||||
<# if(Log == "Main") { #>
|
||||
/// <param name="show">True if an message should be shown to the user, false otherwise.</param>
|
||||
<# } #>
|
||||
/// <param name="callerMethodeName">Don't use! The methode name of the caller will be filled automatically by the compiler.</param>
|
||||
/// <param name="callerFilePath">Don't use! The filepath of the caller will be filled automatically by the compiler.</param>
|
||||
/// <param name="callerLineNumer">Don't use! The line number of the caller will be filled automatically by the compiler.</param>
|
||||
[MessageTemplateFormatMethod("messageTemplate")]
|
||||
public static void <#= LogLevel #>(string messageTemplate, <#= Log == "Main"?(LogLevel == "Fatal"?"bool show = true, ":"bool show = false, "):"" #>[CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1)
|
||||
{
|
||||
using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer}))
|
||||
{
|
||||
<#= Log == "Main"?"_MainLog":"_SongLog" #>.<#= LogLevel #>(messageTemplate);
|
||||
}
|
||||
<# if(Log == "Main") { #>
|
||||
if(show)
|
||||
ShowLogAssistant(messageTemplate, null<#= LogLevel == "Fatal"?", true, false":"" #>);
|
||||
<# } #>
|
||||
<# if(LogLevel == "Fatal") { #>
|
||||
|
||||
// Close logs and exit
|
||||
Close();
|
||||
Environment.Exit(Environment.ExitCode);
|
||||
<# } #>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write an event with the <#= LogLevel #> level with additional propertyValues to the <#= LogLevel #> log<#= LogLevel == "Fatal"?" and TERMINATES the appication":"" #>.
|
||||
/// </summary>
|
||||
/// <param name="messageTemplate">Message template for this event.</param>
|
||||
/// <param name="propertyValues">Data inserted into the message template.</param>
|
||||
<# if(Log == "Main") { #>
|
||||
/// <param name="show">True if an message should be shown to the user, false otherwise.</param>
|
||||
<# } #>
|
||||
/// <param name="callerMethodeName">Don't use! The methode name of the caller will be filled automatically by the compiler.</param>
|
||||
/// <param name="callerFilePath">Don't use! The filepath of the caller will be filled automatically by the compiler.</param>
|
||||
/// <param name="callerLineNumer">Don't use! The line number of the caller will be filled automatically by the compiler.</param>
|
||||
[MessageTemplateFormatMethod("messageTemplate")]
|
||||
public static void <#= LogLevel #>(string messageTemplate, object[] propertyValues, <#= Log == "Main"?(LogLevel == "Fatal"?"bool show = true, ":"bool show = false, "):"" #>[CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1)
|
||||
{
|
||||
using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer}))
|
||||
{
|
||||
int usedPropertiesCount = _PropertiesRegex.Matches(messageTemplate).Cast<Match>().Select(m => m.Value).Distinct().Count();
|
||||
|
||||
if (propertyValues.Length > usedPropertiesCount)
|
||||
{
|
||||
using (LogContext.PushProperty("AdditionalData", propertyValues.Skip(usedPropertiesCount)))
|
||||
{
|
||||
<#= Log == "Main"?"_MainLog":"_SongLog" #>.<#= LogLevel #>(messageTemplate, propertyValues);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<#= Log == "Main"?"_MainLog":"_SongLog" #>.<#= LogLevel #>(messageTemplate, propertyValues);
|
||||
}
|
||||
}
|
||||
<# if(Log == "Main") { #>
|
||||
if(show)
|
||||
ShowLogAssistant(messageTemplate, propertyValues<#= LogLevel == "Fatal"?", true, false":"" #>);
|
||||
<# } #>
|
||||
<# if(LogLevel == "Fatal") { #>
|
||||
|
||||
// Close logs and exit
|
||||
Close();
|
||||
Environment.Exit(Environment.ExitCode);
|
||||
<# } #>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write an event with the <#= LogLevel #> level and associated exception to the <#= LogLevel #> log<#= LogLevel == "Fatal"?" and TERMINATES the appication":"" #>.
|
||||
/// </summary>
|
||||
/// <param name="exception">Exception of this event.</param>
|
||||
/// <param name="messageTemplate">Message template for this event.</param>
|
||||
<# if(Log == "Main") { #>
|
||||
/// <param name="show">True if an message should be shown to the user, false otherwise.</param>
|
||||
<# } #>
|
||||
/// <param name="callerMethodeName">Don't use! The methode name of the caller will be filled automatically by the compiler.</param>
|
||||
/// <param name="callerFilePath">Don't use! The filepath of the caller will be filled automatically by the compiler.</param>
|
||||
/// <param name="callerLineNumer">Don't use! The line number of the caller will be filled automatically by the compiler.</param>
|
||||
[MessageTemplateFormatMethod("messageTemplate")]
|
||||
public static void <#= LogLevel #>(Exception exception, string messageTemplate, <#= Log == "Main"?(LogLevel == "Fatal"?"bool show = true, ":"bool show = false, "):"" #>[CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1)
|
||||
{
|
||||
using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer}))
|
||||
{
|
||||
<#= Log == "Main"?"_MainLog":"_SongLog" #>.<#= LogLevel #>( exception, messageTemplate);
|
||||
}
|
||||
<# if(Log == "Main") { #>
|
||||
if(show)
|
||||
ShowLogAssistant(messageTemplate, null<#= LogLevel == "Fatal"?", true, false":"" #>);
|
||||
<# } #>
|
||||
<# if(LogLevel == "Fatal") { #>
|
||||
|
||||
// Close logs and exit
|
||||
Close();
|
||||
Environment.Exit(Environment.ExitCode);
|
||||
<# } #>
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write an event with the <#= LogLevel #> level with additional propertyValues and associated exception to the <#= LogLevel #> log<#= LogLevel == "Fatal"?" and TERMINATES the appication":"" #>.
|
||||
/// </summary>
|
||||
/// <param name="exception">Exception of this event.</param>
|
||||
/// <param name="messageTemplate">Message template for this event.</param>
|
||||
/// <param name="propertyValues">Data inserted into the message template.</param>
|
||||
<# if(Log == "Main") { #>
|
||||
/// <param name="show">True if an message should be shown to the user, false otherwise.</param>
|
||||
<# } #>
|
||||
/// <param name="callerMethodeName">Don't use! The methode name of the caller will be filled automatically by the compiler.</param>
|
||||
/// <param name="callerFilePath">Don't use! The filepath of the caller will be filled automatically by the compiler.</param>
|
||||
/// <param name="callerLineNumer">Don't use! The line number of the caller will be filled automatically by the compiler.</param>
|
||||
[MessageTemplateFormatMethod("messageTemplate")]
|
||||
public static void <#= LogLevel #>(Exception exception, string messageTemplate, object[] propertyValues, <#= Log == "Main"?(LogLevel == "Fatal"?"bool show = true, ":"bool show = false, "):"" #>[CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1)
|
||||
{
|
||||
using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer}))
|
||||
{
|
||||
int usedPropertiesCount = _PropertiesRegex.Matches(messageTemplate).Cast<Match>().Select(m => m.Value).Distinct().Count();
|
||||
|
||||
if (propertyValues.Length > usedPropertiesCount)
|
||||
{
|
||||
using (LogContext.PushProperty("AdditionalData", propertyValues.Skip(usedPropertiesCount)))
|
||||
{
|
||||
<#= Log == "Main"?"_MainLog":"_SongLog" #>.<#= LogLevel #>(exception, messageTemplate, propertyValues);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<#= Log == "Main"?"_MainLog":"_SongLog" #>.<#= LogLevel #>(exception, messageTemplate, propertyValues);
|
||||
}
|
||||
}
|
||||
<# if(Log == "Main") { #>
|
||||
if(show)
|
||||
ShowLogAssistant(messageTemplate, propertyValues<#= LogLevel == "Fatal"?", true, false":"" #>);
|
||||
<# } #>
|
||||
<# if(LogLevel == "Fatal") { #>
|
||||
|
||||
// Close logs and exit
|
||||
Close();
|
||||
Environment.Exit(Environment.ExitCode);
|
||||
<# } #>
|
||||
}
|
||||
|
||||
#endregion
|
||||
<# } #>
|
||||
<# if(Log == "Song") { #>
|
||||
<# PopIndent(); #>
|
||||
}
|
||||
<# } #>
|
||||
<# } #>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
#region license
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using Serilog;
|
||||
using Serilog.Configuration;
|
||||
using Serilog.Core;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace VocaluxeLib.Log.Enricher
|
||||
{
|
||||
public static class CWithTimeStampFromStartExtension
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public static LoggerConfiguration WithTimeStampFromStart(this LoggerEnrichmentConfiguration enrich)
|
||||
{
|
||||
return enrich.With(new CTimeStampFromStartEnricher());
|
||||
}
|
||||
|
||||
private class CTimeStampFromStartEnricher : ILogEventEnricher
|
||||
{
|
||||
private readonly DateTimeOffset _Start = DateTimeOffset.Now;
|
||||
|
||||
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory lepf)
|
||||
{
|
||||
logEvent.AddPropertyIfAbsent(
|
||||
lepf.CreateProperty("TimeStampFromStart", logEvent.Timestamp - _Start));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
#region license
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace VocaluxeLib.Log.Rolling
|
||||
{
|
||||
static class CLogFileRoller
|
||||
{
|
||||
public static void RollLogs(string mainLogFile, int numLogsToKeep)
|
||||
{
|
||||
_DeleteOldLogs(mainLogFile, numLogsToKeep);
|
||||
|
||||
string currentSourceFile = _GenerateRollLogFileName(mainLogFile, numLogsToKeep);
|
||||
|
||||
|
||||
for (var i = numLogsToKeep; i > 1; i--)
|
||||
{
|
||||
string currentTargetFile = currentSourceFile;
|
||||
currentSourceFile = _GenerateRollLogFileName(mainLogFile, i - 1);
|
||||
|
||||
if (File.Exists(currentSourceFile))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Move(currentSourceFile, currentTargetFile);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Cant log anything here as the log isn't initialized yet
|
||||
#if DEBUG
|
||||
Console.WriteLine($"Error moving old log file: {e.Message}");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (File.Exists(mainLogFile))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (numLogsToKeep > 0)
|
||||
File.Move(mainLogFile, currentSourceFile);
|
||||
else
|
||||
File.Delete(mainLogFile);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Cant log anything here as the log isn't initialized yet
|
||||
#if DEBUG
|
||||
Console.WriteLine($"Error moving old main log file: {e.Message}");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
IEnumerable<string> logFiles = Directory.EnumerateFiles($"{Path.GetDirectoryName(mainLogFile)}", $"{Path.GetFileNameWithoutExtension(mainLogFile)}*{Path.GetExtension(mainLogFile)}");
|
||||
foreach (string file in logFiles)
|
||||
{
|
||||
Match m = r.Match(file);
|
||||
if (m.Success)
|
||||
{
|
||||
int logNum = -1;
|
||||
Int32.TryParse(m.Groups[1].Value, out logNum);
|
||||
|
||||
if (logNum < 0 || logNum > numLogsToKeep - 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(file);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Cant log anything here as the log isn't initialized yet
|
||||
#if DEBUG
|
||||
Console.WriteLine($"Error deleting old log file: {e.Message}");
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static string _GenerateRollLogFileName(string mainLogFile, int number)
|
||||
{
|
||||
return $"{Path.GetDirectoryName(mainLogFile)}\\{Path.GetFileNameWithoutExtension(mainLogFile)}_{number}{Path.GetExtension(mainLogFile)}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,355 @@
|
||||
// From https://github.com/serilog/serilog/blob/4736691b7a0cd574e178c24a61caa8a9196a6a61/src/Serilog/Core/Pipeline/SilentLogger.cs
|
||||
|
||||
// Copyright 2013-2015 Serilog Contributors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Serilog;
|
||||
using Serilog.Core;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace VocaluxeLib.Log.Serilog
|
||||
{
|
||||
class CSilentLogger : ILogger
|
||||
{
|
||||
public ILogger ForContext(ILogEventEnricher enricher)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public ILogger ForContext(IEnumerable<ILogEventEnricher> enrichers)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public ILogger ForContext(string propertyName, object value, bool destructureObjects = false)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public ILogger ForContext<TSource>()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public ILogger ForContext(Type source)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Write(LogEvent logEvent)
|
||||
{
|
||||
}
|
||||
|
||||
public void Write(LogEventLevel level, string messageTemplate)
|
||||
{
|
||||
}
|
||||
|
||||
public void Write<T>(LogEventLevel level, string messageTemplate, T propertyValue)
|
||||
{
|
||||
}
|
||||
|
||||
public void Write<T0, T1>(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
|
||||
{
|
||||
}
|
||||
|
||||
public void Write<T0, T1, T2>(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
|
||||
{
|
||||
}
|
||||
|
||||
public void Write(LogEventLevel level, string messageTemplate, params object[] propertyValues)
|
||||
{
|
||||
}
|
||||
|
||||
public void Write(LogEventLevel level, Exception exception, string messageTemplate)
|
||||
{
|
||||
}
|
||||
|
||||
public void Write<T>(LogEventLevel level, Exception exception, string messageTemplate, T propertyValue)
|
||||
{
|
||||
}
|
||||
|
||||
public void Write<T0, T1>(LogEventLevel level, Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
|
||||
{
|
||||
}
|
||||
|
||||
public void Write<T0, T1, T2>(LogEventLevel level, Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
|
||||
{
|
||||
}
|
||||
|
||||
public void Write(LogEventLevel level, Exception exception, string messageTemplate, params object[] propertyValues)
|
||||
{
|
||||
}
|
||||
|
||||
public bool IsEnabled(LogEventLevel level)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Verbose(string messageTemplate)
|
||||
{
|
||||
}
|
||||
|
||||
public void Verbose<T>(string messageTemplate, T propertyValue)
|
||||
{
|
||||
}
|
||||
|
||||
public void Verbose<T0, T1>(string messageTemplate, T0 propertyValue0, T1 propertyValue1)
|
||||
{
|
||||
}
|
||||
|
||||
public void Verbose<T0, T1, T2>(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
|
||||
{
|
||||
}
|
||||
|
||||
public void Verbose(string messageTemplate, params object[] propertyValues)
|
||||
{
|
||||
}
|
||||
|
||||
public void Verbose(Exception exception, string messageTemplate)
|
||||
{
|
||||
}
|
||||
|
||||
public void Verbose<T>(Exception exception, string messageTemplate, T propertyValue)
|
||||
{
|
||||
}
|
||||
|
||||
public void Verbose<T0, T1>(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
|
||||
{
|
||||
}
|
||||
|
||||
public void Verbose<T0, T1, T2>(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
|
||||
{
|
||||
}
|
||||
|
||||
public void Verbose(Exception exception, string messageTemplate, params object[] propertyValues)
|
||||
{
|
||||
}
|
||||
|
||||
public void Debug(string messageTemplate)
|
||||
{
|
||||
}
|
||||
|
||||
public void Debug<T>(string messageTemplate, T propertyValue)
|
||||
{
|
||||
}
|
||||
|
||||
public void Debug<T0, T1>(string messageTemplate, T0 propertyValue0, T1 propertyValue1)
|
||||
{
|
||||
}
|
||||
|
||||
public void Debug<T0, T1, T2>(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
|
||||
{
|
||||
}
|
||||
|
||||
public void Debug(string messageTemplate, params object[] propertyValues)
|
||||
{
|
||||
}
|
||||
|
||||
public void Debug(Exception exception, string messageTemplate)
|
||||
{
|
||||
}
|
||||
|
||||
public void Debug<T>(Exception exception, string messageTemplate, T propertyValue)
|
||||
{
|
||||
}
|
||||
|
||||
public void Debug<T0, T1>(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
|
||||
{
|
||||
}
|
||||
|
||||
public void Debug<T0, T1, T2>(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
|
||||
{
|
||||
}
|
||||
|
||||
public void Debug(Exception exception, string messageTemplate, params object[] propertyValues)
|
||||
{
|
||||
}
|
||||
|
||||
public void Information(string messageTemplate)
|
||||
{
|
||||
}
|
||||
|
||||
public void Information<T>(string messageTemplate, T propertyValue)
|
||||
{
|
||||
}
|
||||
|
||||
public void Information<T0, T1>(string messageTemplate, T0 propertyValue0, T1 propertyValue1)
|
||||
{
|
||||
}
|
||||
|
||||
public void Information<T0, T1, T2>(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
|
||||
{
|
||||
}
|
||||
|
||||
public void Information(string messageTemplate, params object[] propertyValues)
|
||||
{
|
||||
}
|
||||
|
||||
public void Information(Exception exception, string messageTemplate)
|
||||
{
|
||||
}
|
||||
|
||||
public void Information<T>(Exception exception, string messageTemplate, T propertyValue)
|
||||
{
|
||||
}
|
||||
|
||||
public void Information<T0, T1>(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
|
||||
{
|
||||
}
|
||||
|
||||
public void Information<T0, T1, T2>(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
|
||||
{
|
||||
}
|
||||
|
||||
public void Information(Exception exception, string messageTemplate, params object[] propertyValues)
|
||||
{
|
||||
}
|
||||
|
||||
public void Warning(string messageTemplate)
|
||||
{
|
||||
}
|
||||
|
||||
public void Warning<T>(string messageTemplate, T propertyValue)
|
||||
{
|
||||
}
|
||||
|
||||
public void Warning<T0, T1>(string messageTemplate, T0 propertyValue0, T1 propertyValue1)
|
||||
{
|
||||
}
|
||||
|
||||
public void Warning<T0, T1, T2>(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
|
||||
{
|
||||
}
|
||||
|
||||
public void Warning(string messageTemplate, params object[] propertyValues)
|
||||
{
|
||||
}
|
||||
|
||||
public void Warning(Exception exception, string messageTemplate)
|
||||
{
|
||||
}
|
||||
|
||||
public void Warning<T>(Exception exception, string messageTemplate, T propertyValue)
|
||||
{
|
||||
}
|
||||
|
||||
public void Warning<T0, T1>(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
|
||||
{
|
||||
}
|
||||
|
||||
public void Warning<T0, T1, T2>(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
|
||||
{
|
||||
}
|
||||
|
||||
public void Warning(Exception exception, string messageTemplate, params object[] propertyValues)
|
||||
{
|
||||
}
|
||||
|
||||
public void Error(string messageTemplate)
|
||||
{
|
||||
}
|
||||
|
||||
public void Error<T>(string messageTemplate, T propertyValue)
|
||||
{
|
||||
}
|
||||
|
||||
public void Error<T0, T1>(string messageTemplate, T0 propertyValue0, T1 propertyValue1)
|
||||
{
|
||||
}
|
||||
|
||||
public void Error<T0, T1, T2>(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
|
||||
{
|
||||
}
|
||||
|
||||
public void Error(string messageTemplate, params object[] propertyValues)
|
||||
{
|
||||
}
|
||||
|
||||
public void Error(Exception exception, string messageTemplate)
|
||||
{
|
||||
}
|
||||
|
||||
public void Error<T>(Exception exception, string messageTemplate, T propertyValue)
|
||||
{
|
||||
}
|
||||
|
||||
public void Error<T0, T1>(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
|
||||
{
|
||||
}
|
||||
|
||||
public void Error<T0, T1, T2>(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
|
||||
{
|
||||
}
|
||||
|
||||
public void Error(Exception exception, string messageTemplate, params object[] propertyValues)
|
||||
{
|
||||
}
|
||||
|
||||
public void Fatal(string messageTemplate)
|
||||
{
|
||||
}
|
||||
|
||||
public void Fatal<T>(string messageTemplate, T propertyValue)
|
||||
{
|
||||
}
|
||||
|
||||
public void Fatal<T0, T1>(string messageTemplate, T0 propertyValue0, T1 propertyValue1)
|
||||
{
|
||||
}
|
||||
|
||||
public void Fatal<T0, T1, T2>(string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
|
||||
{
|
||||
}
|
||||
|
||||
public void Fatal(string messageTemplate, params object[] propertyValues)
|
||||
{
|
||||
}
|
||||
|
||||
public void Fatal(Exception exception, string messageTemplate)
|
||||
{
|
||||
}
|
||||
|
||||
public void Fatal<T>(Exception exception, string messageTemplate, T propertyValue)
|
||||
{
|
||||
}
|
||||
|
||||
public void Fatal<T0, T1>(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1)
|
||||
{
|
||||
}
|
||||
|
||||
public void Fatal<T0, T1, T2>(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2)
|
||||
{
|
||||
}
|
||||
|
||||
public void Fatal(Exception exception, string messageTemplate, params object[] propertyValues)
|
||||
{
|
||||
}
|
||||
|
||||
[MessageTemplateFormatMethod("messageTemplate")]
|
||||
public bool BindMessageTemplate(string messageTemplate, object[] propertyValues, out MessageTemplate parsedTemplate, out IEnumerable<LogEventProperty> boundProperties)
|
||||
{
|
||||
parsedTemplate = null;
|
||||
boundProperties = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool BindProperty(string propertyName, object value, bool destructureObjects, out LogEventProperty property)
|
||||
{
|
||||
property = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#region license
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vocaluxe is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
#endregion
|
||||
|
||||
namespace VocaluxeLib.Log
|
||||
{
|
||||
/// <summary>
|
||||
/// Shows a new instance of the log file reporter.
|
||||
/// </summary>
|
||||
/// <param name="crash">True if we are submitting a crash, false otherwise (e.g. error).</param>
|
||||
/// <param name="showContinue">True if the reporter show show a continue message, false if it should show an exit message.</param>
|
||||
/// <param name="vocaluxeVersionTag">The full version tag of this instance (like it is diplayed in the main menu).</param>
|
||||
/// <param name="log">The log to submit.</param>
|
||||
/// <param name="lastError">The last error message.</param>
|
||||
public delegate void ShowReporterDelegate(bool crash, bool showContinue, string vocaluxeVersionTag, string log, string lastError);
|
||||
}
|
||||
@@ -22,6 +22,7 @@ using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml.Serialization;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Log;
|
||||
using VocaluxeLib.Menu.SingNotes;
|
||||
using VocaluxeLib.Menu.SongMenu;
|
||||
using VocaluxeLib.Xml;
|
||||
@@ -224,22 +225,14 @@ namespace VocaluxeLib.Menu
|
||||
msg += "the file is for newer program versions! ";
|
||||
|
||||
msg += "Current screen version is " + _ScreenVersion;
|
||||
CBase.Log.LogError(msg);
|
||||
CLog.Error(msg);
|
||||
}
|
||||
foreach (IThemeable el in _Elements.Select(_GetElement).OfType<IThemeable>())
|
||||
el.LoadSkin();
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
CBase.Log.LogError("Error while reading " + ThemeName + ".xml", true, true);
|
||||
}
|
||||
catch (CXmlException e)
|
||||
{
|
||||
CBase.Log.LogError("Error while reading " + ThemeName + ".xml: " + e, true, true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError(e.Message + e.StackTrace, true, true);
|
||||
CLog.Fatal(e, "Error while reading {ThemeName}.xml", CLog.Params(ThemeName), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,7 +261,7 @@ namespace VocaluxeLib.Menu
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Error while saving theme-file: " + ThemeName + " " + e.Message, true);
|
||||
CLog.Error("Error while saving theme-file: " + ThemeName + " " + e.Message, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace VocaluxeLib.Menu
|
||||
{
|
||||
@@ -57,7 +58,7 @@ namespace VocaluxeLib.Menu
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CBase.Log.LogError("Can't find " + typeof(T).Name.Substring(1) + " Element \"" + key + "\" in " + _ParentName);
|
||||
CLog.Error("Can't find " + typeof(T).Name.Substring(1) + " Element \"" + key + "\" in " + _ParentName);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Xml.Serialization;
|
||||
using VocaluxeLib.Log;
|
||||
using VocaluxeLib.Xml;
|
||||
|
||||
namespace VocaluxeLib.Profile
|
||||
@@ -67,7 +68,7 @@ namespace VocaluxeLib.Profile
|
||||
{
|
||||
Avatar = CBase.Profiles.GetAvatarByFilename(value);
|
||||
if (Avatar == null)
|
||||
CBase.Log.LogError("Avatar '" + value + "' not found");
|
||||
CLog.Error("Avatar '" + value + "' not found");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +105,7 @@ namespace VocaluxeLib.Profile
|
||||
{
|
||||
if (_ConvertProfile(ref e))
|
||||
return true;
|
||||
CBase.Log.LogError("Error loading profile file " + Path.GetFileName(FilePath) + ": " + e.Message);
|
||||
CLog.Error("Error loading profile file " + Path.GetFileName(FilePath) + ": " + e.Message);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -21,6 +21,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace VocaluxeLib.Songs
|
||||
{
|
||||
@@ -350,7 +351,7 @@ namespace VocaluxeLib.Songs
|
||||
for (int i = 0; i < Notes.VoiceCount; i++)
|
||||
{
|
||||
if (!Notes.VoiceNames.IsSet(i))
|
||||
CBase.Log.LogError("Warning: Can't find #P" + (i + 1) + "-tag for duets in \"" + Artist + " - " + Title + "\".");
|
||||
CLog.Error("Warning: Can't find #P" + (i + 1) + "-tag for duets in \"" + Artist + " - " + Title + "\".");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace VocaluxeLib.Songs
|
||||
{
|
||||
@@ -69,30 +70,7 @@ namespace VocaluxeLib.Songs
|
||||
_Song.FileName = Path.GetFileName(filePath);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs a given message with file name and line#
|
||||
/// </summary>
|
||||
/// <param name="msg">Message</param>
|
||||
/// <param name="error">True prepends "Error: "; False prepends "Warning: "</param>
|
||||
/// <param name="withLineNr">Adds line#</param>
|
||||
private void _LogMsg(string msg, bool error, bool withLineNr)
|
||||
{
|
||||
msg = (error ? "Error: " : "Warning: ") + msg;
|
||||
if (withLineNr)
|
||||
msg += " in line #" + _LineNr;
|
||||
CBase.Log.LogSongInfo(msg + " (" + Path.Combine(_Song.Folder, _Song.FileName) + ")");
|
||||
}
|
||||
|
||||
private void _LogError(string msg, bool withLineNr = true)
|
||||
{
|
||||
_LogMsg(msg, true, withLineNr);
|
||||
}
|
||||
|
||||
private void _LogWarning(string msg, bool withLineNr = true)
|
||||
{
|
||||
_LogMsg(msg, false, withLineNr);
|
||||
}
|
||||
|
||||
|
||||
public bool ReadHeader(bool useSetEncoding = false)
|
||||
{
|
||||
@@ -144,7 +122,7 @@ namespace VocaluxeLib.Songs
|
||||
if (value == "")
|
||||
{
|
||||
_Song.UnknownTags.Add(line);
|
||||
_LogWarning("Empty value skipped");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Empty value skipped", CLog.Params(_Song.FileName));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -157,7 +135,7 @@ namespace VocaluxeLib.Songs
|
||||
{
|
||||
if (useSetEncoding)
|
||||
{
|
||||
_LogWarning("Duplicate encoding ignored");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Duplicate encoding ignored", CLog.Params(_Song.FileName));
|
||||
continue;
|
||||
}
|
||||
sr.Dispose();
|
||||
@@ -203,7 +181,7 @@ namespace VocaluxeLib.Songs
|
||||
}
|
||||
else
|
||||
{
|
||||
_LogError("Can't find audio file: " + Path.Combine(_Song.Folder, value));
|
||||
CLog.CSongLog.Error("[{SongFileName}] Can't find audio file: {AudioFile}", CLog.Params(_Song.FileName, Path.Combine(_Song.Folder, value)));
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@@ -214,19 +192,19 @@ namespace VocaluxeLib.Songs
|
||||
headerFlags |= EHeaderFlags.BPM;
|
||||
}
|
||||
else
|
||||
_LogWarning("Invalid BPM value");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Invalid BPM value: {Value}", CLog.Params(_Song.FileName, value));
|
||||
break;
|
||||
case "EDITION":
|
||||
if (value.Length > 1)
|
||||
_Song.Editions.Add(value);
|
||||
else
|
||||
_LogWarning("Invalid edition");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Invalid edition: {Value}", CLog.Params(_Song.FileName, value));
|
||||
break;
|
||||
case "GENRE":
|
||||
if (value.Length > 1)
|
||||
_Song.Genres.Add(value);
|
||||
else
|
||||
_LogWarning("Invalid genre");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Invalid genre: {Value}", CLog.Params(_Song.FileName, value));
|
||||
break;
|
||||
case "ALBUM":
|
||||
_Song.Album = value;
|
||||
@@ -236,13 +214,13 @@ namespace VocaluxeLib.Songs
|
||||
if (value.Length == 4 && int.TryParse(value, out num) && num > 0)
|
||||
_Song.Year = value;
|
||||
else
|
||||
_LogWarning("Invalid year");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Invalid year: {Value}", CLog.Params(_Song.FileName, value));
|
||||
break;
|
||||
case "LANGUAGE":
|
||||
if (value.Length > 1)
|
||||
_Song.Languages.Add(_UnifyLanguage(value));
|
||||
else
|
||||
_LogWarning("Invalid language");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Invalid language: {Value}", CLog.Params(_Song.FileName, value));
|
||||
break;
|
||||
case "COMMENT":
|
||||
if (!String.IsNullOrEmpty(_Song._Comment))
|
||||
@@ -253,49 +231,49 @@ namespace VocaluxeLib.Songs
|
||||
if (CHelper.TryParse(value, out _Song.Gap))
|
||||
_Song.Gap /= 1000f;
|
||||
else
|
||||
_LogWarning("Invalid gap");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Invalid gap: {Value}", CLog.Params(_Song.FileName, value));
|
||||
break;
|
||||
case "COVER":
|
||||
if (File.Exists(Path.Combine(_Song.Folder, value)))
|
||||
_Song.CoverFileName = value;
|
||||
else
|
||||
_LogWarning("Can't find cover file: " + Path.Combine(_Song.Folder, value));
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Can't find cover file: {MissingFile}", CLog.Params(_Song.FileName, Path.Combine(_Song.Folder, value)));
|
||||
break;
|
||||
case "BACKGROUND":
|
||||
if (File.Exists(Path.Combine(_Song.Folder, value)))
|
||||
_Song.BackgroundFileNames.Add(value);
|
||||
else
|
||||
_LogWarning("Can't find background file: " + Path.Combine(_Song.Folder, value));
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Can't find background file: {MissingFile}", CLog.Params(_Song.FileName, Path.Combine(_Song.Folder, value)));
|
||||
break;
|
||||
case "VIDEO":
|
||||
if (File.Exists(Path.Combine(_Song.Folder, value)))
|
||||
_Song.VideoFileName = value;
|
||||
else
|
||||
_LogWarning("Can't find video file: " + Path.Combine(_Song.Folder, value));
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Can't find video file: {MissingFile}", CLog.Params(_Song.FileName, Path.Combine(_Song.Folder, value)));
|
||||
break;
|
||||
case "VIDEOGAP":
|
||||
if (!CHelper.TryParse(value, out _Song.VideoGap))
|
||||
_LogWarning("Invalid videogap");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Invalid videogap: {Value}", CLog.Params(_Song.FileName, value));
|
||||
break;
|
||||
case "VIDEOASPECT":
|
||||
if (!CHelper.TryParse(value, out _Song.VideoAspect, true))
|
||||
_LogWarning("Invalid videoaspect");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Invalid videoaspect: {Value}", CLog.Params(_Song.FileName, value));
|
||||
break;
|
||||
case "START":
|
||||
if (!CHelper.TryParse(value, out _Song.Start))
|
||||
_LogWarning("Invalid start");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Invalid start: {Value}", CLog.Params(_Song.FileName, value));
|
||||
break;
|
||||
case "END":
|
||||
if (CHelper.TryParse(value, out _Song.Finish))
|
||||
_Song.Finish /= 1000f;
|
||||
else
|
||||
_LogWarning("Invalid end");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Invalid end: {Value}", CLog.Params(_Song.FileName, value));
|
||||
break;
|
||||
case "PREVIEWSTART":
|
||||
if (CHelper.TryParse(value, out _Song.Preview.StartTime) && _Song.Preview.StartTime >= 0f)
|
||||
_Song.Preview.Source = EDataSource.Tag;
|
||||
else
|
||||
_LogWarning("Invalid previewstart");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Invalid previewstart: {Value}", CLog.Params(_Song.FileName, value));
|
||||
break;
|
||||
case "PREVIEW":
|
||||
if (CHelper.TryParse(value, out _Song.Preview.StartTime) && _Song.Preview.StartTime >= 0f)
|
||||
@@ -305,19 +283,19 @@ namespace VocaluxeLib.Songs
|
||||
_Song.Preview.Source = EDataSource.Tag;
|
||||
}
|
||||
else
|
||||
_LogWarning("Invalid previewstart");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Invalid previewstart: {Value}", CLog.Params(_Song.FileName, value));
|
||||
break;
|
||||
case "MEDLEYSTARTBEAT":
|
||||
if (int.TryParse(value, out _Song.Medley.StartBeat))
|
||||
headerFlags |= EHeaderFlags.MedleyStartBeat;
|
||||
else
|
||||
_LogWarning("Invalid medleystartbeat");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Invalid medleystartbeat: {Value}", CLog.Params(_Song.FileName, value));
|
||||
break;
|
||||
case "MEDLEYENDBEAT":
|
||||
if (int.TryParse(value, out _Song.Medley.EndBeat))
|
||||
headerFlags |= EHeaderFlags.MedleyEndBeat;
|
||||
else
|
||||
_LogWarning("Invalid medleyendbeat");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Invalid medleyendbeat: {Value}", CLog.Params(_Song.FileName, value));
|
||||
break;
|
||||
case "ENDSHORT":
|
||||
if ((headerFlags & EHeaderFlags.BPM) != 0)
|
||||
@@ -329,7 +307,7 @@ namespace VocaluxeLib.Songs
|
||||
_Song.ShortEnd.Source = EDataSource.Tag;
|
||||
}
|
||||
else
|
||||
_LogWarning("Invalid shortendbeat");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Invalid shortendbeat: {Value}", CLog.Params(_Song.FileName, value));
|
||||
}
|
||||
break;
|
||||
case "CALCMEDLEY":
|
||||
@@ -364,7 +342,7 @@ namespace VocaluxeLib.Songs
|
||||
else
|
||||
{
|
||||
_Song.UnknownTags.Add(line);
|
||||
_LogWarning("Unknown tag: #" + identifier);
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Unknown tag: #{Identifier}", CLog.Params(_Song.FileName, identifier));
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -374,31 +352,32 @@ namespace VocaluxeLib.Songs
|
||||
if (sr.EndOfStream)
|
||||
{
|
||||
//No other data then header
|
||||
_LogError("Lyrics/Notes missing", false);
|
||||
CLog.CSongLog.Error("[{SongFileName}] Lyrics/Notes missing", CLog.Params(_Song.FileName));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((headerFlags & EHeaderFlags.Title) == 0)
|
||||
{
|
||||
_LogError("Title tag missing", false);
|
||||
CLog.CSongLog.Error("[{SongFileName}] Title tag missing", CLog.Params(_Song.FileName));
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((headerFlags & EHeaderFlags.Artist) == 0)
|
||||
{
|
||||
_LogError("Artist tag missing", false);
|
||||
CLog.CSongLog.Error("[{SongFileName}] Artist tag missing", CLog.Params(_Song.FileName));
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((headerFlags & EHeaderFlags.MP3) == 0)
|
||||
{
|
||||
_LogError("MP3 tag missing", false);
|
||||
CLog.CSongLog.Error("[{SongFileName}] MP3 tag missing", CLog.Params(_Song.FileName));
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((headerFlags & EHeaderFlags.BPM) == 0)
|
||||
{
|
||||
_LogError("BPM tag missing", false);
|
||||
CLog.CSongLog.Error("[{SongFileName}] BPM tag missing", CLog.Params(_Song.FileName));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -407,7 +386,7 @@ namespace VocaluxeLib.Songs
|
||||
{
|
||||
if (_Song.Medley.StartBeat > _Song.Medley.EndBeat)
|
||||
{
|
||||
_LogError("MedleyStartBeat is bigger than MedleyEndBeat in file", false);
|
||||
CLog.CSongLog.Error("[{SongFileName}] MedleyStartBeat is bigger than MedleyEndBeat in file: {StartBeat} > {EndBeat}", CLog.Params(_Song.FileName, _Song.Medley.StartBeat > _Song.Medley.EndBeat));
|
||||
headerFlags = headerFlags - EHeaderFlags.MedleyStartBeat - EHeaderFlags.MedleyEndBeat;
|
||||
}
|
||||
}
|
||||
@@ -433,7 +412,7 @@ namespace VocaluxeLib.Songs
|
||||
{
|
||||
if (sr != null)
|
||||
sr.Dispose();
|
||||
_LogError("Error reading txt header" + e.Message, false);
|
||||
CLog.CSongLog.Error(e, "[{SongFileName}] Error reading txt header with Message: {ExceptionMessage}", CLog.Params(e.Message, _Song.FileName));
|
||||
return false;
|
||||
}
|
||||
_Song.Encoding = sr.CurrentEncoding;
|
||||
@@ -530,7 +509,7 @@ namespace VocaluxeLib.Songs
|
||||
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
_LogError("The file does not exist", false);
|
||||
CLog.CSongLog.Error("[{SongFileName}] The file songfile does not exist", CLog.Params(_Song.FileName));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -579,7 +558,7 @@ namespace VocaluxeLib.Songs
|
||||
|
||||
if (!int.TryParse(line, out player))
|
||||
{
|
||||
_LogError("Wrong or missing number after \"P\"");
|
||||
CLog.CSongLog.Error("[{SongFileName}] Wrong or missing number after \"P\" (in line {LineNr})", CLog.Params(_Song.FileName, _LineNr));
|
||||
return false;
|
||||
}
|
||||
currentBeat = 0;
|
||||
@@ -593,25 +572,25 @@ namespace VocaluxeLib.Songs
|
||||
{
|
||||
if (noteData.Length == 3)
|
||||
{
|
||||
_LogWarning("Ignored note without text");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Ignored note without text (in line {LineNr})", CLog.Params(_Song.FileName, _LineNr));
|
||||
changesMade.NoTextNoteCt++;
|
||||
continue;
|
||||
}
|
||||
_LogError("Invalid note found");
|
||||
CLog.CSongLog.Error("[{SongFileName}] Invalid note found (in line {LineNr}): {noteData}", CLog.Params(_Song.FileName, _LineNr, noteData));
|
||||
sr.Dispose();
|
||||
return false;
|
||||
}
|
||||
int tone;
|
||||
if (!int.TryParse(noteData[0], out beat) || !int.TryParse(noteData[1], out length) || !int.TryParse(noteData[2], out tone))
|
||||
{
|
||||
_LogError("Invalid note found (non-numeric values)");
|
||||
CLog.CSongLog.Error("[{SongFileName}] Invalid note found (non-numeric values) (in line {LineNr}): {noteData}", CLog.Params(_Song.FileName, _LineNr, noteData));
|
||||
sr.Dispose();
|
||||
return false;
|
||||
}
|
||||
string text = noteData[3].TrimMultipleWs();
|
||||
if (text == "")
|
||||
{
|
||||
_LogWarning("Ignored note without text");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Ignored note without text (in line {LineNr})", CLog.Params(_Song.FileName, _LineNr));
|
||||
changesMade.NoTextNoteCt++;
|
||||
continue;
|
||||
}
|
||||
@@ -622,12 +601,12 @@ namespace VocaluxeLib.Songs
|
||||
changesMade.ZeroLengthNoteCt++;
|
||||
if (_CurrentReadMode == ENoteReadMode.Normal && changesMade.ZeroLengthNoteCt > _MaxZeroNoteCt && changesMade.OverlapNoteCt <= _MaxOverlapNoteCt)
|
||||
{
|
||||
_LogWarning("Found more than " + _MaxZeroNoteCt + " note with length < 1. Trying alternative read mode.");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Found more than {MaxZeroNoteCt} notes with length < 1. Trying alternative read mode.", CLog.Params(_Song.FileName, _MaxZeroNoteCt));
|
||||
_CurrentReadMode = ENoteReadMode.ZeroBased;
|
||||
sr.Dispose();
|
||||
return ReadNotes(true);
|
||||
}
|
||||
_LogWarning("Ignored note with length < 1");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Ignored note with length < 1 (in line {LineNr})", CLog.Params(_Song.FileName, _LineNr));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -656,13 +635,13 @@ namespace VocaluxeLib.Songs
|
||||
changesMade.OverlapNoteCt++;
|
||||
if (changesMade.OverlapNoteCt > _MaxOverlapNoteCt && _CurrentReadMode == ENoteReadMode.ZeroBased)
|
||||
{
|
||||
_LogWarning("Found more than " + _MaxOverlapNoteCt + " overlapping notes. Using standard mode.");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Found more than {MaxOverlapNoteCt} overlapping notes. Using standard mode.", CLog.Params(_Song.FileName, _MaxOverlapNoteCt));
|
||||
_CurrentReadMode = ENoteReadMode.OneBased;
|
||||
sr.Dispose();
|
||||
return ReadNotes(true);
|
||||
}
|
||||
}
|
||||
_LogWarning("Ignored note for player " + (curPlayer + 1) + " because it overlaps with other note");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Ignored note for player {CurrentPlayerNumber} because it overlaps with other note (in line {LineNr})", CLog.Params(_Song.FileName, (curPlayer + 1), _LineNr));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -671,13 +650,13 @@ namespace VocaluxeLib.Songs
|
||||
string[] lineBreakData = line.Split(splitChars);
|
||||
if (lineBreakData.Length < 1)
|
||||
{
|
||||
_LogError("Invalid line break found (No beat)");
|
||||
CLog.CSongLog.Error("[{SongFileName}] Invalid line break found (No beat) (in line {LineNr}): {LineBreakData}", CLog.Params(_Song.FileName, _LineNr, lineBreakData));
|
||||
sr.Dispose();
|
||||
return false;
|
||||
}
|
||||
if (!int.TryParse(lineBreakData[0], out beat))
|
||||
{
|
||||
_LogError("Invalid line break found (Non-numeric value)");
|
||||
CLog.CSongLog.Error("[{SongFileName}] Invalid line break found (Non-numeric value) (in line {LineNr}): {LineBreakData}", CLog.Params(_Song.FileName, _LineNr, lineBreakData));
|
||||
sr.Dispose();
|
||||
return false;
|
||||
}
|
||||
@@ -687,7 +666,7 @@ namespace VocaluxeLib.Songs
|
||||
beat += currentBeat;
|
||||
if (lineBreakData.Length < 2 || !int.TryParse(lineBreakData[1], out length))
|
||||
{
|
||||
_LogWarning("Missing line break length");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Missing line break length (in line {LineNr}):{LineBreakData}", CLog.Params(_Song.FileName, _LineNr, lineBreakData));
|
||||
changesMade.NoLengthBreakCt++;
|
||||
currentBeat = beat;
|
||||
}
|
||||
@@ -697,7 +676,8 @@ namespace VocaluxeLib.Songs
|
||||
|
||||
if (lastNote != null && beat <= lastNote.EndBeat)
|
||||
{
|
||||
_LogWarning("Line break is before previous note end. Adjusted.");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Line break is before previous note end. Adjusted. (in line {LineNr})", CLog.Params(_Song.FileName, _LineNr));
|
||||
|
||||
changesMade.AjustedBreakCt++;
|
||||
if (_Song.Relative)
|
||||
currentBeat += lastNote.EndBeat - beat + 1;
|
||||
@@ -706,7 +686,7 @@ namespace VocaluxeLib.Songs
|
||||
|
||||
if (beat < 1)
|
||||
{
|
||||
_LogWarning("Ignored line break because position is < 1");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Ignored line break because position is < 1 (in line {LineNr})", CLog.Params(_Song.FileName, _LineNr));
|
||||
changesMade.InvalidPosBreakCt++;
|
||||
}
|
||||
else
|
||||
@@ -714,12 +694,12 @@ namespace VocaluxeLib.Songs
|
||||
foreach (int curPlayer in player.GetSetBits())
|
||||
{
|
||||
if (!_NewSentence(curPlayer, beat))
|
||||
_LogWarning("Ignored line break for player " + (curPlayer + 1) + " (Overlapping or duplicate)");
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Ignored line break for player {CurPlayerNr} (Overlapping or duplicate) (in line {LineNr})", CLog.Params(_Song.FileName, (curPlayer + 1) , _LineNr));
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_LogError("Unexpected or missing character (" + tag + ")");
|
||||
CLog.CSongLog.Error("[{SongFileName}] Unexpected or missing character ({Tag})", CLog.Params(_Song.FileName, tag));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -729,13 +709,13 @@ namespace VocaluxeLib.Songs
|
||||
CVoice voice = _Song.Notes.GetVoice(i);
|
||||
int emptyLines = voice.RemoveEmptyLines();
|
||||
if (emptyLines > 0)
|
||||
_LogWarning("Removed " + emptyLines + " empty lines from P" + ". This often indicates a problem with the line breaks in the file", false);
|
||||
CLog.CSongLog.Warning("[{SongFileName}] Removed {NumEmptyLines} empty lines from P .This often indicates a problem with the line breaks in the file", CLog.Params(_Song.FileName, emptyLines));
|
||||
voice.UpdateTimings();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_LogError("An unhandled exception occured (" + e.Message + ")");
|
||||
CLog.CSongLog.Error(e, "[{SongFileName}] An unhandled exception occured: {ExceptionMessage}", CLog.Params(_Song.FileName, e.Message));
|
||||
if (sr != null)
|
||||
sr.Dispose();
|
||||
return false;
|
||||
@@ -752,14 +732,13 @@ namespace VocaluxeLib.Songs
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_LogError("An unhandled exception occured (" + e.Message + ")", false);
|
||||
CLog.CSongLog.Error(e, "[{SongFileName}] An unhandled exception occured: {ExceptionMessage}", CLog.Params(_Song.FileName, e.Message));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (changesMade.IsModified)
|
||||
{
|
||||
string msg = "Automatic changes have been made to " + filePath + " Please check result!\r\n" + changesMade;
|
||||
CBase.Log.LogError("Warning: " + msg);
|
||||
CLog.Warning("Automatic changes have been made to {FilePath} Please check result!\r\n{ChangesMade}" , CLog.Params(filePath, changesMade));
|
||||
if (CBase.Config.GetSaveModifiedSongs() == EOffOn.TR_CONFIG_ON)
|
||||
{
|
||||
string name = Path.GetFileNameWithoutExtension(_Song.FileName);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace VocaluxeLib.Songs
|
||||
{
|
||||
@@ -207,12 +208,12 @@ namespace VocaluxeLib.Songs
|
||||
}
|
||||
catch (UnauthorizedAccessException)
|
||||
{
|
||||
CBase.Log.LogError("Cannot write " + filePath + ". Directory might be readonly or requires admin rights.");
|
||||
CLog.Error("Cannot write " + filePath + ". Directory might be readonly or requires admin rights.");
|
||||
return false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CBase.Log.LogError("Unhandled exception while writing " + filePath + ": " + e);
|
||||
CLog.Error("Unhandled exception while writing " + filePath + ": " + e);
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VocaluxeLib.Utils
|
||||
{
|
||||
// Modified version of https://docs.microsoft.com/en-us/dotnet/standard/collections/thread-safe/how-to-create-an-object-pool
|
||||
|
||||
/// <summary>
|
||||
/// Pool for objects.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of the objects in the pool.</typeparam>
|
||||
public class CObjectPool<T>
|
||||
{
|
||||
private readonly ConcurrentBag<T> _Objects;
|
||||
private readonly Func<T> _ObjectGenerator;
|
||||
private readonly int _Poolsize;
|
||||
|
||||
/// <summary>
|
||||
/// Create a new object pool.
|
||||
/// </summary>
|
||||
/// <param name="objectGenerator">Function witch generate a new object instance.</param>
|
||||
/// <param name="poolSize">Number of objects to keep in the pool.</param>
|
||||
public CObjectPool(Func<T> objectGenerator, int poolSize)
|
||||
{
|
||||
if (objectGenerator == null)
|
||||
throw new ArgumentNullException(nameof(objectGenerator));
|
||||
if (poolSize <= 0)
|
||||
throw new ArgumentNullException(nameof(poolSize));
|
||||
_Objects = new ConcurrentBag<T>();
|
||||
_ObjectGenerator = objectGenerator;
|
||||
_Poolsize = poolSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get an object (from the pool or a new one).
|
||||
/// </summary>
|
||||
/// <returns>An object instance.</returns>
|
||||
public T GetObject()
|
||||
{
|
||||
T item;
|
||||
if (_Objects.TryTake(out item)) return item;
|
||||
return _ObjectGenerator();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Put an intance back to the pool.
|
||||
/// </summary>
|
||||
/// <param name="item">The object instance that is given back to the pool.</param>
|
||||
public void PutObject(T item)
|
||||
{
|
||||
if(_Objects.Count < _Poolsize)
|
||||
_Objects.Add(item);
|
||||
else
|
||||
(item as IDisposable)?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,6 +82,27 @@
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Serilog.2.6.0\lib\net46\Serilog.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Serilog.Enrichers.Thread, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Serilog.Enrichers.Thread.3.0.0\lib\net45\Serilog.Enrichers.Thread.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Serilog.Sinks.Console, Version=3.1.1.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Serilog.Sinks.Console.3.1.1\lib\net45\Serilog.Sinks.Console.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Serilog.Sinks.File, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Serilog.Sinks.File.4.0.0\lib\net45\Serilog.Sinks.File.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Serilog.Sinks.TextWriter, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Serilog.Sinks.TextWriter.2.1.0\lib\net45\Serilog.Sinks.TextWriter.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
@@ -91,10 +112,21 @@
|
||||
<Compile Include="CEncoding.cs" />
|
||||
<Compile Include="CFading.cs" />
|
||||
<Compile Include="CFont.cs" />
|
||||
<Compile Include="Log\ShowReporterDelegate.cs" />
|
||||
<Compile Include="Log\CLog.cs" />
|
||||
<Compile Include="CVideoStream.cs" />
|
||||
<Compile Include="Extensions.cs" />
|
||||
<Compile Include="GlobalSuppressions.cs" />
|
||||
<Compile Include="IBasic.cs" />
|
||||
<Compile Include="Log\Enricher\CTimeStampFromStartEnricher.cs" />
|
||||
<Compile Include="Log\Rolling\CLogFileRoller.cs" />
|
||||
<Compile Include="Log\Serilog\CSilentLogger.cs" />
|
||||
<Compile Include="Log\CLogFunctions.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>CLogFunctions.tt</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Log\CBenchmark.cs" />
|
||||
<Compile Include="Menu\CBackground.cs" />
|
||||
<Compile Include="CBasic.cs" />
|
||||
<Compile Include="Menu\CButton.cs" />
|
||||
@@ -123,6 +155,7 @@
|
||||
<Compile Include="Menu\IThemeable.cs" />
|
||||
<Compile Include="Menu\SingNotes\CNoteBars.cs" />
|
||||
<Compile Include="Utils\Combinatorics\CCombinations.cs" />
|
||||
<Compile Include="Utils\ObjectPool.cs" />
|
||||
<Compile Include="XmlStructs.cs" />
|
||||
<Compile Include="Xml\CTypeExtensions.cs" />
|
||||
<Compile Include="Xml\CXmlDeserializer.cs" />
|
||||
@@ -160,6 +193,18 @@
|
||||
<Compile Include="Utils\Player\CSoundPlayer.cs" />
|
||||
<Compile Include="Xml\SFieldInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Log\CLogFunctions.tt">
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>CLogFunctions.cs</LastGenOutput>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
|
||||
@@ -24,6 +24,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace VocaluxeLib.Xml
|
||||
{
|
||||
@@ -173,7 +174,7 @@ namespace VocaluxeLib.Xml
|
||||
{
|
||||
if (e.IsError)
|
||||
throw e;
|
||||
CBase.Log.LogError(e.ToString());
|
||||
CLog.Error(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Serilog" version="2.6.0" targetFramework="net471" />
|
||||
<package id="Serilog.Enrichers.Thread" version="3.0.0" targetFramework="net471" />
|
||||
<package id="Serilog.Sinks.Console" version="3.1.1" targetFramework="net471" />
|
||||
<package id="Serilog.Sinks.File" version="4.0.0" targetFramework="net471" />
|
||||
<package id="Serilog.Sinks.TextWriter" version="2.1.0" targetFramework="net471" />
|
||||
</packages>
|
||||
@@ -3,7 +3,9 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Vocaluxe.Base;
|
||||
using Vocaluxe.Reporting;
|
||||
using VocaluxeLib;
|
||||
using VocaluxeLib.Log;
|
||||
using VocaluxeLib.PartyModes.Challenge;
|
||||
|
||||
namespace VocaluxeTests
|
||||
@@ -46,8 +48,7 @@ namespace VocaluxeTests
|
||||
public void TestRoundGeneration()
|
||||
{
|
||||
CBase.Game = new CBGame();
|
||||
CLog.Init();
|
||||
CBase.Log = new CBlog();
|
||||
CLog.Init(CSettings.FolderNameLogs, CSettings.FileNameMainLog, CSettings.FileNameSongLog, CSettings.FileNameCrashMarker, CSettings.GetFullVersionText(), CReporter.ShowReporterFunc);
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
for (int numPlayer = 1; numPlayer <= 20; numPlayer++)
|
||||
@@ -61,7 +62,7 @@ namespace VocaluxeTests
|
||||
Assert.IsTrue(rounds.Count >= numRounds);
|
||||
_CheckRounds(rounds, numPlayer);
|
||||
if (rounds.Count != numRounds)
|
||||
CBase.Log.LogDebug("Number of rounds does not match. Expected: " + numRounds + ", Is: " + rounds.Count + " for " + numPlayer + "/" +
|
||||
CLog.Debug("Number of rounds does not match. Expected: " + numRounds + ", Is: " + rounds.Count + " for " + numPlayer + "/" +
|
||||
((numPlayer < numMic) ? numPlayer : numMic));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user