diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index a552974b..5d4fb05a 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -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(_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(""); diff --git a/Vocaluxe/Base/CCover.cs b/Vocaluxe/Base/CCover.cs index 0a155740..6dea5e2f 100644 --- a/Vocaluxe/Base/CCover.cs +++ b/Vocaluxe/Base/CCover.cs @@ -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); diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs index 8887982f..d159679f 100644 --- a/Vocaluxe/Base/CDataBase.cs +++ b/Vocaluxe/Base/CDataBase.cs @@ -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; diff --git a/Vocaluxe/Base/CDraw.cs b/Vocaluxe/Base/CDraw.cs index 57f61ff2..08969aac 100644 --- a/Vocaluxe/Base/CDraw.cs +++ b/Vocaluxe/Base/CDraw.cs @@ -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; diff --git a/Vocaluxe/Base/CGraphics.cs b/Vocaluxe/Base/CGraphics.cs index 0c63169e..495090a8 100644 --- a/Vocaluxe/Base/CGraphics.cs +++ b/Vocaluxe/Base/CGraphics.cs @@ -26,6 +26,7 @@ using Vocaluxe.Base.Fonts; using Vocaluxe.Base.ThemeSystem; using Vocaluxe.Screens; using VocaluxeLib; +using VocaluxeLib.Log; using VocaluxeLib.Menu; namespace Vocaluxe.Base @@ -63,7 +64,7 @@ namespace Vocaluxe.Base public static void Init() { // Add Screens, must be the same order as in EScreens! - CLog.LogInformation("Build Screen List"); + CLog.Information("Build Screen List"); using (Operation.At(LogEventLevel.Information).Time("Build Screen List")) { _Screens.Add(new CScreenTest()); @@ -100,7 +101,7 @@ namespace Vocaluxe.Base GlobalAlpha = 1f; ZOffset = 0f; - CLog.LogInformation("Load Theme"); + CLog.Information("Load Theme"); using (Operation.At(LogEventLevel.Information).Time("Load Theme")) { LoadTheme(); @@ -121,7 +122,7 @@ namespace Vocaluxe.Base for (int i = 0; i < _Screens.Count; i++) { - CLog.LogInformation("Load Theme " + Enum.GetNames(typeof(EScreen))[i]); + CLog.Information("Load Theme " + Enum.GetNames(typeof(EScreen))[i]); using (Operation.At(LogEventLevel.Information).Time("Load Theme " + Enum.GetNames(typeof(EScreen))[i])) { _Screens[i].Init(); diff --git a/Vocaluxe/Base/CLanguage.cs b/Vocaluxe/Base/CLanguage.cs index d6b1cbe4..a7f6f1ec 100644 --- a/Vocaluxe/Base/CLanguage.cs +++ b/Vocaluxe/Base/CLanguage.cs @@ -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; } diff --git a/Vocaluxe/Base/CLog.cs b/Vocaluxe/Base/CLog.cs deleted file mode 100644 index 7b8af970..00000000 --- a/Vocaluxe/Base/CLog.cs +++ /dev/null @@ -1,277 +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 . -#endregion - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Runtime.CompilerServices; -using System.Text; -using System.Text.RegularExpressions; -using System.Windows.Forms; -using Serilog; -using Serilog.Configuration; -using Serilog.Core; -using Serilog.Context; -using Serilog.Events; -using Serilog.Formatting.Compact; - -namespace Vocaluxe.Base -{ - static class CLog - { - private static bool _Initialized; - - private static readonly StringBuilder _MainLogStringBuilder = new StringBuilder(); - private static readonly StringWriter _MainLogStringWriter = new StringWriter(_MainLogStringBuilder); - - private static Logger _MainLog; - private static Logger _SongInfoLog; - private static string _LogFolder; - - private const string _MainLogTemplate = "[{TimeStampFromStart}] [{Level}] {Message}{NewLine}{Properties}{NewLine}{Exception}"; - private const string _SongInfoLogTemplate = "{Message}{NewLine}Additional info:{Properties}{NewLine}{Exception}"; - - public static void Init(string logFolder) - { - _LogFolder = logFolder; - - _RollLogs(Path.Combine(_LogFolder, CSettings.FileNameMainLog), 2); - _RollLogs(Path.Combine(_LogFolder, CSettings.FileNameSongInfoLog), 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(Path.Combine(_LogFolder, CSettings.FileNameMainLog), flushToDiskInterval: TimeSpan.FromSeconds(30), outputTemplate: _MainLogTemplate) -#if DEBUG - .WriteTo.Console(outputTemplate: _MainLogTemplate) -#endif - .CreateLogger(); - - Log.Logger = _MainLog; - - _SongInfoLog = new LoggerConfiguration() - .WriteTo.File(Path.Combine(_LogFolder, CSettings.FileNameSongInfoLog), flushToDiskInterval: TimeSpan.FromSeconds(60), outputTemplate: _SongInfoLogTemplate) -#if DEBUG - .WriteTo.Console(outputTemplate: "[SongInfo] " + _SongInfoLogTemplate) -#endif - .CreateLogger(); - - _Initialized = true; - } - - - public static void Close() - { - if (_Initialized) - { - - _MainLog.Dispose(); - _MainLog = null; - _SongInfoLog.Dispose(); - _SongInfoLog = null; - _Initialized = false; - } - } - - public static string MainLogEntries - { - get { - _MainLogStringWriter.Flush(); - return _MainLogStringBuilder.ToString(); - } - } - - public static void LogError(Exception exception, string errorText, bool show = false, bool exit = false, [CallerMemberName] string callerMethodeName = "", - [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1, params object[] propertyValues) - { - using (LogContext.PushProperty("CallingContext", new { callerMethodeName = callerMethodeName, callerFilePath = callerFilePath, callerLineNumer = callerLineNumer })) - { - if (exit) - { - _MainLog.Fatal(exception, errorText, propertyValues); - } - else - { - _MainLog.Error(exception, errorText, propertyValues); - } - } - - if (show) - { - //Todo: Logsend assistent - MessageBox.Show(errorText, CSettings.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - - if (exit) - { - // Flush the logging piplines before exiting - _MainLog.Dispose(); - _SongInfoLog.Dispose(); - // Close the Programm - Environment.Exit(Environment.ExitCode); - } - } - - public static void LogError(string errorText, bool show = false, bool exit = false, [CallerMemberName] string callerMethodeName = "", - [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1, params object[] propertyValues) - { - // ReSharper disable ExplicitCallerInfoArgument - LogError(null, errorText, show, exit, callerMethodeName, callerFilePath, callerLineNumer, propertyValues); - } - - public static void LogWarning(string text, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1, params object[] propertyValues) - { - using (LogContext.PushProperty("CallingContext", new { callerMethodeName = callerMethodeName, callerFilePath = callerFilePath, callerLineNumer = callerLineNumer })) - { - _MainLog.Warning(text, propertyValues); - } - } - - public static void LogInformation(string text, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1, params object[] propertyValues) - { - using (LogContext.PushProperty("CallingContext", new { callerMethodeName = callerMethodeName, callerFilePath = callerFilePath, callerLineNumer = callerLineNumer })) - { - _MainLog.Information(text, propertyValues); - } - } - - public static void LogDebug(string text, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1, params object[] propertyValues) - { - using (LogContext.PushProperty("CallingContext", new { callerMethodeName = callerMethodeName, callerFilePath = callerFilePath, callerLineNumer = callerLineNumer })) - { - _MainLog.Debug(text, propertyValues); - } - } - - public static void LogSongError(Exception exception, string text, params object[] propertyValues) - { - _SongInfoLog.Error(exception, text, propertyValues); - } - public static void LogSongError(string text, params object[] propertyValues) - { - _SongInfoLog.Error(text, propertyValues); - } - - public static void LogSongWaring(string text, params object[] propertyValues) - { - _SongInfoLog.Warning(text, propertyValues); - } - - #region Log rolling - - private 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) - { - // Cant log anything here as the log isn't initialized yet - } - } - } - - if (File.Exists(mainLogFile)) - { - try { - if(numLogsToKeep > 0) - File.Move(mainLogFile, currentSourceFile); - else - File.Delete(mainLogFile); - } - catch (Exception) - { - // Cant log anything here as the log isn't initialized yet - } - } - } - - 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 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) - { - // Cant log anything here as the log isn't initialized yet - } - - } - } - } - } - - private static string _GenerateRollLogFileName(string mainLogFile, int number) - { - return $"{Path.GetDirectoryName(mainLogFile)}\\{Path.GetFileNameWithoutExtension(mainLogFile)}_{number}{Path.GetExtension(mainLogFile)}"; - } - - #endregion - - #region CTimeStampFromStartEnricher - - // ReSharper disable once InconsistentNaming - private 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)); - } - } - - #endregion - } -} \ No newline at end of file diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index b4256fa0..0689ccba 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -25,6 +25,7 @@ using Vocaluxe.Base.ThemeSystem; using VocaluxeLib; using VocaluxeLib.Game; using VocaluxeLib.Draw; +using VocaluxeLib.Log; using VocaluxeLib.Menu; using VocaluxeLib.Songs; using VocaluxeLib.Profile; @@ -39,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(); @@ -55,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); } } @@ -508,41 +508,6 @@ namespace Vocaluxe.Base } } - // ReSharper disable ExplicitCallerInfoArgument - class CBlog : ILog - { - public void LogError(Exception exeption, string errorText, bool showMsg = false, bool exit = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1, params object[] propertyValues) - { - CLog.LogError(exeption, errorText, showMsg, exit, callerMethodeName, callerFilePath, callerLineNumer, propertyValues); - } - - public void LogError(string errorText, bool showMsg = false, bool exit = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1, params object[] propertyValues) - { - CLog.LogError(null, errorText, showMsg, exit, callerMethodeName, callerFilePath, callerLineNumer, propertyValues); - } - - public void LogDebug(string text, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1, params object[] propertyValues) - { - - CLog.LogDebug(text, callerMethodeName, callerFilePath, callerLineNumer, propertyValues); - } - - public void LogSongWarning(string text, params object[] propertyValues) - { - CLog.LogSongWaring(text, propertyValues); - } - - public void LogSongError(Exception exception, string text, params object[] propertyValues) - { - CLog.LogSongError(exception, text, propertyValues); - } - - public void LogSongError(string text, params object[] propertyValues) - { - CLog.LogSongError(text, propertyValues); - } - } - class CBfonts : IFonts { public RectangleF GetTextBounds(CText text) @@ -866,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}"); } } @@ -883,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}"); } } @@ -895,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}"); } } } diff --git a/Vocaluxe/Base/CParty.cs b/Vocaluxe/Base/CParty.cs index f8126737..6687bffa 100644 --- a/Vocaluxe/Base/CParty.cs +++ b/Vocaluxe/Base/CParty.cs @@ -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; diff --git a/Vocaluxe/Base/CPlaylists.cs b/Vocaluxe/Base/CPlaylists.cs index 881d3ccb..8c47b962 100644 --- a/Vocaluxe/Base/CPlaylists.cs +++ b/Vocaluxe/Base/CPlaylists.cs @@ -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); } } } diff --git a/Vocaluxe/Base/CProfiles.cs b/Vocaluxe/Base/CProfiles.cs index 9e454ffe..12440e5f 100644 --- a/Vocaluxe/Base/CProfiles.cs +++ b/Vocaluxe/Base/CProfiles.cs @@ -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; } diff --git a/Vocaluxe/Base/CSettings.cs b/Vocaluxe/Base/CSettings.cs index 5a6a8998..abe324ed 100644 --- a/Vocaluxe/Base/CSettings.cs +++ b/Vocaluxe/Base/CSettings.cs @@ -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 @@ -113,7 +114,7 @@ namespace Vocaluxe.Base public const string FileNameCreditsRessourcesDB = "CreditsRessourcesDB.sqlite"; public const string FileNameMainLog = "Vocaluxe.log"; - public const string FileNameSongInfoLog = "SongInformation.log"; + public const string FileNameSongLog = "Song.log"; public const string FileNameRequiredSkinElements = "RequiredSkinElements.xml"; @@ -239,7 +240,7 @@ namespace Vocaluxe.Base } catch (Exception e) { - CLog.LogError("Cannot create directory \"" + path + "\": " + e.Message); + CLog.Error("Cannot create directory \"" + path + "\": " + e.Message); } } } diff --git a/Vocaluxe/Base/CSongs.cs b/Vocaluxe/Base/CSongs.cs index 5429b65b..e2a6e3f8 100644 --- a/Vocaluxe/Base/CSongs.cs +++ b/Vocaluxe/Base/CSongs.cs @@ -25,6 +25,7 @@ using System.Threading.Tasks; using Serilog.Events; using SerilogTimings; using VocaluxeLib; +using VocaluxeLib.Log; using VocaluxeLib.Songs; namespace Vocaluxe.Base @@ -335,7 +336,7 @@ namespace Vocaluxe.Base public static void LoadSongs() { - CLog.LogInformation("Load Songs"); + CLog.Information("Load Songs"); using (Operation.At(LogEventLevel.Information).Time("Load Songs")) { SongsLoaded = false; @@ -343,7 +344,7 @@ namespace Vocaluxe.Base var files = new List(); - CLog.LogInformation("List Songs"); + CLog.Information("List Songs"); using (Operation.At(LogEventLevel.Information).Time("List Songs")) { @@ -358,7 +359,7 @@ namespace Vocaluxe.Base } } - CLog.LogInformation("Read TXTs"); + CLog.Information("Read TXTs"); using (Operation.At(LogEventLevel.Information).Time("Read TXTs")) { foreach (string file in files) @@ -372,7 +373,7 @@ namespace Vocaluxe.Base } } - CLog.LogInformation("Sort Songs"); + CLog.Information("Sort Songs"); using (Operation.At(LogEventLevel.Information).Time("Sorted Songs")) { Sorter.SongSorting = CConfig.Config.Game.SongSorting; @@ -409,7 +410,7 @@ namespace Vocaluxe.Base private static void _LoadCovers() { - CLog.LogInformation("Load Covers"); + CLog.Information("Load Covers"); using (Operation.At(LogEventLevel.Information).Time("Loaded Covers")) { int songCount = _Songs.Count; diff --git a/Vocaluxe/Base/Fonts/CFontStyle.cs b/Vocaluxe/Base/Fonts/CFontStyle.cs index 0958632b..448f4b13 100644 --- a/Vocaluxe/Base/Fonts/CFontStyle.cs +++ b/Vocaluxe/Base/Fonts/CFontStyle.cs @@ -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); diff --git a/Vocaluxe/Base/Fonts/CFonts.cs b/Vocaluxe/Base/Fonts/CFonts.cs index ae9d1af9..a91faec2 100644 --- a/Vocaluxe/Base/Fonts/CFonts.cs +++ b/Vocaluxe/Base/Fonts/CFonts.cs @@ -24,6 +24,7 @@ using System.Linq; using Serilog.Events; using SerilogTimings; using VocaluxeLib; +using VocaluxeLib.Log; using VocaluxeLib.Menu; using VocaluxeLib.Xml; @@ -215,14 +216,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"); + CLog.Error("Empty fontName requested"); if (_FontFamilies.Count == 0) - CLog.LogError("No fonts found!", true, true); + CLog.Fatal("No fonts found!"); return 0; } @@ -267,7 +268,7 @@ namespace Vocaluxe.Base.Fonts } catch (Exception e) { - CLog.LogError(e, "Error loading default Fonts"); + CLog.Error(e, "Error loading default Fonts"); return false; } @@ -285,12 +286,12 @@ 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.LogInformation("Build Glyphs"); + CLog.Information("Build Glyphs"); using (Operation.At(LogEventLevel.Information).Time("Build Glyphs")) { _BuildGlyphs(); diff --git a/Vocaluxe/Base/ThemeSystem/CBaseSkin.cs b/Vocaluxe/Base/ThemeSystem/CBaseSkin.cs index 91d36113..273a7aa2 100644 --- a/Vocaluxe/Base/ThemeSystem/CBaseSkin.cs +++ b/Vocaluxe/Base/ThemeSystem/CBaseSkin.cs @@ -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; } } diff --git a/Vocaluxe/Base/ThemeSystem/CBaseTheme.cs b/Vocaluxe/Base/ThemeSystem/CBaseTheme.cs index cc4c5f3c..f0cd3950 100644 --- a/Vocaluxe/Base/ThemeSystem/CBaseTheme.cs +++ b/Vocaluxe/Base/ThemeSystem/CBaseTheme.cs @@ -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(); } diff --git a/Vocaluxe/Base/ThemeSystem/CPartySkin.cs b/Vocaluxe/Base/ThemeSystem/CPartySkin.cs index 16484bfc..b09c93bb 100644 --- a/Vocaluxe/Base/ThemeSystem/CPartySkin.cs +++ b/Vocaluxe/Base/ThemeSystem/CPartySkin.cs @@ -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); } } diff --git a/Vocaluxe/Base/ThemeSystem/CPartyTheme.cs b/Vocaluxe/Base/ThemeSystem/CPartyTheme.cs index f91a09d0..b6167fb6 100644 --- a/Vocaluxe/Base/ThemeSystem/CPartyTheme.cs +++ b/Vocaluxe/Base/ThemeSystem/CPartyTheme.cs @@ -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) diff --git a/Vocaluxe/Base/ThemeSystem/CSkin.cs b/Vocaluxe/Base/ThemeSystem/CSkin.cs index 379ed66a..398d1d35 100644 --- a/Vocaluxe/Base/ThemeSystem/CSkin.cs +++ b/Vocaluxe/Base/ThemeSystem/CSkin.cs @@ -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(e, "Can't load skin file \"" + Path.Combine(_Folder, _FileName) + "\". Invalid file!"); + 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); diff --git a/Vocaluxe/Base/ThemeSystem/CTheme.cs b/Vocaluxe/Base/ThemeSystem/CTheme.cs index 6014da02..12ea5eaf 100644 --- a/Vocaluxe/Base/ThemeSystem/CTheme.cs +++ b/Vocaluxe/Base/ThemeSystem/CTheme.cs @@ -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(e, "Can't load theme \"" + _FileName + "\". Invalid file!"); + CLog.Error(e, "Can't load theme \"" + _FileName + "\". Invalid file!"); return false; } diff --git a/Vocaluxe/Base/ThemeSystem/CThemes.cs b/Vocaluxe/Base/ThemeSystem/CThemes.cs index fabfa85f..8ca65c47 100644 --- a/Vocaluxe/Base/ThemeSystem/CThemes.cs +++ b/Vocaluxe/Base/ThemeSystem/CThemes.cs @@ -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; } } diff --git a/Vocaluxe/CProgrammHelper.cs b/Vocaluxe/CProgrammHelper.cs index 7a3dd995..52e7d055 100644 --- a/Vocaluxe/CProgrammHelper.cs +++ b/Vocaluxe/CProgrammHelper.cs @@ -21,6 +21,7 @@ using System.Reflection; using System.Security; using Microsoft.Win32; using Vocaluxe.Base; +using VocaluxeLib.Log; namespace Vocaluxe { @@ -118,14 +119,13 @@ 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( + CLog.Error( "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; @@ -134,12 +134,12 @@ namespace Vocaluxe bool vc2008Installed = _IsVC2008Installed(); if (!vc2008Installed) { - CLog.LogError( + CLog.Error( "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( + CLog.Error( "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); return false; diff --git a/Vocaluxe/CSplashScreen.cs b/Vocaluxe/CSplashScreen.cs index bba2749c..30f1f9b2 100644 --- a/Vocaluxe/CSplashScreen.cs +++ b/Vocaluxe/CSplashScreen.cs @@ -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; diff --git a/Vocaluxe/Lib/Database/CCoverDB.cs b/Vocaluxe/Lib/Database/CCoverDB.cs index 7c902fbe..f4729f5f 100644 --- a/Vocaluxe/Lib/Database/CCoverDB.cs +++ b/Vocaluxe/Lib/Database/CCoverDB.cs @@ -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; diff --git a/Vocaluxe/Lib/Database/CHighscoreDB.cs b/Vocaluxe/Lib/Database/CHighscoreDB.cs index c6683788..5f6bf106 100644 --- a/Vocaluxe/Lib/Database/CHighscoreDB.cs +++ b/Vocaluxe/Lib/Database/CHighscoreDB.cs @@ -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 diff --git a/Vocaluxe/Lib/Database/CResourceDB.cs b/Vocaluxe/Lib/Database/CResourceDB.cs index 64b0a181..1aca8250 100644 --- a/Vocaluxe/Lib/Database/CResourceDB.cs +++ b/Vocaluxe/Lib/Database/CResourceDB.cs @@ -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; diff --git a/Vocaluxe/Lib/Draw/CDirect3D.cs b/Vocaluxe/Lib/Draw/CDirect3D.cs index 11dd3c22..728e1217 100644 --- a/Vocaluxe/Lib/Draw/CDirect3D.cs +++ b/Vocaluxe/Lib/Draw/CDirect3D.cs @@ -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(e, "No DirectX runtimes were found, please download and install them from http://www.microsoft.com/download/en/details.aspx?id=8109"); + 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(e, "Error during D3D device creation."); + 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"); } /// @@ -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"); } /// diff --git a/Vocaluxe/Lib/Input/CHIDAPI.cs b/Vocaluxe/Lib/Input/CHIDAPI.cs index 73a92ce1..86fa686e 100644 --- a/Vocaluxe/Lib/Input/CHIDAPI.cs +++ b/Vocaluxe/Lib/Input/CHIDAPI.cs @@ -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; diff --git a/Vocaluxe/Lib/Input/WiiMote/WiiMoteLib.cs b/Vocaluxe/Lib/Input/WiiMote/WiiMoteLib.cs index f8eb987b..e6642331 100644 --- a/Vocaluxe/Lib/Input/WiiMote/WiiMoteLib.cs +++ b/Vocaluxe/Lib/Input/WiiMote/WiiMoteLib.cs @@ -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; } diff --git a/Vocaluxe/Lib/Playlist/CPlaylistFile.cs b/Vocaluxe/Lib/Playlist/CPlaylistFile.cs index fdddf0dc..9c9c9ac4 100644 --- a/Vocaluxe/Lib/Playlist/CPlaylistFile.cs +++ b/Vocaluxe/Lib/Playlist/CPlaylistFile.cs @@ -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); diff --git a/Vocaluxe/Lib/Sound/CPortAudioHandle.cs b/Vocaluxe/Lib/Sound/CPortAudioHandle.cs index 355b4b45..a8fe8e89 100644 --- a/Vocaluxe/Lib/Sound/CPortAudioHandle.cs +++ b/Vocaluxe/Lib/Sound/CPortAudioHandle.cs @@ -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(ex, "Error disposing PortAudio"); + CLog.Error(ex, "Error disposing PortAudio"); } } _Disposed = true; @@ -179,7 +180,7 @@ namespace Vocaluxe.Lib.Sound } catch (Exception ex) { - CLog.LogError(ex, "Error closing stream:"); + 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; } diff --git a/Vocaluxe/Lib/Sound/Playback/CAudioStreamBase.cs b/Vocaluxe/Lib/Sound/Playback/CAudioStreamBase.cs index 35e62978..bad098cf 100644 --- a/Vocaluxe/Lib/Sound/Playback/CAudioStreamBase.cs +++ b/Vocaluxe/Lib/Sound/Playback/CAudioStreamBase.cs @@ -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() diff --git a/Vocaluxe/Lib/Sound/Playback/Decoder/CAudioDecoderFFmpeg.cs b/Vocaluxe/Lib/Sound/Playback/Decoder/CAudioDecoderFFmpeg.cs index 505b3604..7abe611b 100644 --- a/Vocaluxe/Lib/Sound/Playback/Decoder/CAudioDecoderFFmpeg.cs +++ b/Vocaluxe/Lib/Sound/Playback/Decoder/CAudioDecoderFFmpeg.cs @@ -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(); } } diff --git a/Vocaluxe/Lib/Sound/Playback/GstreamerSharp/CGstreamerSharpAudio.cs b/Vocaluxe/Lib/Sound/Playback/GstreamerSharp/CGstreamerSharpAudio.cs index 6de16180..bd903d2d 100644 --- a/Vocaluxe/Lib/Sound/Playback/GstreamerSharp/CGstreamerSharpAudio.cs +++ b/Vocaluxe/Lib/Sound/Playback/GstreamerSharp/CGstreamerSharpAudio.cs @@ -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 diff --git a/Vocaluxe/Lib/Sound/Playback/GstreamerSharp/CGstreamerSharpAudioStream.cs b/Vocaluxe/Lib/Sound/Playback/GstreamerSharp/CGstreamerSharpAudioStream.cs index 452056d0..f433c8c5 100644 --- a/Vocaluxe/Lib/Sound/Playback/GstreamerSharp/CGstreamerSharpAudioStream.cs +++ b/Vocaluxe/Lib/Sound/Playback/GstreamerSharp/CGstreamerSharpAudioStream.cs @@ -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(); diff --git a/Vocaluxe/Lib/Sound/Playback/OpenAL/COpenAlStream.cs b/Vocaluxe/Lib/Sound/Playback/OpenAL/COpenAlStream.cs index fd22e07c..38a0cb77 100644 --- a/Vocaluxe/Lib/Sound/Playback/OpenAL/COpenAlStream.cs +++ b/Vocaluxe/Lib/Sound/Playback/OpenAL/COpenAlStream.cs @@ -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; } diff --git a/Vocaluxe/Lib/Sound/Playback/PortAudio/CPortAudioStream.cs b/Vocaluxe/Lib/Sound/Playback/PortAudio/CPortAudioStream.cs index 2002aa9c..d8040976 100644 --- a/Vocaluxe/Lib/Sound/Playback/PortAudio/CPortAudioStream.cs +++ b/Vocaluxe/Lib/Sound/Playback/PortAudio/CPortAudioStream.cs @@ -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; diff --git a/Vocaluxe/Lib/Sound/Record/PitchTracker/CPitchTrackerTest.cs b/Vocaluxe/Lib/Sound/Record/PitchTracker/CPitchTrackerTest.cs index 7c727693..81b934c1 100644 --- a/Vocaluxe/Lib/Sound/Record/PitchTracker/CPitchTrackerTest.cs +++ b/Vocaluxe/Lib/Sound/Record/PitchTracker/CPitchTrackerTest.cs @@ -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); } } } diff --git a/Vocaluxe/Lib/Sound/Record/PortAudio/CPortAudioRecord.cs b/Vocaluxe/Lib/Sound/Record/PortAudio/CPortAudioRecord.cs index cfc8818c..dde1cbe9 100644 --- a/Vocaluxe/Lib/Sound/Record/PortAudio/CPortAudioRecord.cs +++ b/Vocaluxe/Lib/Sound/Record/PortAudio/CPortAudioRecord.cs @@ -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; diff --git a/Vocaluxe/Lib/Video/Acinerella/CDecoderThread.cs b/Vocaluxe/Lib/Video/Acinerella/CDecoderThread.cs index 64385abe..2e845f4d 100644 --- a/Vocaluxe/Lib/Video/Acinerella/CDecoderThread.cs +++ b/Vocaluxe/Lib/Video/Acinerella/CDecoderThread.cs @@ -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(e, "Couldn't copy the frame to the managed environment."); + CLog.Error(e, "Couldn't copy the frame to the managed environment."); return false; } diff --git a/Vocaluxe/Program.cs b/Vocaluxe/Program.cs index 590a0127..84ea160b 100644 --- a/Vocaluxe/Program.cs +++ b/Vocaluxe/Program.cs @@ -30,6 +30,7 @@ using Vocaluxe.Base; using Vocaluxe.Base.Fonts; using Vocaluxe.Base.Server; using Vocaluxe.Base.ThemeSystem; +using VocaluxeLib.Log; [assembly: InternalsVisibleTo("VocaluxeTests")] @@ -80,7 +81,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); @@ -98,20 +99,20 @@ namespace Vocaluxe Directory.CreateDirectory(CSettings.DataFolder); // Init Log - CLog.Init(CSettings.FolderNameLogs); + CLog.Init(CSettings.FolderNameLogs, CSettings.FileNameMainLog, CSettings.FileNameSongLog); if (!CProgrammHelper.CheckRequirements()) return; CProgrammHelper.Init(); - CLog.LogInformation("Init Program"); + CLog.Information("Init Program"); using (Operation.At(LogEventLevel.Information).Time("Init Program")) { CMain.Init(); Application.DoEvents(); // Init Language - CLog.LogInformation("Init Language"); + CLog.Information("Init Language"); using (Operation.At(LogEventLevel.Information).Time("Init Language")) { if (!CLanguage.Init()) @@ -121,7 +122,7 @@ namespace Vocaluxe Application.DoEvents(); // load config - CLog.LogInformation("Init Config"); + CLog.Information("Init Config"); using (Operation.At(LogEventLevel.Information).Time("Init Config")) { CConfig.LoadCommandLineParams(args); @@ -137,7 +138,7 @@ namespace Vocaluxe Application.DoEvents(); // Init Draw - CLog.LogInformation("Init Draw"); + CLog.Information("Init Draw"); using (Operation.At(LogEventLevel.Information).Time("Init Draw")) { if (!CDraw.Init()) @@ -147,7 +148,7 @@ namespace Vocaluxe Application.DoEvents(); // Init Playback - CLog.LogInformation("Init Playback"); + CLog.Information("Init Playback"); using (Operation.At(LogEventLevel.Information).Time("Init Playback")) { if (!CSound.Init()) @@ -157,7 +158,7 @@ namespace Vocaluxe Application.DoEvents(); // Init Record - CLog.LogInformation("Init Record"); + CLog.Information("Init Record"); using (Operation.At(LogEventLevel.Information).Time("Init Record")) { if (!CRecord.Init()) @@ -167,7 +168,7 @@ namespace Vocaluxe Application.DoEvents(); // Init VideoDecoder - CLog.LogInformation("Init Videodecoder"); + CLog.Information("Init Videodecoder"); using (Operation.At(LogEventLevel.Information).Time("Init Videodecoder")) { if (!CVideo.Init()) @@ -177,7 +178,7 @@ namespace Vocaluxe Application.DoEvents(); // Init Database - CLog.LogInformation("Init Database"); + CLog.Information("Init Database"); using (Operation.At(LogEventLevel.Information).Time("Init Database")) { if (!CDataBase.Init()) @@ -187,7 +188,7 @@ namespace Vocaluxe Application.DoEvents(); //Init Webcam - CLog.LogInformation("Init Webcam"); + CLog.Information("Init Webcam"); using (Operation.At(LogEventLevel.Information).Time("Init Webcam")) { if (!CWebcam.Init()) @@ -197,7 +198,7 @@ namespace Vocaluxe Application.DoEvents(); // Init Background Music - CLog.LogInformation("Init Background Music"); + CLog.Information("Init Background Music"); using (Operation.At(LogEventLevel.Information).Time("Init Background Music")) { CBackgroundMusic.Init(); @@ -206,7 +207,7 @@ namespace Vocaluxe Application.DoEvents(); // Init Profiles - CLog.LogInformation("Init Profiles"); + CLog.Information("Init Profiles"); using (Operation.At(LogEventLevel.Information).Time("Init Profiles")) { CProfiles.Init(); @@ -215,7 +216,7 @@ namespace Vocaluxe Application.DoEvents(); // Init Fonts - CLog.LogInformation("Init Fonts"); + CLog.Information("Init Fonts"); using (Operation.At(LogEventLevel.Information).Time("Init Fonts")) { if (!CFonts.Init()) @@ -225,14 +226,14 @@ namespace Vocaluxe Application.DoEvents(); // Theme System - CLog.LogInformation("Init Theme"); + CLog.Information("Init Theme"); using (Operation.At(LogEventLevel.Information).Time("Init Theme")) { if (!CThemes.Init()) throw new CLoadingException("theme"); } - CLog.LogInformation("Load Theme"); + CLog.Information("Load Theme"); using (Operation.At(LogEventLevel.Information).Time("Load Theme")) { CThemes.Load(); @@ -241,7 +242,7 @@ namespace Vocaluxe Application.DoEvents(); // Load Cover - CLog.LogInformation("Init Cover"); + CLog.Information("Init Cover"); using (Operation.At(LogEventLevel.Information).Time("Init Cover")) { if (!CCover.Init()) @@ -251,7 +252,7 @@ namespace Vocaluxe Application.DoEvents(); // Init Screens - CLog.LogInformation("Init Screens"); + CLog.Information("Init Screens"); using (Operation.At(LogEventLevel.Information).Time("Init Screens")) { CGraphics.Init(); @@ -260,7 +261,7 @@ namespace Vocaluxe Application.DoEvents(); // Init Server - CLog.LogInformation("Init Server"); + CLog.Information("Init Server"); using (Operation.At(LogEventLevel.Information).Time("Init Server")) { CVocaluxeServer.Init(); @@ -269,7 +270,7 @@ namespace Vocaluxe Application.DoEvents(); // Init Input - CLog.LogInformation("Init Input"); + CLog.Information("Init Input"); using (Operation.At(LogEventLevel.Information).Time("Init Input")) { CController.Init(); @@ -279,7 +280,7 @@ namespace Vocaluxe Application.DoEvents(); // Init Game; - CLog.LogInformation("Init Game"); + CLog.Information("Init Game"); using (Operation.At(LogEventLevel.Information).Time("Init Game")) { CGame.Init(); @@ -290,7 +291,7 @@ namespace Vocaluxe Application.DoEvents(); // Init Party Modes; - CLog.LogInformation("Init Party Modes"); + CLog.Information("Init Party Modes"); using (Operation.At(LogEventLevel.Information).Time("Init Party Modes")) { if (!CParty.Init()) @@ -306,7 +307,7 @@ namespace Vocaluxe catch (Exception e) { MessageBox.Show("Error on start up: " + e.Message); - CLog.LogError("Error on start up: " + e); + CLog.Error("Error on start up: " + e); if (_SplashScreen != null) _SplashScreen.Close(); _CloseProgram(); @@ -330,7 +331,7 @@ namespace Vocaluxe } catch (Exception e) { - CLog.LogError(e, "Error during shutdown! (CController)"); + CLog.Error(e, "Error during shutdown! (CController)"); } try @@ -339,7 +340,7 @@ namespace Vocaluxe } catch (Exception e) { - CLog.LogError(e, "Error during shutdown! (CVocaluxeServer)"); + CLog.Error(e, "Error during shutdown! (CVocaluxeServer)"); } try @@ -348,7 +349,7 @@ namespace Vocaluxe } catch (Exception e) { - CLog.LogError(e, "Error during shutdown! (CGraphics)"); + CLog.Error(e, "Error during shutdown! (CGraphics)"); } try @@ -357,7 +358,7 @@ namespace Vocaluxe } catch (Exception e) { - CLog.LogError(e, "Error during shutdown! (CThemes)"); + CLog.Error(e, "Error during shutdown! (CThemes)"); } try @@ -366,7 +367,7 @@ namespace Vocaluxe } catch (Exception e) { - CLog.LogError(e, "Error during shutdown! (CCover)"); + CLog.Error(e, "Error during shutdown! (CCover)"); } try @@ -375,7 +376,7 @@ namespace Vocaluxe } catch (Exception e) { - CLog.LogError(e, "Error during shutdown! (CFonts)"); + CLog.Error(e, "Error during shutdown! (CFonts)"); } try @@ -384,7 +385,7 @@ namespace Vocaluxe } catch (Exception e) { - CLog.LogError(e, "Error during shutdown! (CBackgroundMusic)"); + CLog.Error(e, "Error during shutdown! (CBackgroundMusic)"); } try @@ -393,7 +394,7 @@ namespace Vocaluxe } catch (Exception e) { - CLog.LogError(e, "Error during shutdown! (CWebcam)"); + CLog.Error(e, "Error during shutdown! (CWebcam)"); } try @@ -402,7 +403,7 @@ namespace Vocaluxe } catch (Exception e) { - CLog.LogError(e, "Error during shutdown! (CDataBase)"); + CLog.Error(e, "Error during shutdown! (CDataBase)"); } try @@ -411,7 +412,7 @@ namespace Vocaluxe } catch (Exception e) { - CLog.LogError(e, "Error during shutdown! (CVideo)"); + CLog.Error(e, "Error during shutdown! (CVideo)"); } try @@ -420,7 +421,7 @@ namespace Vocaluxe } catch (Exception e) { - CLog.LogError(e, "Error during shutdown! (CRecord)"); + CLog.Error(e, "Error during shutdown! (CRecord)"); } try @@ -429,7 +430,7 @@ namespace Vocaluxe } catch (Exception e) { - CLog.LogError(e, "Error during shutdown! (CSound)"); + CLog.Error(e, "Error during shutdown! (CSound)"); } try @@ -438,7 +439,7 @@ namespace Vocaluxe } catch (Exception e) { - CLog.LogError(e, "Error during shutdown! (CDraw)"); + CLog.Error(e, "Error during shutdown! (CDraw)"); } GC.Collect(); // Do a GC run here before we close logs to have finalizers run @@ -462,7 +463,7 @@ namespace Vocaluxe } catch {} MessageBox.Show("Unhandled exception: " + e.Message + stackTrace); - CLog.LogError("Unhandled exception: " + e.Message + stackTrace); + CLog.Error("Unhandled exception: " + e.Message + stackTrace); _CloseProgram(); } #endif @@ -498,7 +499,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 diff --git a/Vocaluxe/Screens/CScreenCredits.cs b/Vocaluxe/Screens/CScreenCredits.cs index 9ec2afed..824f25f4 100644 --- a/Vocaluxe/Screens/CScreenCredits.cs +++ b/Vocaluxe/Screens/CScreenCredits.cs @@ -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; diff --git a/Vocaluxe/Screens/CScreenLoad.cs b/Vocaluxe/Screens/CScreenLoad.cs index 61b9e39e..7ace4847 100644 --- a/Vocaluxe/Screens/CScreenLoad.cs +++ b/Vocaluxe/Screens/CScreenLoad.cs @@ -22,6 +22,7 @@ using Serilog.Events; using SerilogTimings; using Vocaluxe.Base; using VocaluxeLib; +using VocaluxeLib.Log; using VocaluxeLib.Menu; namespace Vocaluxe.Screens @@ -128,7 +129,7 @@ namespace Vocaluxe.Screens videoPlayer.PreLoad(); } - CLog.LogInformation("Load Songs Full"); + CLog.Information("Load Songs Full"); _TimerLoadSongsFull = Operation.At(LogEventLevel.Information).Time("Loaded Songs Full"); _SongLoaderThread = new Thread(CSongs.LoadSongs) {Name = "SongLoader", IsBackground = true}; @@ -187,7 +188,7 @@ namespace Vocaluxe.Screens _TimerLoadSongsFull.Dispose(); //Init Playlists - CLog.LogInformation("Init Playlists"); + CLog.Information("Init Playlists"); using (Operation.At(LogEventLevel.Information).Time("Init Playlists")) { CPlaylists.Init(); diff --git a/Vocaluxe/Screens/CScreenOptionsVideo.cs b/Vocaluxe/Screens/CScreenOptionsVideo.cs index 8c33e722..e06a755f 100644 --- a/Vocaluxe/Screens/CScreenOptionsVideo.cs +++ b/Vocaluxe/Screens/CScreenOptionsVideo.cs @@ -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; diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index d55e6bc3..e36dfbfd 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -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; } diff --git a/Vocaluxe/Vocaluxe.csproj b/Vocaluxe/Vocaluxe.csproj index 4b64c235..8b69d5f0 100644 --- a/Vocaluxe/Vocaluxe.csproj +++ b/Vocaluxe/Vocaluxe.csproj @@ -160,7 +160,7 @@ - ..\packages\Serilog.2.5.0\lib\net46\Serilog.dll + ..\packages\Serilog.2.6.0\lib\net46\Serilog.dll True @@ -176,7 +176,7 @@ True - ..\packages\Serilog.Sinks.File.3.1.0\lib\net45\Serilog.Sinks.File.dll + ..\packages\Serilog.Sinks.File.4.0.0\lib\net45\Serilog.Sinks.File.dll True @@ -249,7 +249,6 @@ - diff --git a/Vocaluxe/packages.config b/Vocaluxe/packages.config index 01998c23..1cb54eb4 100644 --- a/Vocaluxe/packages.config +++ b/Vocaluxe/packages.config @@ -1,10 +1,10 @@  - + - + diff --git a/VocaluxeLib/CBasic.cs b/VocaluxeLib/CBasic.cs index c100ea7b..a8f0484c 100644 --- a/VocaluxeLib/CBasic.cs +++ b/VocaluxeLib/CBasic.cs @@ -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; diff --git a/VocaluxeLib/CHelper.cs b/VocaluxeLib/CHelper.cs index 6c143b59..6c04fee7 100644 --- a/VocaluxeLib/CHelper.cs +++ b/VocaluxeLib/CHelper.cs @@ -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; diff --git a/VocaluxeLib/IBasic.cs b/VocaluxeLib/IBasic.cs index d730db8b..e182273b 100644 --- a/VocaluxeLib/IBasic.cs +++ b/VocaluxeLib/IBasic.cs @@ -166,16 +166,6 @@ namespace VocaluxeLib IMenu GetScreen(EScreen screen); } - public interface ILog - { - void LogError(Exception exeption, string errorText, bool showMsg = false, bool exit = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1, params object[] propertyValues); - void LogError(string errorText, bool showMsg = false, bool exit = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1, params object[] propertyValues); - void LogDebug(string text, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1, params object[] propertyValues); - void LogSongWarning(string text, params object[] propertyValues); - void LogSongError(Exception exception, string text, params object[] propertyValues); - void LogSongError(string text, params object[] propertyValues); - } - public interface IFonts { RectangleF GetTextBounds(CText text); diff --git a/VocaluxeLib/Log/CLog.cs b/VocaluxeLib/Log/CLog.cs new file mode 100644 index 00000000..00669bd7 --- /dev/null +++ b/VocaluxeLib/Log/CLog.cs @@ -0,0 +1,79 @@ +using System; +using System.IO; +using System.Text; +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 SilentLogger(); + private static ILogger _SongLog = new SilentLogger(); + private static string _LogFolder; + + private const string _MainLogTemplate = "[{TimeStampFromStart}] [{Level}] {Message}{NewLine}{Properties}{NewLine}{Exception}"; + private const string _SongLogTemplate = "{Message}{NewLine}Additional info:{Properties}{NewLine}{Exception}"; + + public static void Init(string logFolder, string fileNameMainLog, string fileNameSongInfoLog) + { + _LogFolder = logFolder; + if (!Directory.Exists(_LogFolder)) + Directory.CreateDirectory(_LogFolder); + + LogFileRoller.RollLogs(Path.Combine(_LogFolder, fileNameMainLog), 2); + LogFileRoller.RollLogs(Path.Combine(_LogFolder, fileNameSongInfoLog), 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(Path.Combine(_LogFolder, fileNameMainLog), flushToDiskInterval: TimeSpan.FromSeconds(30), outputTemplate: _MainLogTemplate) +#if DEBUG + .WriteTo.Console(outputTemplate: _MainLogTemplate) +#endif + .CreateLogger(); + + _SongLog = new LoggerConfiguration() + .WriteTo.File(Path.Combine(_LogFolder, fileNameSongInfoLog), flushToDiskInterval: TimeSpan.FromSeconds(60), outputTemplate: _SongLogTemplate) +#if DEBUG + .WriteTo.Console(outputTemplate: "[SongInfo] " + _SongLogTemplate) +#endif + .CreateLogger(); + } + + public static void Close() + { + if (!(_MainLog is SilentLogger)) + { + ILogger loggerToDispose = _MainLog; + + _MainLog = new SilentLogger(); + (_MainLog as IDisposable)?.Dispose(); + } + + if (!(_SongLog is SilentLogger)) + { + ILogger loggerToDispose = _MainLog; + + _SongLog = new SilentLogger(); + (_SongLog as IDisposable)?.Dispose(); + } + + } + + private static void _ShowLogAssistent(string messageTemplate, object[] propertyValues, string callerMethodeName = "", string callerFilePath = "", int callerLineNumer = -1) + { + //Todo: Logsend assistent + //MessageBox.Show(messageTemplate, "Vocaluxe", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } +} diff --git a/VocaluxeLib/Log/CLogFunctions.cs b/VocaluxeLib/Log/CLogFunctions.cs new file mode 100644 index 00000000..cf311403 --- /dev/null +++ b/VocaluxeLib/Log/CLogFunctions.cs @@ -0,0 +1,959 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using Serilog.Context; +using Serilog.Core; + +namespace VocaluxeLib.Log +{ + public static partial class CLog + { + + public static object[] Params(params object[] propertyValues) + { + return propertyValues; + } + + + #region Verbose functions + + /// + /// Write an event with the Verbose level to the Verbose log. + /// + /// Message template for this event. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Verbose(string messageTemplate, bool show = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Verbose(messageTemplate); + } + if(show) + _ShowLogAssistent(messageTemplate, null, callerMethodeName, callerFilePath, callerLineNumer); + } + + /// + /// Write an event with the Verbose level with additional propertyValues to the Verbose log. + /// + /// Message template for this event. + /// Data inserted into the message template. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Verbose(string messageTemplate, object[] propertyValues, bool show = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Verbose(messageTemplate, propertyValues); + } + if(show) + _ShowLogAssistent(messageTemplate, propertyValues, callerMethodeName, callerFilePath, callerLineNumer); + } + + /// + /// Write an event with the Verbose level and associated exception to the Verbose log. + /// + /// Exception of this event. + /// Message template for this event. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Verbose(Exception exception, string messageTemplate, bool show = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Verbose( exception, messageTemplate); + } + if(show) + _ShowLogAssistent(messageTemplate, null, callerMethodeName, callerFilePath, callerLineNumer); + } + + /// + /// Write an event with the Verbose level with additional propertyValues and associated exception to the Verbose log. + /// + /// Exception of this event. + /// Message template for this event. + /// Data inserted into the message template. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Verbose(Exception exception, string messageTemplate, object[] propertyValues, bool show = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Verbose(exception, messageTemplate, propertyValues); + } + if(show) + _ShowLogAssistent(messageTemplate, propertyValues, callerMethodeName, callerFilePath, callerLineNumer); + } + + #endregion + + #region Debug functions + + /// + /// Write an event with the Debug level to the Debug log. + /// + /// Message template for this event. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Debug(string messageTemplate, bool show = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Debug(messageTemplate); + } + if(show) + _ShowLogAssistent(messageTemplate, null, callerMethodeName, callerFilePath, callerLineNumer); + } + + /// + /// Write an event with the Debug level with additional propertyValues to the Debug log. + /// + /// Message template for this event. + /// Data inserted into the message template. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Debug(string messageTemplate, object[] propertyValues, bool show = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Debug(messageTemplate, propertyValues); + } + if(show) + _ShowLogAssistent(messageTemplate, propertyValues, callerMethodeName, callerFilePath, callerLineNumer); + } + + /// + /// Write an event with the Debug level and associated exception to the Debug log. + /// + /// Exception of this event. + /// Message template for this event. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Debug(Exception exception, string messageTemplate, bool show = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Debug( exception, messageTemplate); + } + if(show) + _ShowLogAssistent(messageTemplate, null, callerMethodeName, callerFilePath, callerLineNumer); + } + + /// + /// Write an event with the Debug level with additional propertyValues and associated exception to the Debug log. + /// + /// Exception of this event. + /// Message template for this event. + /// Data inserted into the message template. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Debug(Exception exception, string messageTemplate, object[] propertyValues, bool show = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Debug(exception, messageTemplate, propertyValues); + } + if(show) + _ShowLogAssistent(messageTemplate, propertyValues, callerMethodeName, callerFilePath, callerLineNumer); + } + + #endregion + + #region Information functions + + /// + /// Write an event with the Information level to the Information log. + /// + /// Message template for this event. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Information(string messageTemplate, bool show = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Information(messageTemplate); + } + if(show) + _ShowLogAssistent(messageTemplate, null, callerMethodeName, callerFilePath, callerLineNumer); + } + + /// + /// Write an event with the Information level with additional propertyValues to the Information log. + /// + /// Message template for this event. + /// Data inserted into the message template. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Information(string messageTemplate, object[] propertyValues, bool show = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Information(messageTemplate, propertyValues); + } + if(show) + _ShowLogAssistent(messageTemplate, propertyValues, callerMethodeName, callerFilePath, callerLineNumer); + } + + /// + /// Write an event with the Information level and associated exception to the Information log. + /// + /// Exception of this event. + /// Message template for this event. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Information(Exception exception, string messageTemplate, bool show = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Information( exception, messageTemplate); + } + if(show) + _ShowLogAssistent(messageTemplate, null, callerMethodeName, callerFilePath, callerLineNumer); + } + + /// + /// Write an event with the Information level with additional propertyValues and associated exception to the Information log. + /// + /// Exception of this event. + /// Message template for this event. + /// Data inserted into the message template. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Information(Exception exception, string messageTemplate, object[] propertyValues, bool show = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Information(exception, messageTemplate, propertyValues); + } + if(show) + _ShowLogAssistent(messageTemplate, propertyValues, callerMethodeName, callerFilePath, callerLineNumer); + } + + #endregion + + #region Warning functions + + /// + /// Write an event with the Warning level to the Warning log. + /// + /// Message template for this event. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Warning(string messageTemplate, bool show = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Warning(messageTemplate); + } + if(show) + _ShowLogAssistent(messageTemplate, null, callerMethodeName, callerFilePath, callerLineNumer); + } + + /// + /// Write an event with the Warning level with additional propertyValues to the Warning log. + /// + /// Message template for this event. + /// Data inserted into the message template. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Warning(string messageTemplate, object[] propertyValues, bool show = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Warning(messageTemplate, propertyValues); + } + if(show) + _ShowLogAssistent(messageTemplate, propertyValues, callerMethodeName, callerFilePath, callerLineNumer); + } + + /// + /// Write an event with the Warning level and associated exception to the Warning log. + /// + /// Exception of this event. + /// Message template for this event. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Warning(Exception exception, string messageTemplate, bool show = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Warning( exception, messageTemplate); + } + if(show) + _ShowLogAssistent(messageTemplate, null, callerMethodeName, callerFilePath, callerLineNumer); + } + + /// + /// Write an event with the Warning level with additional propertyValues and associated exception to the Warning log. + /// + /// Exception of this event. + /// Message template for this event. + /// Data inserted into the message template. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Warning(Exception exception, string messageTemplate, object[] propertyValues, bool show = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Warning(exception, messageTemplate, propertyValues); + } + if(show) + _ShowLogAssistent(messageTemplate, propertyValues, callerMethodeName, callerFilePath, callerLineNumer); + } + + #endregion + + #region Error functions + + /// + /// Write an event with the Error level to the Error log. + /// + /// Message template for this event. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Error(string messageTemplate, bool show = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Error(messageTemplate); + } + if(show) + _ShowLogAssistent(messageTemplate, null, callerMethodeName, callerFilePath, callerLineNumer); + } + + /// + /// Write an event with the Error level with additional propertyValues to the Error log. + /// + /// Message template for this event. + /// Data inserted into the message template. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Error(string messageTemplate, object[] propertyValues, bool show = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Error(messageTemplate, propertyValues); + } + if(show) + _ShowLogAssistent(messageTemplate, propertyValues, callerMethodeName, callerFilePath, callerLineNumer); + } + + /// + /// Write an event with the Error level and associated exception to the Error log. + /// + /// Exception of this event. + /// Message template for this event. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Error(Exception exception, string messageTemplate, bool show = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Error( exception, messageTemplate); + } + if(show) + _ShowLogAssistent(messageTemplate, null, callerMethodeName, callerFilePath, callerLineNumer); + } + + /// + /// Write an event with the Error level with additional propertyValues and associated exception to the Error log. + /// + /// Exception of this event. + /// Message template for this event. + /// Data inserted into the message template. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Error(Exception exception, string messageTemplate, object[] propertyValues, bool show = false, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Error(exception, messageTemplate, propertyValues); + } + if(show) + _ShowLogAssistent(messageTemplate, propertyValues, callerMethodeName, callerFilePath, callerLineNumer); + } + + #endregion + + #region Fatal functions + + /// + /// Write an event with the Fatal level to the Fatal log. + /// + /// Message template for this event. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Fatal(string messageTemplate, bool show = true, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Fatal(messageTemplate); + } + if(show) + _ShowLogAssistent(messageTemplate, null, callerMethodeName, callerFilePath, callerLineNumer); + } + + /// + /// Write an event with the Fatal level with additional propertyValues to the Fatal log. + /// + /// Message template for this event. + /// Data inserted into the message template. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Fatal(string messageTemplate, object[] propertyValues, bool show = true, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Fatal(messageTemplate, propertyValues); + } + if(show) + _ShowLogAssistent(messageTemplate, propertyValues, callerMethodeName, callerFilePath, callerLineNumer); + } + + /// + /// Write an event with the Fatal level and associated exception to the Fatal log. + /// + /// Exception of this event. + /// Message template for this event. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Fatal(Exception exception, string messageTemplate, bool show = true, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Fatal( exception, messageTemplate); + } + if(show) + _ShowLogAssistent(messageTemplate, null, callerMethodeName, callerFilePath, callerLineNumer); + } + + /// + /// Write an event with the Fatal level with additional propertyValues and associated exception to the Fatal log. + /// + /// Exception of this event. + /// Message template for this event. + /// Data inserted into the message template. + /// True if an message should be shown to the user, false otherwise. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Fatal(Exception exception, string messageTemplate, object[] propertyValues, bool show = true, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _MainLog.Fatal(exception, messageTemplate, propertyValues); + } + if(show) + _ShowLogAssistent(messageTemplate, propertyValues, callerMethodeName, callerFilePath, callerLineNumer); + } + + #endregion + + [SuppressMessage("ReSharper", "MemberHidesStaticFromOuterClass")] + public static class CSongLog + { + + #region Verbose functions + + /// + /// Write an event with the Verbose level to the Verbose log. + /// + /// Message template for this event. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Verbose(string messageTemplate, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Verbose(messageTemplate); + } + } + + /// + /// Write an event with the Verbose level with additional propertyValues to the Verbose log. + /// + /// Message template for this event. + /// Data inserted into the message template. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Verbose(string messageTemplate, object[] propertyValues, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Verbose(messageTemplate, propertyValues); + } + } + + /// + /// Write an event with the Verbose level and associated exception to the Verbose log. + /// + /// Exception of this event. + /// Message template for this event. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Verbose(Exception exception, string messageTemplate, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Verbose( exception, messageTemplate); + } + } + + /// + /// Write an event with the Verbose level with additional propertyValues and associated exception to the Verbose log. + /// + /// Exception of this event. + /// Message template for this event. + /// Data inserted into the message template. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Verbose(Exception exception, string messageTemplate, object[] propertyValues, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Verbose(exception, messageTemplate, propertyValues); + } + } + + #endregion + + #region Debug functions + + /// + /// Write an event with the Debug level to the Debug log. + /// + /// Message template for this event. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Debug(string messageTemplate, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Debug(messageTemplate); + } + } + + /// + /// Write an event with the Debug level with additional propertyValues to the Debug log. + /// + /// Message template for this event. + /// Data inserted into the message template. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Debug(string messageTemplate, object[] propertyValues, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Debug(messageTemplate, propertyValues); + } + } + + /// + /// Write an event with the Debug level and associated exception to the Debug log. + /// + /// Exception of this event. + /// Message template for this event. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Debug(Exception exception, string messageTemplate, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Debug( exception, messageTemplate); + } + } + + /// + /// Write an event with the Debug level with additional propertyValues and associated exception to the Debug log. + /// + /// Exception of this event. + /// Message template for this event. + /// Data inserted into the message template. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Debug(Exception exception, string messageTemplate, object[] propertyValues, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Debug(exception, messageTemplate, propertyValues); + } + } + + #endregion + + #region Information functions + + /// + /// Write an event with the Information level to the Information log. + /// + /// Message template for this event. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Information(string messageTemplate, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Information(messageTemplate); + } + } + + /// + /// Write an event with the Information level with additional propertyValues to the Information log. + /// + /// Message template for this event. + /// Data inserted into the message template. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Information(string messageTemplate, object[] propertyValues, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Information(messageTemplate, propertyValues); + } + } + + /// + /// Write an event with the Information level and associated exception to the Information log. + /// + /// Exception of this event. + /// Message template for this event. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Information(Exception exception, string messageTemplate, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Information( exception, messageTemplate); + } + } + + /// + /// Write an event with the Information level with additional propertyValues and associated exception to the Information log. + /// + /// Exception of this event. + /// Message template for this event. + /// Data inserted into the message template. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Information(Exception exception, string messageTemplate, object[] propertyValues, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Information(exception, messageTemplate, propertyValues); + } + } + + #endregion + + #region Warning functions + + /// + /// Write an event with the Warning level to the Warning log. + /// + /// Message template for this event. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Warning(string messageTemplate, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Warning(messageTemplate); + } + } + + /// + /// Write an event with the Warning level with additional propertyValues to the Warning log. + /// + /// Message template for this event. + /// Data inserted into the message template. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Warning(string messageTemplate, object[] propertyValues, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Warning(messageTemplate, propertyValues); + } + } + + /// + /// Write an event with the Warning level and associated exception to the Warning log. + /// + /// Exception of this event. + /// Message template for this event. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Warning(Exception exception, string messageTemplate, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Warning( exception, messageTemplate); + } + } + + /// + /// Write an event with the Warning level with additional propertyValues and associated exception to the Warning log. + /// + /// Exception of this event. + /// Message template for this event. + /// Data inserted into the message template. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Warning(Exception exception, string messageTemplate, object[] propertyValues, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Warning(exception, messageTemplate, propertyValues); + } + } + + #endregion + + #region Error functions + + /// + /// Write an event with the Error level to the Error log. + /// + /// Message template for this event. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Error(string messageTemplate, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Error(messageTemplate); + } + } + + /// + /// Write an event with the Error level with additional propertyValues to the Error log. + /// + /// Message template for this event. + /// Data inserted into the message template. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Error(string messageTemplate, object[] propertyValues, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Error(messageTemplate, propertyValues); + } + } + + /// + /// Write an event with the Error level and associated exception to the Error log. + /// + /// Exception of this event. + /// Message template for this event. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Error(Exception exception, string messageTemplate, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Error( exception, messageTemplate); + } + } + + /// + /// Write an event with the Error level with additional propertyValues and associated exception to the Error log. + /// + /// Exception of this event. + /// Message template for this event. + /// Data inserted into the message template. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Error(Exception exception, string messageTemplate, object[] propertyValues, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Error(exception, messageTemplate, propertyValues); + } + } + + #endregion + + #region Fatal functions + + /// + /// Write an event with the Fatal level to the Fatal log. + /// + /// Message template for this event. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Fatal(string messageTemplate, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Fatal(messageTemplate); + } + } + + /// + /// Write an event with the Fatal level with additional propertyValues to the Fatal log. + /// + /// Message template for this event. + /// Data inserted into the message template. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Fatal(string messageTemplate, object[] propertyValues, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Fatal(messageTemplate, propertyValues); + } + } + + /// + /// Write an event with the Fatal level and associated exception to the Fatal log. + /// + /// Exception of this event. + /// Message template for this event. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Fatal(Exception exception, string messageTemplate, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Fatal( exception, messageTemplate); + } + } + + /// + /// Write an event with the Fatal level with additional propertyValues and associated exception to the Fatal log. + /// + /// Exception of this event. + /// Message template for this event. + /// Data inserted into the message template. + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [MessageTemplateFormatMethod("messageTemplate")] + public static void Fatal(Exception exception, string messageTemplate, object[] propertyValues, [CallerMemberName] string callerMethodeName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumer = -1) + { + using (LogContext.PushProperty("CallingContext", new { callerMethodeName, callerFilePath, callerLineNumer})) + { + _SongLog.Fatal(exception, messageTemplate, propertyValues); + } + } + + #endregion + } + } +} \ No newline at end of file diff --git a/VocaluxeLib/Log/CLogFunctions.tt b/VocaluxeLib/Log/CLogFunctions.tt new file mode 100644 index 00000000..2fe5ec71 --- /dev/null +++ b/VocaluxeLib/Log/CLogFunctions.tt @@ -0,0 +1,139 @@ +<#@ 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" #> +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using Serilog.Context; +using Serilog.Core; + +namespace VocaluxeLib.Log +{ + public static partial class CLog + { + + 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"}) { #> + + #region <#= LogLevel #> functions + + /// + /// Write an event with the <#= LogLevel #> level to the <#= LogLevel #> log. + /// + /// Message template for this event. +<# if(Log == "Main") { #> + /// True if an message should be shown to the user, false otherwise. +<# } #> + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [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) + _ShowLogAssistent(messageTemplate, null, callerMethodeName, callerFilePath, callerLineNumer); +<# } #> + } + + /// + /// Write an event with the <#= LogLevel #> level with additional propertyValues to the <#= LogLevel #> log. + /// + /// Message template for this event. + /// Data inserted into the message template. +<# if(Log == "Main") { #> + /// True if an message should be shown to the user, false otherwise. +<# } #> + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [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})) + { + <#= Log == "Main"?"_MainLog":"_SongLog" #>.<#= LogLevel #>(messageTemplate, propertyValues); + } +<# if(Log == "Main") { #> + if(show) + _ShowLogAssistent(messageTemplate, propertyValues, callerMethodeName, callerFilePath, callerLineNumer); +<# } #> + } + + /// + /// Write an event with the <#= LogLevel #> level and associated exception to the <#= LogLevel #> log. + /// + /// Exception of this event. + /// Message template for this event. +<# if(Log == "Main") { #> + /// True if an message should be shown to the user, false otherwise. +<# } #> + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [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) + _ShowLogAssistent(messageTemplate, null, callerMethodeName, callerFilePath, callerLineNumer); +<# } #> + } + + /// + /// Write an event with the <#= LogLevel #> level with additional propertyValues and associated exception to the <#= LogLevel #> log. + /// + /// Exception of this event. + /// Message template for this event. + /// Data inserted into the message template. +<# if(Log == "Main") { #> + /// True if an message should be shown to the user, false otherwise. +<# } #> + /// Don't use! The methode name of the caller will be filled automatically by the compiler. + /// Don't use! The filepath of the caller will be filled automatically by the compiler. + /// Don't use! The line number of the caller will be filled automatically by the compiler. + [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})) + { + <#= Log == "Main"?"_MainLog":"_SongLog" #>.<#= LogLevel #>(exception, messageTemplate, propertyValues); + } +<# if(Log == "Main") { #> + if(show) + _ShowLogAssistent(messageTemplate, propertyValues, callerMethodeName, callerFilePath, callerLineNumer); +<# } #> + } + + #endregion +<# } #> +<# if(Log == "Song") { #> +<# PopIndent(); #> + } +<# } #> +<# } #> + } +} \ No newline at end of file diff --git a/VocaluxeLib/Log/Enricher/CTimeStampFromStartEnricher.cs b/VocaluxeLib/Log/Enricher/CTimeStampFromStartEnricher.cs new file mode 100644 index 00000000..4b924dba --- /dev/null +++ b/VocaluxeLib/Log/Enricher/CTimeStampFromStartEnricher.cs @@ -0,0 +1,28 @@ +using System; +using Serilog; +using Serilog.Configuration; +using Serilog.Core; +using Serilog.Events; + +namespace VocaluxeLib.Log.Enricher +{ + public static class WithTimeStampFromStartExtension + { + // 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)); + } + } + } +} diff --git a/VocaluxeLib/Log/Rolling/LogRoller.cs b/VocaluxeLib/Log/Rolling/LogRoller.cs new file mode 100644 index 00000000..adb69ab5 --- /dev/null +++ b/VocaluxeLib/Log/Rolling/LogRoller.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text.RegularExpressions; + +namespace VocaluxeLib.Log.Rolling +{ + static class LogFileRoller + { + 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) + { + // Cant log anything here as the log isn't initialized yet + } + } + } + + if (File.Exists(mainLogFile)) + { + try + { + if (numLogsToKeep > 0) + File.Move(mainLogFile, currentSourceFile); + else + File.Delete(mainLogFile); + } + catch (Exception) + { + // Cant log anything here as the log isn't initialized yet + } + } + } + + 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 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) + { + // Cant log anything here as the log isn't initialized yet + } + + } + } + } + } + + private static string _GenerateRollLogFileName(string mainLogFile, int number) + { + return $"{Path.GetDirectoryName(mainLogFile)}\\{Path.GetFileNameWithoutExtension(mainLogFile)}_{number}{Path.GetExtension(mainLogFile)}"; + } + } +} diff --git a/VocaluxeLib/Log/Serilog/SilentLogger.cs b/VocaluxeLib/Log/Serilog/SilentLogger.cs new file mode 100644 index 00000000..475a530f --- /dev/null +++ b/VocaluxeLib/Log/Serilog/SilentLogger.cs @@ -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 SilentLogger : ILogger + { + public ILogger ForContext(ILogEventEnricher enricher) + { + return this; + } + + public ILogger ForContext(IEnumerable enrichers) + { + return this; + } + + public ILogger ForContext(string propertyName, object value, bool destructureObjects = false) + { + return this; + } + + public ILogger ForContext() + { + return this; + } + + public ILogger ForContext(Type source) + { + return this; + } + + public void Write(LogEvent logEvent) + { + } + + public void Write(LogEventLevel level, string messageTemplate) + { + } + + public void Write(LogEventLevel level, string messageTemplate, T propertyValue) + { + } + + public void Write(LogEventLevel level, string messageTemplate, T0 propertyValue0, T1 propertyValue1) + { + } + + public void Write(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(LogEventLevel level, Exception exception, string messageTemplate, T propertyValue) + { + } + + public void Write(LogEventLevel level, Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) + { + } + + public void Write(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(string messageTemplate, T propertyValue) + { + } + + public void Verbose(string messageTemplate, T0 propertyValue0, T1 propertyValue1) + { + } + + public void Verbose(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(Exception exception, string messageTemplate, T propertyValue) + { + } + + public void Verbose(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) + { + } + + public void Verbose(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(string messageTemplate, T propertyValue) + { + } + + public void Debug(string messageTemplate, T0 propertyValue0, T1 propertyValue1) + { + } + + public void Debug(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(Exception exception, string messageTemplate, T propertyValue) + { + } + + public void Debug(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) + { + } + + public void Debug(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(string messageTemplate, T propertyValue) + { + } + + public void Information(string messageTemplate, T0 propertyValue0, T1 propertyValue1) + { + } + + public void Information(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(Exception exception, string messageTemplate, T propertyValue) + { + } + + public void Information(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) + { + } + + public void Information(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(string messageTemplate, T propertyValue) + { + } + + public void Warning(string messageTemplate, T0 propertyValue0, T1 propertyValue1) + { + } + + public void Warning(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(Exception exception, string messageTemplate, T propertyValue) + { + } + + public void Warning(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) + { + } + + public void Warning(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(string messageTemplate, T propertyValue) + { + } + + public void Error(string messageTemplate, T0 propertyValue0, T1 propertyValue1) + { + } + + public void Error(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(Exception exception, string messageTemplate, T propertyValue) + { + } + + public void Error(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) + { + } + + public void Error(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(string messageTemplate, T propertyValue) + { + } + + public void Fatal(string messageTemplate, T0 propertyValue0, T1 propertyValue1) + { + } + + public void Fatal(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(Exception exception, string messageTemplate, T propertyValue) + { + } + + public void Fatal(Exception exception, string messageTemplate, T0 propertyValue0, T1 propertyValue1) + { + } + + public void Fatal(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 boundProperties) + { + parsedTemplate = null; + boundProperties = null; + return false; + } + + public bool BindProperty(string propertyName, object value, bool destructureObjects, out LogEventProperty property) + { + property = null; + return false; + } + } +} \ No newline at end of file diff --git a/VocaluxeLib/Menu/CMenu.cs b/VocaluxeLib/Menu/CMenu.cs index 3ea5af46..8c82185a 100644 --- a/VocaluxeLib/Menu/CMenu.cs +++ b/VocaluxeLib/Menu/CMenu.cs @@ -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()) 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); } } diff --git a/VocaluxeLib/Menu/COrderedDictionaryLite.cs b/VocaluxeLib/Menu/COrderedDictionaryLite.cs index 3bb7d995..da8a2cbe 100644 --- a/VocaluxeLib/Menu/COrderedDictionaryLite.cs +++ b/VocaluxeLib/Menu/COrderedDictionaryLite.cs @@ -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; } } diff --git a/VocaluxeLib/Profile/CProfile.cs b/VocaluxeLib/Profile/CProfile.cs index 5f4de009..1f2e60ea 100644 --- a/VocaluxeLib/Profile/CProfile.cs +++ b/VocaluxeLib/Profile/CProfile.cs @@ -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; diff --git a/VocaluxeLib/Songs/CSong.cs b/VocaluxeLib/Songs/CSong.cs index 46fe2267..fb9c033e 100644 --- a/VocaluxeLib/Songs/CSong.cs +++ b/VocaluxeLib/Songs/CSong.cs @@ -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 + "\"."); } } diff --git a/VocaluxeLib/Songs/CSongLoader.cs b/VocaluxeLib/Songs/CSongLoader.cs index 17a7bc7a..99702bc8 100644 --- a/VocaluxeLib/Songs/CSongLoader.cs +++ b/VocaluxeLib/Songs/CSongLoader.cs @@ -19,6 +19,7 @@ using System; using System.IO; using System.Linq; using System.Text; +using VocaluxeLib.Log; namespace VocaluxeLib.Songs { @@ -121,8 +122,7 @@ namespace VocaluxeLib.Songs if (value == "") { _Song.UnknownTags.Add(line); - CBase.Log.LogSongWarning("[{SongFileName}] Empty value skipped", _Song.FileName); - + CLog.CSongLog.Warning("[{SongFileName}] Empty value skipped", CLog.Params(_Song.FileName)); continue; } @@ -135,7 +135,7 @@ namespace VocaluxeLib.Songs { if (useSetEncoding) { - CBase.Log.LogSongWarning("[{SongFileName}] Duplicate encoding ignored", _Song.FileName); + CLog.CSongLog.Warning("[{SongFileName}] Duplicate encoding ignored", CLog.Params(_Song.FileName)); continue; } sr.Dispose(); @@ -181,7 +181,7 @@ namespace VocaluxeLib.Songs } else { - CBase.Log.LogSongError("[{SongFileName}] Can't find audio file: {AudioFile}", _Song.FileName, 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; @@ -192,19 +192,19 @@ namespace VocaluxeLib.Songs headerFlags |= EHeaderFlags.BPM; } else - CBase.Log.LogSongWarning("[{SongFileName}] Invalid BPM value: {Value}", _Song.FileName, 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 - CBase.Log.LogSongWarning("[{SongFileName}] Invalid edition: {Value}", _Song.FileName, value); + CLog.CSongLog.Warning("[{SongFileName}] Invalid edition: {Value}", CLog.Params(_Song.FileName, value)); break; case "GENRE": if (value.Length > 1) _Song.Genres.Add(value); else - CBase.Log.LogSongWarning("[{SongFileName}] Invalid genre: {Value}", _Song.FileName, value); + CLog.CSongLog.Warning("[{SongFileName}] Invalid genre: {Value}", CLog.Params(_Song.FileName, value)); break; case "ALBUM": _Song.Album = value; @@ -214,13 +214,13 @@ namespace VocaluxeLib.Songs if (value.Length == 4 && int.TryParse(value, out num) && num > 0) _Song.Year = value; else - CBase.Log.LogSongWarning("[{SongFileName}] Invalid year: {Value}", _Song.FileName, value); + 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 - CBase.Log.LogSongWarning("[{SongFileName}] Invalid language: {Value}", _Song.FileName, value); + CLog.CSongLog.Warning("[{SongFileName}] Invalid language: {Value}", CLog.Params(_Song.FileName, value)); break; case "COMMENT": if (!String.IsNullOrEmpty(_Song._Comment)) @@ -231,49 +231,49 @@ namespace VocaluxeLib.Songs if (CHelper.TryParse(value, out _Song.Gap)) _Song.Gap /= 1000f; else - CBase.Log.LogSongWarning("[{SongFileName}] Invalid gap: {Value}", _Song.FileName, value); + 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 - CBase.Log.LogSongWarning("[{SongFileName}] Can't find cover file: {MissingFile}", _Song.FileName, 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 - CBase.Log.LogSongWarning("[{SongFileName}] Can't find background file: {MissingFile}", _Song.FileName, 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 - CBase.Log.LogSongWarning("[{SongFileName}] Can't find video file: {MissingFile}", _Song.FileName, 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)) - CBase.Log.LogSongWarning("[{SongFileName}] Invalid videogap: {Value}", _Song.FileName, value); + CLog.CSongLog.Warning("[{SongFileName}] Invalid videogap: {Value}", CLog.Params(_Song.FileName, value)); break; case "VIDEOASPECT": if (!CHelper.TryParse(value, out _Song.VideoAspect, true)) - CBase.Log.LogSongWarning("[{SongFileName}] Invalid videoaspect: {Value}", _Song.FileName, value); + CLog.CSongLog.Warning("[{SongFileName}] Invalid videoaspect: {Value}", CLog.Params(_Song.FileName, value)); break; case "START": if (!CHelper.TryParse(value, out _Song.Start)) - CBase.Log.LogSongWarning("[{SongFileName}] Invalid start: {Value}", _Song.FileName, value); + 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 - CBase.Log.LogSongWarning("[{SongFileName}] Invalid end: {Value}", _Song.FileName, value); + 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 - CBase.Log.LogSongWarning("[{SongFileName}] Invalid previewstart: {Value}", _Song.FileName, value); + 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) @@ -283,19 +283,19 @@ namespace VocaluxeLib.Songs _Song.Preview.Source = EDataSource.Tag; } else - CBase.Log.LogSongWarning("[{SongFileName}] Invalid previewstart: {Value}", _Song.FileName, value); + 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 - CBase.Log.LogSongWarning("[{SongFileName}] Invalid medleystartbeat: {Value}", _Song.FileName, value); + 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 - CBase.Log.LogSongWarning("[{SongFileName}] Invalid medleyendbeat: {Value}", _Song.FileName, value); + CLog.CSongLog.Warning("[{SongFileName}] Invalid medleyendbeat: {Value}", CLog.Params(_Song.FileName, value)); break; case "ENDSHORT": if ((headerFlags & EHeaderFlags.BPM) != 0) @@ -307,7 +307,7 @@ namespace VocaluxeLib.Songs _Song.ShortEnd.Source = EDataSource.Tag; } else - CBase.Log.LogSongWarning("[{SongFileName}] Invalid shortendbeat: {Value}", _Song.FileName, value); + CLog.CSongLog.Warning("[{SongFileName}] Invalid shortendbeat: {Value}", CLog.Params(_Song.FileName, value)); } break; case "CALCMEDLEY": @@ -342,7 +342,7 @@ namespace VocaluxeLib.Songs else { _Song.UnknownTags.Add(line); - CBase.Log.LogSongWarning("[{SongFileName}] Unknown tag: #{Identifier}", _Song.FileName, identifier); + CLog.CSongLog.Warning("[{SongFileName}] Unknown tag: #{Identifier}", CLog.Params(_Song.FileName, identifier)); } break; @@ -352,32 +352,32 @@ namespace VocaluxeLib.Songs if (sr.EndOfStream) { //No other data then header - CBase.Log.LogSongError("[{SongFileName}] Lyrics/Notes missing", _Song.FileName); + CLog.CSongLog.Error("[{SongFileName}] Lyrics/Notes missing", CLog.Params(_Song.FileName)); return false; } if ((headerFlags & EHeaderFlags.Title) == 0) { - CBase.Log.LogSongError("[{SongFileName}] Title tag missing", _Song.FileName); + CLog.CSongLog.Error("[{SongFileName}] Title tag missing", CLog.Params(_Song.FileName)); return false; } if ((headerFlags & EHeaderFlags.Artist) == 0) { - CBase.Log.LogSongError("[{SongFileName}] Artist tag missing", _Song.FileName); + CLog.CSongLog.Error("[{SongFileName}] Artist tag missing", CLog.Params(_Song.FileName)); return false; } if ((headerFlags & EHeaderFlags.MP3) == 0) { - CBase.Log.LogSongError("[{SongFileName}] MP3 tag missing", _Song.FileName); + CLog.CSongLog.Error("[{SongFileName}] MP3 tag missing", CLog.Params(_Song.FileName)); return false; } if ((headerFlags & EHeaderFlags.BPM) == 0) { - CBase.Log.LogSongError("[{SongFileName}] BPM tag missing", _Song.FileName); + CLog.CSongLog.Error("[{SongFileName}] BPM tag missing", CLog.Params(_Song.FileName)); return false; } @@ -386,7 +386,7 @@ namespace VocaluxeLib.Songs { if (_Song.Medley.StartBeat > _Song.Medley.EndBeat) { - CBase.Log.LogSongError("[{SongFileName}] MedleyStartBeat is bigger than MedleyEndBeat in file: {StartBeat} > {EndBeat}", _Song.FileName, _Song.Medley.StartBeat > _Song.Medley.EndBeat); + 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; } } @@ -412,7 +412,7 @@ namespace VocaluxeLib.Songs { if (sr != null) sr.Dispose(); - CBase.Log.LogSongError(e, "[{SongFileName}] Error reading txt header with Message: {ExceptionMessage}", e.Message, _Song.FileName); + CLog.CSongLog.Error(e, "[{SongFileName}] Error reading txt header with Message: {ExceptionMessage}", CLog.Params(e.Message, _Song.FileName)); return false; } _Song.Encoding = sr.CurrentEncoding; @@ -509,7 +509,7 @@ namespace VocaluxeLib.Songs if (!File.Exists(filePath)) { - CBase.Log.LogSongError("[{SongFileName}] The file songfile does not exist", _Song.FileName); + CLog.CSongLog.Error("[{SongFileName}] The file songfile does not exist", CLog.Params(_Song.FileName)); return false; } @@ -558,7 +558,7 @@ namespace VocaluxeLib.Songs if (!int.TryParse(line, out player)) { - CBase.Log.LogSongError("[{SongFileName}] Wrong or missing number after \"P\" (in line {LineNr})", _Song.FileName, _LineNr); + CLog.CSongLog.Error("[{SongFileName}] Wrong or missing number after \"P\" (in line {LineNr})", CLog.Params(_Song.FileName, _LineNr)); return false; } currentBeat = 0; @@ -572,25 +572,25 @@ namespace VocaluxeLib.Songs { if (noteData.Length == 3) { - CBase.Log.LogSongWarning("[{SongFileName}] Ignored note without text (in line {LineNr})", _Song.FileName, _LineNr); + CLog.CSongLog.Warning("[{SongFileName}] Ignored note without text (in line {LineNr})", CLog.Params(_Song.FileName, _LineNr)); changesMade.NoTextNoteCt++; continue; } - CBase.Log.LogSongError("[{SongFileName}] Invalid note found (in line {LineNr}): {noteData}", _Song.FileName, _LineNr, noteData); + 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)) { - CBase.Log.LogSongError("[{SongFileName}] Invalid note found (non-numeric values) (in line {LineNr}): {noteData}", _Song.FileName, _LineNr, noteData); + 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 == "") { - CBase.Log.LogSongWarning("[{SongFileName}] Ignored note without text (in line {LineNr})", _Song.FileName, _LineNr); + CLog.CSongLog.Warning("[{SongFileName}] Ignored note without text (in line {LineNr})", CLog.Params(_Song.FileName, _LineNr)); changesMade.NoTextNoteCt++; continue; } @@ -601,12 +601,12 @@ namespace VocaluxeLib.Songs changesMade.ZeroLengthNoteCt++; if (_CurrentReadMode == ENoteReadMode.Normal && changesMade.ZeroLengthNoteCt > _MaxZeroNoteCt && changesMade.OverlapNoteCt <= _MaxOverlapNoteCt) { - CBase.Log.LogSongWarning("[{SongFileName}] Found more than {MaxZeroNoteCt} notes with length < 1. Trying alternative read mode.", _Song.FileName, _MaxZeroNoteCt); + 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); } - CBase.Log.LogSongWarning("[{SongFileName}] Ignored note with length < 1 (in line {LineNr})", _Song.FileName, _LineNr); + CLog.CSongLog.Warning("[{SongFileName}] Ignored note with length < 1 (in line {LineNr})", CLog.Params(_Song.FileName, _LineNr)); } else { @@ -635,13 +635,13 @@ namespace VocaluxeLib.Songs changesMade.OverlapNoteCt++; if (changesMade.OverlapNoteCt > _MaxOverlapNoteCt && _CurrentReadMode == ENoteReadMode.ZeroBased) { - CBase.Log.LogSongWarning("[{SongFileName}] Found more than {MaxOverlapNoteCt} overlapping notes. Using standard mode.", _Song.FileName, _MaxOverlapNoteCt); + 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); } } - CBase.Log.LogSongWarning("[{SongFileName}] Ignored note for player {CurrentPlayerNumber} because it overlaps with other note (in line {LineNr})", _Song.FileName, (curPlayer + 1), _LineNr); + 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)); } } } @@ -650,13 +650,13 @@ namespace VocaluxeLib.Songs string[] lineBreakData = line.Split(splitChars); if (lineBreakData.Length < 1) { - CBase.Log.LogSongError("[{SongFileName}] Invalid line break found (No beat) (in line {LineNr}): {LineBreakData}", _Song.FileName, _LineNr, lineBreakData); + 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)) { - CBase.Log.LogSongError("[{SongFileName}] Invalid line break found (Non-numeric value) (in line {LineNr}): {LineBreakData}", _Song.FileName, _LineNr, lineBreakData); + 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; } @@ -666,7 +666,7 @@ namespace VocaluxeLib.Songs beat += currentBeat; if (lineBreakData.Length < 2 || !int.TryParse(lineBreakData[1], out length)) { - CBase.Log.LogSongWarning("[{SongFileName}] Missing line break length (in line {LineNr}):{LineBreakData}", _Song.FileName, _LineNr, lineBreakData); + CLog.CSongLog.Warning("[{SongFileName}] Missing line break length (in line {LineNr}):{LineBreakData}", CLog.Params(_Song.FileName, _LineNr, lineBreakData)); changesMade.NoLengthBreakCt++; currentBeat = beat; } @@ -676,7 +676,7 @@ namespace VocaluxeLib.Songs if (lastNote != null && beat <= lastNote.EndBeat) { - CBase.Log.LogSongWarning("[{SongFileName}] Line break is before previous note end. Adjusted. (in line {LineNr})", _Song.FileName, _LineNr); + 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) @@ -686,7 +686,7 @@ namespace VocaluxeLib.Songs if (beat < 1) { - CBase.Log.LogSongWarning("[{SongFileName}] Ignored line break because position is < 1 (in line {LineNr})", _Song.FileName, _LineNr); + CLog.CSongLog.Warning("[{SongFileName}] Ignored line break because position is < 1 (in line {LineNr})", CLog.Params(_Song.FileName, _LineNr)); changesMade.InvalidPosBreakCt++; } else @@ -694,12 +694,12 @@ namespace VocaluxeLib.Songs foreach (int curPlayer in player.GetSetBits()) { if (!_NewSentence(curPlayer, beat)) - CBase.Log.LogSongWarning("[{SongFileName}] Ignored line break for player {CurPlayerNr} (Overlapping or duplicate) (in line {LineNr})", _Song.FileName, (curPlayer + 1) , _LineNr); + 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: - CBase.Log.LogSongError("[{SongFileName}] Unexpected or missing character ({Tag})", _Song.FileName, tag); + CLog.CSongLog.Error("[{SongFileName}] Unexpected or missing character ({Tag})", CLog.Params(_Song.FileName, tag)); return false; } } @@ -709,13 +709,13 @@ namespace VocaluxeLib.Songs CVoice voice = _Song.Notes.GetVoice(i); int emptyLines = voice.RemoveEmptyLines(); if (emptyLines > 0) - CBase.Log.LogSongWarning("[{SongFileName}] Removed {NumEmptyLines} empty lines from P .This often indicates a problem with the line breaks in the file", _Song.FileName, emptyLines); + 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) { - CBase.Log.LogSongError(e, "[{SongFileName}] An unhandled exception occured: {ExceptionMessage}", _Song.FileName, 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; @@ -732,14 +732,13 @@ namespace VocaluxeLib.Songs } catch (Exception e) { - CBase.Log.LogSongError(e, "[{SongFileName}] An unhandled exception occured: {ExceptionMessage}", _Song.FileName, e.Message); + 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); diff --git a/VocaluxeLib/Songs/CSongWriter.cs b/VocaluxeLib/Songs/CSongWriter.cs index 7d5eb4ca..bdae39c4 100644 --- a/VocaluxeLib/Songs/CSongWriter.cs +++ b/VocaluxeLib/Songs/CSongWriter.cs @@ -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 diff --git a/VocaluxeLib/VocaluxeLib.csproj b/VocaluxeLib/VocaluxeLib.csproj index c0265ccf..c8d5068e 100644 --- a/VocaluxeLib/VocaluxeLib.csproj +++ b/VocaluxeLib/VocaluxeLib.csproj @@ -82,6 +82,31 @@ true + + + ..\packages\Serilog.2.6.0\lib\net46\Serilog.dll + True + + + ..\packages\Serilog.Enrichers.Thread.3.0.0\lib\net45\Serilog.Enrichers.Thread.dll + True + + + ..\packages\Serilog.Sinks.Console.3.1.1\lib\net45\Serilog.Sinks.Console.dll + True + + + ..\packages\Serilog.Sinks.File.4.0.0\lib\net45\Serilog.Sinks.File.dll + True + + + ..\packages\Serilog.Sinks.TextWriter.2.1.0\lib\net45\Serilog.Sinks.TextWriter.dll + True + + + ..\packages\SerilogTimings.2.2.0\lib\net45\SerilogTimings.dll + True + @@ -91,10 +116,19 @@ + + + + + + True + True + CLogFunctions.tt + @@ -160,6 +194,18 @@ + + + + + + TextTemplatingFileGenerator + CLogFunctions.cs + + + + + diff --git a/VocaluxeLib/Xml/CXmlDeserializer.cs b/VocaluxeLib/Xml/CXmlDeserializer.cs index 0a3b6e70..5a415397 100644 --- a/VocaluxeLib/Xml/CXmlDeserializer.cs +++ b/VocaluxeLib/Xml/CXmlDeserializer.cs @@ -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()); } } diff --git a/VocaluxeLib/packages.config b/VocaluxeLib/packages.config new file mode 100644 index 00000000..66ace7ae --- /dev/null +++ b/VocaluxeLib/packages.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/VocaluxeTests/PartyModeTests.cs b/VocaluxeTests/PartyModeTests.cs index 4108e8df..04374e62 100644 --- a/VocaluxeTests/PartyModeTests.cs +++ b/VocaluxeTests/PartyModeTests.cs @@ -4,6 +4,7 @@ using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; using Vocaluxe.Base; using VocaluxeLib; +using VocaluxeLib.Log; using VocaluxeLib.PartyModes.Challenge; namespace VocaluxeTests @@ -46,8 +47,7 @@ namespace VocaluxeTests public void TestRoundGeneration() { CBase.Game = new CBGame(); - CLog.Init(CSettings.FolderNameLogs); - CBase.Log = new CBlog(); + CLog.Init(CSettings.FolderNameLogs, CSettings.FileNameMainLog, CSettings.FileNameSongLog); for (int i = 0; i < 10; i++) { for (int numPlayer = 1; numPlayer <= 20; numPlayer++) @@ -61,7 +61,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)); } }