diff --git a/FoxTunes.Config/Configuration.cs b/FoxTunes.Config/Configuration.cs index dee0cbdb8..be30b0643 100644 --- a/FoxTunes.Config/Configuration.cs +++ b/FoxTunes.Config/Configuration.cs @@ -69,13 +69,13 @@ public bool Contains(string id) private void Add(ConfigurationSection section) { - //Logger.Write(this, LogLevel.Debug, "Adding configuration section: {0} => {1}", section.Id, section.Name); + Logger.Write(this, LogLevel.Debug, "Adding configuration section: {0} => {1}", section.Id, section.Name); this.Sections.Add(section.Id, section); } private void Update(ConfigurationSection section) { - //Logger.Write(this, LogLevel.Debug, "Updating configuration section: {0} => {1}", section.Id, section.Name); + Logger.Write(this, LogLevel.Debug, "Updating configuration section: {0} => {1}", section.Id, section.Name); var existing = this.GetSection(section.Id); existing.Update(section); } @@ -103,10 +103,10 @@ public void Load(string profile) } if (!File.Exists(fileName)) { - //Logger.Write(this, LogLevel.Debug, "Configuration file \"{0}\" does not exist.", fileName); + Logger.Write(this, LogLevel.Debug, "Configuration file \"{0}\" does not exist.", fileName); return; } - //Logger.Write(this, LogLevel.Debug, "Loading configuration from file \"{0}\".", fileName); + Logger.Write(this, LogLevel.Debug, "Loading configuration from file \"{0}\".", fileName); this.OnLoading(); try { @@ -121,18 +121,18 @@ public void Load(string profile) { //If config was created by a component that is no longer loaded then it will be lost here. //TODO: Add the config but hide it so it's preserved but not displayed. - //Logger.Write(this, LogLevel.Warn, "Configuration section \"{0}\" no longer exists.", section.Key); + Logger.Write(this, LogLevel.Warn, "Configuration section \"{0}\" no longer exists.", section.Key); continue; } var existing = this.GetSection(section.Key); try { - //Logger.Write(this, LogLevel.Debug, "Loading configuration section \"{0}\".", section.Key); + Logger.Write(this, LogLevel.Debug, "Loading configuration section \"{0}\".", section.Key); restoredElements.AddRange(this.Load(existing, section.Value)); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to load configuration section \"{0}\": {1}", existing.Id, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to load configuration section \"{0}\": {1}", existing.Id, e.Message); } } } @@ -142,14 +142,14 @@ public void Load(string profile) { continue; } - //Logger.Write(this, LogLevel.Debug, "Resetting configuration element: \"{0}\".", modifiedElement.Id); + Logger.Write(this, LogLevel.Debug, "Resetting configuration element: \"{0}\".", modifiedElement.Id); modifiedElement.Reset(); } Profiles.Profile = profile; } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to load configuration: {0}", e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to load configuration: {0}", e.Message); } this.OnLoaded(); } @@ -163,10 +163,10 @@ protected virtual IEnumerable Load(ConfigurationSection se { //If config was created by a component that is no longer loaded then it will be lost here. //TODO: Add the config but hide it so it's preserved but not displayed. - //Logger.Write(this, LogLevel.Warn, "Configuration element \"{0}\" no longer exists.", element.Key); + Logger.Write(this, LogLevel.Warn, "Configuration element \"{0}\" no longer exists.", element.Key); continue; } - //Logger.Write(this, LogLevel.Debug, "Loading configuration element: \"{0}\".", element.Key); + Logger.Write(this, LogLevel.Debug, "Loading configuration element: \"{0}\".", element.Key); var existing = section.GetElement(element.Key); existing.SetPersistentValue(element.Value); restoredElements.Add(existing); @@ -211,7 +211,7 @@ public void Save(string profile) } var fileName = Profiles.GetFileName(profile); this.OnSaving(); - //Logger.Write(this, LogLevel.Debug, "Saving configuration to file \"{0}\".", fileName); + Logger.Write(this, LogLevel.Debug, "Saving configuration to file \"{0}\".", fileName); try { //Use a temp file so the settings aren't lost if something goes wrong. @@ -226,9 +226,9 @@ public void Save(string profile) } Profiles.Profile = profile; } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to save configuration: {0}", e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to save configuration: {0}", e.Message); } this.OnSaved(); } @@ -251,9 +251,9 @@ public void Copy(string profile) } Profiles.Profile = profile; } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to copy configuration: {0}", e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to copy configuration: {0}", e.Message); } } @@ -299,9 +299,9 @@ public void Delete(string profile) } this.Load(); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to delete configuration: {0}", e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to delete configuration: {0}", e.Message); } this.OnSaved(); } diff --git a/FoxTunes.Config/Profiles.cs b/FoxTunes.Config/Profiles.cs index 78ef24e1f..875748598 100644 --- a/FoxTunes.Config/Profiles.cs +++ b/FoxTunes.Config/Profiles.cs @@ -8,6 +8,14 @@ namespace FoxTunes { public static class Profiles { + private static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + private static readonly string ConfigurationFileName = Path.Combine( Publication.StoragePath, "Profiles.txt" @@ -32,16 +40,16 @@ public static class Profiles } } } - catch + catch (Exception e) { - //Logger.Write(typeof(Profiles), LogLevel.Warn, "Failed to read available profiles: {0}", e.Message); + Logger.Write(typeof(Profiles), LogLevel.Warn, "Failed to read available profiles: {0}", e.Message); } } if (!profiles.Contains(Strings.Profiles_Default, StringComparer.OrdinalIgnoreCase)) { profiles.Insert(0, Strings.Profiles_Default); } - //Logger.Write(typeof(Profiles), LogLevel.Debug, "Available profiles: {0}", string.Join(", ", profiles)); + Logger.Write(typeof(Profiles), LogLevel.Debug, "Available profiles: {0}", string.Join(", ", profiles)); return profiles; }); @@ -103,9 +111,9 @@ private static void Update(string profile, bool delete) } } } - catch + catch (Exception e) { - //Logger.Write(typeof(Profiles), LogLevel.Warn, "Failed to write available profiles: {0}", e.Message); + Logger.Write(typeof(Profiles), LogLevel.Warn, "Failed to write available profiles: {0}", e.Message); } _AvailableProfiles.Reset(); } diff --git a/FoxTunes.Config/Serializer.cs b/FoxTunes.Config/Serializer.cs index ad63c1d34..ca8b8c4fd 100644 --- a/FoxTunes.Config/Serializer.cs +++ b/FoxTunes.Config/Serializer.cs @@ -9,6 +9,14 @@ namespace FoxTunes { public static class Serializer { + private static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + public static void Save(Stream stream, IEnumerable sections) { using (var writer = new XmlTextWriter(stream, Encoding.Default)) @@ -25,12 +33,12 @@ public static void Save(Stream stream, IEnumerable section { continue; } - //Logger.Write(typeof(Serializer), LogLevel.Trace, "Saving configuration section: \"{0}\".", section.Id); + Logger.Write(typeof(Serializer), LogLevel.Trace, "Saving configuration section: \"{0}\".", section.Id); writer.WriteStartElement(nameof(ConfigurationSection)); writer.WriteAttributeString(nameof(section.Id), section.Id); foreach (var element in elements) { - //Logger.Write(typeof(Serializer), LogLevel.Trace, "Saving configuration element: \"{0}\".", element.Id); + Logger.Write(typeof(Serializer), LogLevel.Trace, "Saving configuration element: \"{0}\".", element.Id); writer.WriteStartElement(nameof(ConfigurationElement)); writer.WriteAttributeString(nameof(ConfigurationElement.Id), element.Id); writer.WriteCData(element.GetPersistentValue()); @@ -53,7 +61,7 @@ public static IEnumerable>>(id, Load(reader))); if (reader.NodeType == XmlNodeType.EndElement && string.Equals(reader.Name, nameof(ConfigurationSection))) @@ -75,7 +83,7 @@ private static IEnumerable> Load(XmlReader reader) while (reader.IsStartElement(nameof(ConfigurationElement))) { var id = reader.GetAttribute(nameof(ConfigurationElement.Id)); - //Logger.Write(typeof(Serializer), LogLevel.Trace, "Loading configuration element: \"{0}\".", id); + Logger.Write(typeof(Serializer), LogLevel.Trace, "Loading configuration element: \"{0}\".", id); reader.ReadStartElement(nameof(ConfigurationElement)); elements.Add(new KeyValuePair(id, reader.Value)); reader.Read(); //Done with CreateImages(IntPtr handle) { - //Logger.Write(this, LogLevel.Debug, "Creating taskbar button image list."); + Logger.Write(this, LogLevel.Debug, "Creating taskbar button image list."); var source = HwndSource.FromHwnd(handle); if (source == null) { - //Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); + Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); this.AddFlag(handle, TaskbarButtonsWindowFlags.Error); return false; } @@ -359,7 +359,7 @@ protected virtual async Task CreateImages(IntPtr handle) var height = WindowsSystemMetrics.GetSystemMetrics( WindowsSystemMetrics.SystemMetric.SM_CYSMICON ); - //Logger.Write(this, LogLevel.Debug, "Taskbar buttom image dimentions: {0}x{1}", width, height); + Logger.Write(this, LogLevel.Debug, "Taskbar buttom image dimentions: {0}x{1}", width, height); var imageList = WindowsImageList.ImageList_Create( width, height, @@ -369,7 +369,7 @@ protected virtual async Task CreateImages(IntPtr handle) ); if (IntPtr.Zero.Equals(imageList)) { - //Logger.Write(this, LogLevel.Warn, "Failed to create button image list."); + Logger.Write(this, LogLevel.Warn, "Failed to create button image list."); this.AddFlag(handle, TaskbarButtonsWindowFlags.Error); return false; } @@ -394,13 +394,13 @@ await source.Invoke( ).ConfigureAwait(false); if (result != WindowsTaskbarList.HResult.Ok) { - //Logger.Write(this, LogLevel.Warn, "Failed to create button image list: {0}", Enum.GetName(typeof(WindowsTaskbarList.HResult), result)); + Logger.Write(this, LogLevel.Warn, "Failed to create button image list: {0}", Enum.GetName(typeof(WindowsTaskbarList.HResult), result)); this.AddFlag(handle, TaskbarButtonsWindowFlags.Error); return false; } else { - //Logger.Write(this, LogLevel.Debug, "Taskbar button image list created."); + Logger.Write(this, LogLevel.Debug, "Taskbar button image list created."); this.AddFlag(handle, TaskbarButtonsWindowFlags.ImagesCreated); return true; } @@ -412,14 +412,14 @@ protected virtual bool AddImage(IntPtr handle, IntPtr imageList, Bitmap bitmap, { if (!hdc.IsValid) { - //Logger.Write(this, LogLevel.Warn, "Failed to create device context."); + Logger.Write(this, LogLevel.Warn, "Failed to create device context."); this.AddFlag(handle, TaskbarButtonsWindowFlags.Error); return false; } var bitmapSection = default(IntPtr); if (!WindowsImaging.CreateDIBSection(hdc.cdc, bitmap, bitmap.Width, bitmap.Height, out bitmapSection)) { - //Logger.Write(this, LogLevel.Warn, "Failed to create native bitmap."); + Logger.Write(this, LogLevel.Warn, "Failed to create native bitmap."); this.AddFlag(handle, TaskbarButtonsWindowFlags.Error); return false; } @@ -431,7 +431,7 @@ protected virtual bool AddImage(IntPtr handle, IntPtr imageList, Bitmap bitmap, WindowsImaging.DeleteObject(bitmapSection); if (result < 0) { - //Logger.Write(this, LogLevel.Warn, "Failed to add image to ImageList."); + Logger.Write(this, LogLevel.Warn, "Failed to add image to ImageList."); this.AddFlag(handle, TaskbarButtonsWindowFlags.Error); return false; } @@ -450,13 +450,13 @@ protected virtual bool DestroyImages(IntPtr handle) var result = WindowsImageList.ImageList_Destroy(imageList); if (!result) { - //Logger.Write(this, LogLevel.Warn, "Failed to destroy image list: {0}", Enum.GetName(typeof(WindowsTaskbarList.HResult), result)); + Logger.Write(this, LogLevel.Warn, "Failed to destroy image list: {0}", Enum.GetName(typeof(WindowsTaskbarList.HResult), result)); this.AddFlag(handle, TaskbarButtonsWindowFlags.Error); return false; } else { - //Logger.Write(this, LogLevel.Debug, "Taskbar button image list destroyed."); + Logger.Write(this, LogLevel.Debug, "Taskbar button image list destroyed."); this.RemoveFlag(handle, TaskbarButtonsWindowFlags.ImagesCreated); return true; } @@ -465,7 +465,7 @@ protected virtual bool DestroyImages(IntPtr handle) protected virtual Bitmap GetImage(int index, int width, int height) { var name = string.Format("FoxTunes.Core.Windows.Images.{0}.png", this.GetImageName(index)); - //Logger.Write(this, LogLevel.Debug, "Creating image: {0}", name); + Logger.Write(this, LogLevel.Debug, "Creating image: {0}", name); using (var stream = typeof(TaskbarButtonsBehaviour).Assembly.GetManifestResourceStream(name)) { return this.GetImage(stream, width, height); @@ -507,11 +507,11 @@ protected virtual string GetImageName(int index) protected virtual async Task CreateButtons(IntPtr handle) { - //Logger.Write(this, LogLevel.Debug, "Creating taskbar buttons."); + Logger.Write(this, LogLevel.Debug, "Creating taskbar buttons."); var source = HwndSource.FromHwnd(handle); if (source == null) { - //Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); + Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); return false; } var buttons = this.Buttons.ToArray(); @@ -525,13 +525,13 @@ await source.Invoke( ).ConfigureAwait(false); if (result != WindowsTaskbarList.HResult.Ok) { - //Logger.Write(this, LogLevel.Warn, "Failed to create taskbar buttons: {0}", Enum.GetName(typeof(WindowsTaskbarList.HResult), result)); + Logger.Write(this, LogLevel.Warn, "Failed to create taskbar buttons: {0}", Enum.GetName(typeof(WindowsTaskbarList.HResult), result)); this.AddFlag(handle, TaskbarButtonsWindowFlags.Error); return false; } else { - //Logger.Write(this, LogLevel.Debug, "Taskbar buttons created."); + Logger.Write(this, LogLevel.Debug, "Taskbar buttons created."); this.AddFlag(handle, TaskbarButtonsWindowFlags.ButtonsCreated); return true; } @@ -550,7 +550,7 @@ protected virtual async Task UpdateButtons(IntPtr handle) var source = HwndSource.FromHwnd(handle); if (source == null) { - //Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); + Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); return false; } var buttons = this.Buttons.ToArray(); @@ -564,7 +564,7 @@ await source.Invoke( ).ConfigureAwait(false); if (result != WindowsTaskbarList.HResult.Ok) { - //Logger.Write(this, LogLevel.Warn, "Failed to update taskbar buttons: {0}", Enum.GetName(typeof(WindowsTaskbarList.HResult), result)); + Logger.Write(this, LogLevel.Warn, "Failed to update taskbar buttons: {0}", Enum.GetName(typeof(WindowsTaskbarList.HResult), result)); this.AddFlag(handle, TaskbarButtonsWindowFlags.Error); return false; } @@ -670,14 +670,14 @@ protected virtual void OnButtonPressed(int button) protected virtual async Task Previous() { - //Logger.Write(this, LogLevel.Debug, "Previous button was clicked."); + Logger.Write(this, LogLevel.Debug, "Previous button was clicked."); await this.PlaylistManager.Previous().ConfigureAwait(false); var task = this.UpdateButtons(); } protected virtual async Task PlayPause() { - //Logger.Write(this, LogLevel.Debug, "Play/pause button was clicked."); + Logger.Write(this, LogLevel.Debug, "Play/pause button was clicked."); var currentStream = this.PlaybackManager.CurrentStream; if (currentStream == null) { @@ -699,7 +699,7 @@ protected virtual async Task PlayPause() protected virtual async Task Next() { - //Logger.Write(this, LogLevel.Debug, "Next button was clicked."); + Logger.Write(this, LogLevel.Debug, "Next button was clicked."); await this.PlaylistManager.Next().ConfigureAwait(false); var task = this.UpdateButtons(); } @@ -740,7 +740,7 @@ protected virtual void OnDisposing() ~TaskbarButtonsBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core.Windows/Behaviours/TaskbarProgressBehaviour.cs b/FoxTunes.Core.Windows/Behaviours/TaskbarProgressBehaviour.cs index 6e6459679..e79962af4 100644 --- a/FoxTunes.Core.Windows/Behaviours/TaskbarProgressBehaviour.cs +++ b/FoxTunes.Core.Windows/Behaviours/TaskbarProgressBehaviour.cs @@ -106,7 +106,7 @@ protected virtual void OnWindowCreated(object sender, UserInterfaceWindowEventAr //Only create taskbar progress for main windows. return; } - //Logger.Write(this, LogLevel.Debug, "Window created: {0}", e.Window.Handle); + Logger.Write(this, LogLevel.Debug, "Window created: {0}", e.Window.Handle); this.Windows.TryAdd(e.Window.Handle, TaskbarProgressWindowFlags.None); } @@ -117,13 +117,13 @@ protected virtual void OnWindowDestroyed(object sender, UserInterfaceWindowEvent //Only create taskbar progress for main windows. return; } - //Logger.Write(this, LogLevel.Debug, "Window destroyed: {0}", e.Window.Handle); + Logger.Write(this, LogLevel.Debug, "Window destroyed: {0}", e.Window.Handle); this.AddFlag(e.Window.Handle, TaskbarProgressWindowFlags.Destroyed); } protected virtual void OnShuttingDown(object sender, EventArgs e) { - //Logger.Write(this, LogLevel.Debug, "Shutdown signal recieved."); + Logger.Write(this, LogLevel.Debug, "Shutdown signal recieved."); this.Windows.Clear(); } @@ -138,7 +138,7 @@ public void Enable() this.Timer.Elapsed += this.OnElapsed; this.Timer.AutoReset = false; this.Timer.Start(); - //Logger.Write(this, LogLevel.Debug, "Updater enabled."); + Logger.Write(this, LogLevel.Debug, "Updater enabled."); } } } @@ -153,7 +153,7 @@ public void Disable() this.Timer.Elapsed -= this.OnElapsed; this.Timer.Dispose(); this.Timer = null; - //Logger.Write(this, LogLevel.Debug, "Updater disabled."); + Logger.Write(this, LogLevel.Debug, "Updater disabled."); } } //Perform any cleanup. @@ -248,17 +248,17 @@ protected virtual void OnTaskBarCreated(IntPtr handle) //Handing an event for an unknown window? return; } - //Logger.Write(this, LogLevel.Debug, "Taskbar was created: {0}", handle); + Logger.Write(this, LogLevel.Debug, "Taskbar was created: {0}", handle); this.Windows[handle] = TaskbarProgressWindowFlags.Registered; } protected virtual void AddHook(IntPtr handle) { - //Logger.Write(this, LogLevel.Debug, "Adding Windows event handler."); + Logger.Write(this, LogLevel.Debug, "Adding Windows event handler."); var source = HwndSource.FromHwnd(handle); if (source == null) { - //Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); + Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); this.AddFlag(handle, TaskbarProgressWindowFlags.Error); return; } @@ -268,11 +268,11 @@ protected virtual void AddHook(IntPtr handle) protected virtual void RemoveHook(IntPtr handle) { - //Logger.Write(this, LogLevel.Debug, "Removing Windows event handler."); + Logger.Write(this, LogLevel.Debug, "Removing Windows event handler."); var source = HwndSource.FromHwnd(handle); if (source == null) { - //Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); + Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); this.AddFlag(handle, TaskbarProgressWindowFlags.Error); return; } @@ -307,7 +307,7 @@ protected virtual async Task UpdateTaskProgress(IntPtr handle) var source = HwndSource.FromHwnd(handle); if (source == null) { - //Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); + Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); return false; } var result = default(WindowsTaskbarList.HResult); @@ -333,7 +333,7 @@ await source.Invoke( ).ConfigureAwait(false); if (result != WindowsTaskbarList.HResult.Ok) { - //Logger.Write(this, LogLevel.Warn, "Failed to update taskbar progress: {0}", Enum.GetName(typeof(WindowsTaskbarList.HResult), result)); + Logger.Write(this, LogLevel.Warn, "Failed to update taskbar progress: {0}", Enum.GetName(typeof(WindowsTaskbarList.HResult), result)); this.AddFlag(handle, TaskbarProgressWindowFlags.Error); return false; } @@ -354,7 +354,7 @@ protected virtual async Task UpdatePlaybackProgress(IntPtr handle) var source = HwndSource.FromHwnd(handle); if (source == null) { - //Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); + Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); return false; } var result = default(WindowsTaskbarList.HResult); @@ -384,7 +384,7 @@ await source.Invoke( ).ConfigureAwait(false); if (result != WindowsTaskbarList.HResult.Ok) { - //Logger.Write(this, LogLevel.Warn, "Failed to update taskbar progress: {0}", Enum.GetName(typeof(WindowsTaskbarList.HResult), result)); + Logger.Write(this, LogLevel.Warn, "Failed to update taskbar progress: {0}", Enum.GetName(typeof(WindowsTaskbarList.HResult), result)); this.AddFlag(handle, TaskbarProgressWindowFlags.Error); return false; } @@ -400,7 +400,7 @@ protected virtual async Task ClearProgress(IntPtr handle) var source = HwndSource.FromHwnd(handle); if (source == null) { - //Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); + Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); return false; } var result = default(WindowsTaskbarList.HResult); @@ -412,7 +412,7 @@ await source.Invoke( ).ConfigureAwait(false); if (result != WindowsTaskbarList.HResult.Ok) { - //Logger.Write(this, LogLevel.Warn, "Failed to update taskbar progress: {0}", Enum.GetName(typeof(WindowsTaskbarList.HResult), result)); + Logger.Write(this, LogLevel.Warn, "Failed to update taskbar progress: {0}", Enum.GetName(typeof(WindowsTaskbarList.HResult), result)); this.AddFlag(handle, TaskbarProgressWindowFlags.Error); return false; } @@ -456,7 +456,7 @@ protected virtual void OnDisposing() ~TaskbarProgressBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core.Windows/Behaviours/TaskbarThumbnailBehaviour.cs b/FoxTunes.Core.Windows/Behaviours/TaskbarThumbnailBehaviour.cs index ae08d491a..bdc9d09d0 100644 --- a/FoxTunes.Core.Windows/Behaviours/TaskbarThumbnailBehaviour.cs +++ b/FoxTunes.Core.Windows/Behaviours/TaskbarThumbnailBehaviour.cs @@ -141,7 +141,7 @@ protected virtual void OnWindowCreated(object sender, UserInterfaceWindowEventAr //Only create taskbar thumbnail for main windows. return; } - //Logger.Write(this, LogLevel.Debug, "Window created: {0}", e.Window.Handle); + Logger.Write(this, LogLevel.Debug, "Window created: {0}", e.Window.Handle); this.Windows.TryAdd(e.Window.Handle, TaskbarThumbnailWindowFlags.None); } @@ -152,13 +152,13 @@ protected virtual void OnWindowDestroyed(object sender, UserInterfaceWindowEvent //Only create taskbar thumbnail for main windows. return; } - //Logger.Write(this, LogLevel.Debug, "Window destroyed: {0}", e.Window.Handle); + Logger.Write(this, LogLevel.Debug, "Window destroyed: {0}", e.Window.Handle); this.AddFlag(e.Window.Handle, TaskbarThumbnailWindowFlags.Destroyed); } protected virtual void OnShuttingDown(object sender, EventArgs e) { - //Logger.Write(this, LogLevel.Debug, "Shutdown signal recieved."); + Logger.Write(this, LogLevel.Debug, "Shutdown signal recieved."); this.Windows.Clear(); } @@ -173,7 +173,7 @@ public void Enable() this.Timer.Elapsed += this.OnElapsed; this.Timer.AutoReset = false; this.Timer.Start(); - //Logger.Write(this, LogLevel.Debug, "Updater enabled."); + Logger.Write(this, LogLevel.Debug, "Updater enabled."); } } } @@ -188,7 +188,7 @@ public void Disable() this.Timer.Elapsed -= this.OnElapsed; this.Timer.Dispose(); this.Timer = null; - //Logger.Write(this, LogLevel.Debug, "Updater disabled."); + Logger.Write(this, LogLevel.Debug, "Updater disabled."); } } //Perform any cleanup. @@ -293,17 +293,17 @@ protected virtual void OnTaskBarCreated(IntPtr handle) //Handing an event for an unknown window? return; } - //Logger.Write(this, LogLevel.Debug, "Taskbar was created: {0}", handle); + Logger.Write(this, LogLevel.Debug, "Taskbar was created: {0}", handle); this.Windows[handle] = TaskbarThumbnailWindowFlags.Registered; } protected virtual void AddHook(IntPtr handle) { - //Logger.Write(this, LogLevel.Debug, "Adding Windows event handler."); + Logger.Write(this, LogLevel.Debug, "Adding Windows event handler."); var source = HwndSource.FromHwnd(handle); if (source == null) { - //Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); + Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); this.AddFlag(handle, TaskbarThumbnailWindowFlags.Error); return; } @@ -313,11 +313,11 @@ protected virtual void AddHook(IntPtr handle) protected virtual void RemoveHook(IntPtr handle) { - //Logger.Write(this, LogLevel.Debug, "Removing Windows event handler."); + Logger.Write(this, LogLevel.Debug, "Removing Windows event handler."); var source = HwndSource.FromHwnd(handle); if (source == null) { - //Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); + Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); this.AddFlag(handle, TaskbarThumbnailWindowFlags.Error); return; } @@ -330,13 +330,13 @@ protected virtual async Task UpdateThumbnail(IntPtr handle) var source = HwndSource.FromHwnd(handle); if (source == null) { - //Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); + Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); return false; } var thumbnail = await this.GetThumbnail().ConfigureAwait(false); if (!this.HasThumbnail(handle, thumbnail.Name)) { - //Logger.Write(this, LogLevel.Debug, "Iconic thumbnail: {0}", thumbnail.Name); + Logger.Write(this, LogLevel.Debug, "Iconic thumbnail: {0}", thumbnail.Name); this.SetThumbnail(handle, thumbnail); var result = default(WindowsIconicThumbnail.HResult); await source.Invoke( @@ -344,7 +344,7 @@ await source.Invoke( ).ConfigureAwait(false); if (result != WindowsIconicThumbnail.HResult.Ok) { - //Logger.Write(this, LogLevel.Warn, "Failed to invalidate iconic thumbnail: {0}", Enum.GetName(typeof(WindowsIconicThumbnail.HResult), result)); + Logger.Write(this, LogLevel.Warn, "Failed to invalidate iconic thumbnail: {0}", Enum.GetName(typeof(WindowsIconicThumbnail.HResult), result)); this.AddFlag(handle, TaskbarThumbnailWindowFlags.Error); return false; } @@ -357,13 +357,13 @@ protected virtual async Task SetWindowAttributes(IntPtr handle, bool enabl var source = HwndSource.FromHwnd(handle); if (source == null) { - //Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); + Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); return false; } int forceIconicRepresentation = enable ? 1 : 0; int hasIconicBitmap = enable ? 1 : 0; var result = default(WindowsIconicThumbnail.HResult); - //Logger.Write(this, LogLevel.Debug, "Setting window attribute {0}: DWM_FORCE_ICONIC_REPRESENTATION = {1}", handle, enable ? bool.TrueString : bool.FalseString); + Logger.Write(this, LogLevel.Debug, "Setting window attribute {0}: DWM_FORCE_ICONIC_REPRESENTATION = {1}", handle, enable ? bool.TrueString : bool.FalseString); await source.Invoke( () => result = WindowsIconicThumbnail.DwmSetWindowAttribute( handle, @@ -374,11 +374,11 @@ await source.Invoke( ).ConfigureAwait(false); if (result != WindowsIconicThumbnail.HResult.Ok) { - //Logger.Write(this, LogLevel.Warn, "Failed to set window attribute DWM_FORCE_ICONIC_REPRESENTATION: {0}", Enum.GetName(typeof(WindowsIconicThumbnail.HResult), result)); + Logger.Write(this, LogLevel.Warn, "Failed to set window attribute DWM_FORCE_ICONIC_REPRESENTATION: {0}", Enum.GetName(typeof(WindowsIconicThumbnail.HResult), result)); this.AddFlag(handle, TaskbarThumbnailWindowFlags.Error); return false; } - //Logger.Write(this, LogLevel.Debug, "Setting window attribute {0}: DWM_HAS_ICONIC_BITMAP = {1}", handle, enable ? bool.TrueString : bool.FalseString); + Logger.Write(this, LogLevel.Debug, "Setting window attribute {0}: DWM_HAS_ICONIC_BITMAP = {1}", handle, enable ? bool.TrueString : bool.FalseString); await source.Invoke( () => result = WindowsIconicThumbnail.DwmSetWindowAttribute( handle, @@ -389,7 +389,7 @@ await source.Invoke( ).ConfigureAwait(false); if (result != WindowsIconicThumbnail.HResult.Ok) { - //Logger.Write(this, LogLevel.Warn, "Failed to set window attribute DWM_HAS_ICONIC_BITMAP: {0}", Enum.GetName(typeof(WindowsIconicThumbnail.HResult), result)); + Logger.Write(this, LogLevel.Warn, "Failed to set window attribute DWM_HAS_ICONIC_BITMAP: {0}", Enum.GetName(typeof(WindowsIconicThumbnail.HResult), result)); this.AddFlag(handle, TaskbarThumbnailWindowFlags.Error); return false; } @@ -423,21 +423,21 @@ protected virtual async Task OnSendIconicThumbnail(IntPtr handle, Bitmap b var source = HwndSource.FromHwnd(handle); if (source == null) { - //Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); + Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); return false; } using (var hdc = WindowsImaging.ScopedDC.Compatible(handle)) { if (!hdc.IsValid) { - //Logger.Write(this, LogLevel.Warn, "Failed to create device context."); + Logger.Write(this, LogLevel.Warn, "Failed to create device context."); this.AddFlag(handle, TaskbarThumbnailWindowFlags.Error); return false; } var bitmapSection = default(IntPtr); if (!WindowsImaging.CreateDIBSection(hdc.cdc, bitmap, bitmap.Width, -bitmap.Height/* This isn't a mistake, DIB is top down. */, out bitmapSection)) { - //Logger.Write(this, LogLevel.Warn, "Failed to create native bitmap."); + Logger.Write(this, LogLevel.Warn, "Failed to create native bitmap."); this.AddFlag(handle, TaskbarThumbnailWindowFlags.Error); return false; } @@ -448,7 +448,7 @@ await source.Invoke( WindowsImaging.DeleteObject(bitmapSection); if (result != WindowsIconicThumbnail.HResult.Ok) { - //Logger.Write(this, LogLevel.Warn, "Failed to set iconic thumbnail: {0}", Enum.GetName(typeof(WindowsIconicThumbnail.HResult), result)); + Logger.Write(this, LogLevel.Warn, "Failed to set iconic thumbnail: {0}", Enum.GetName(typeof(WindowsIconicThumbnail.HResult), result)); this.AddFlag(handle, TaskbarThumbnailWindowFlags.Error); return false; } @@ -484,7 +484,7 @@ protected virtual async Task OnSendIconicLivePreviewBitmap(IntPtr handle) var source = HwndSource.FromHwnd(handle); if (source == null) { - //Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); + Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); return false; } var bitmap = default(Bitmap); @@ -499,21 +499,21 @@ protected virtual async Task OnSendIconicLivePreviewBitmap(IntPtr handle, var source = HwndSource.FromHwnd(handle); if (source == null) { - //Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); + Logger.Write(this, LogLevel.Warn, "No such window for handle: {0}", handle); return false; } using (var hdc = WindowsImaging.ScopedDC.Compatible(handle)) { if (!hdc.IsValid) { - //Logger.Write(this, LogLevel.Warn, "Failed to create device context."); + Logger.Write(this, LogLevel.Warn, "Failed to create device context."); this.AddFlag(handle, TaskbarThumbnailWindowFlags.Error); return false; } var bitmapSection = default(IntPtr); if (!WindowsImaging.CreateDIBSection(hdc.cdc, bitmap, bitmap.Width, -bitmap.Height/* This isn't a mistake, DIB is top down. */, out bitmapSection)) { - //Logger.Write(this, LogLevel.Warn, "Failed to create native bitmap."); + Logger.Write(this, LogLevel.Warn, "Failed to create native bitmap."); this.AddFlag(handle, TaskbarThumbnailWindowFlags.Error); return false; } @@ -525,7 +525,7 @@ await source.Invoke( WindowsImaging.DeleteObject(bitmapSection); if (result != WindowsIconicThumbnail.HResult.Ok) { - //Logger.Write(this, LogLevel.Warn, "Failed to set iconic live preview: {0}", Enum.GetName(typeof(WindowsIconicThumbnail.HResult), result)); + Logger.Write(this, LogLevel.Warn, "Failed to set iconic live preview: {0}", Enum.GetName(typeof(WindowsIconicThumbnail.HResult), result)); this.AddFlag(handle, TaskbarThumbnailWindowFlags.Error); return false; } @@ -579,7 +579,7 @@ protected virtual void OnDisposing() ~TaskbarThumbnailBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); @@ -628,7 +628,7 @@ public Bitmap Scale(int width, int height) var size = new Size(width, height); return this.ScaledBitmaps.GetOrAdd(size, () => { - //Logger.Write(typeof(TaskbarThumbnail), LogLevel.Debug, "Resizing image {0}: {1}x{2}", this.Name, width, height); + Logger.Write(typeof(TaskbarThumbnail), LogLevel.Debug, "Resizing image {0}: {1}x{2}", this.Name, width, height); return WindowsImaging.Resize(this.Bitmap, width, height, true); }); } @@ -671,7 +671,7 @@ protected virtual void OnDisposing() ~TaskbarThumbnail() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); @@ -686,7 +686,7 @@ public static TaskbarThumbnail GetOrAdd(string fileName) { return Store.GetOrAdd(fileName, () => { - //Logger.Write(typeof(TaskbarThumbnail), LogLevel.Debug, "Creating image: {0}", fileName); + Logger.Write(typeof(TaskbarThumbnail), LogLevel.Debug, "Creating image: {0}", fileName); var stream = File.OpenRead(fileName); return new TaskbarThumbnail(fileName, (Bitmap)Bitmap.FromStream(stream)); }); @@ -696,7 +696,7 @@ public static TaskbarThumbnail GetOrAdd(string fileName) private static TaskbarThumbnail GetPlaceholder() { - //Logger.Write(typeof(TaskbarThumbnail), LogLevel.Debug, "Creating image: {0}", PLACEHOLDER); + Logger.Write(typeof(TaskbarThumbnail), LogLevel.Debug, "Creating image: {0}", PLACEHOLDER); var stream = typeof(TaskbarThumbnailBehaviour).Assembly.GetManifestResourceStream(PLACEHOLDER); return new TaskbarThumbnail(PLACEHOLDER, (Bitmap)Bitmap.FromStream(stream)); } diff --git a/FoxTunes.Core.Windows/Configuration/FileAssociations.cs b/FoxTunes.Core.Windows/Configuration/FileAssociations.cs index 38a8dbece..b2953de16 100644 --- a/FoxTunes.Core.Windows/Configuration/FileAssociations.cs +++ b/FoxTunes.Core.Windows/Configuration/FileAssociations.cs @@ -106,7 +106,7 @@ private static void AddAssociations(IEnumerable associations) } if (success) { - //Logger.Write(typeof(FileAssociations), LogLevel.Debug, "Sending SHChangeNotify."); + Logger.Write(typeof(FileAssociations), LogLevel.Debug, "Sending SHChangeNotify."); SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_FLUSH, IntPtr.Zero, IntPtr.Zero); } } @@ -120,7 +120,7 @@ private static void RemoveAssociations(IEnumerable association } if (success) { - //Logger.Write(typeof(FileAssociations), LogLevel.Debug, "Sending SHChangeNotify."); + Logger.Write(typeof(FileAssociations), LogLevel.Debug, "Sending SHChangeNotify."); SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_FLUSH, IntPtr.Zero, IntPtr.Zero); } } @@ -135,7 +135,7 @@ private static void AddShortcuts(IFileAssociation association) { global::System.IO.File.Delete(fileName); } - //Logger.Write(typeof(FileAssociations), LogLevel.Debug, "Creating \"SendTo\" link for program \"{0}\": {1}", association.ProgId, fileName); + Logger.Write(typeof(FileAssociations), LogLevel.Debug, "Creating \"SendTo\" link for program \"{0}\": {1}", association.ProgId, fileName); Shell.CreateShortcut(fileName, association.ExecutableFilePath); } @@ -149,7 +149,7 @@ private static void RemoveShortcuts(IFileAssociation association) { return; } - //Logger.Write(typeof(FileAssociations), LogLevel.Debug, "Removing \"SendTo\" link for program \"{0}\".", association.ProgId); + Logger.Write(typeof(FileAssociations), LogLevel.Debug, "Removing \"SendTo\" link for program \"{0}\".", association.ProgId); global::System.IO.File.Delete(fileName); } @@ -157,28 +157,28 @@ private static bool AddProgram(IFileAssociation association) { var path = string.Format(@"Software\Classes\{0}\shell\open\command", association.ProgId); var command = GetOpenString(association.ExecutableFilePath); - //Logger.Write(typeof(FileAssociations), LogLevel.Debug, "Creating shell command for program \"{0}\": {1}", association.ProgId, command); + Logger.Write(typeof(FileAssociations), LogLevel.Debug, "Creating shell command for program \"{0}\": {1}", association.ProgId, command); return SetKeyValue(path, command); } private static bool RemoveProgram(IFileAssociation association) { var path = @"Software\Classes\" + association.ProgId; - //Logger.Write(typeof(FileAssociations), LogLevel.Debug, "Removing shell command for program \"{0}\".", association.ProgId); + Logger.Write(typeof(FileAssociations), LogLevel.Debug, "Removing shell command for program \"{0}\".", association.ProgId); return DeleteKey(path); } private static bool AddAssociation(IFileAssociation association) { var path = @"Software\Classes\" + association.Extension; - //Logger.Write(typeof(FileAssociations), LogLevel.Debug, "Creating file association for program \"{0}\": {1}", association.ProgId, association.Extension); + Logger.Write(typeof(FileAssociations), LogLevel.Debug, "Creating file association for program \"{0}\": {1}", association.ProgId, association.Extension); return SetKeyValue(path, association.ProgId); } private static bool RemoveAssociation(IFileAssociation association) { var path = @"Software\Classes\" + association.Extension; - //Logger.Write(typeof(FileAssociations), LogLevel.Debug, "Removing file association for program \"{0}\": {1}", association.ProgId, association.Extension); + Logger.Write(typeof(FileAssociations), LogLevel.Debug, "Removing file association for program \"{0}\": {1}", association.ProgId, association.Extension); return DeleteKey(path); } diff --git a/FoxTunes.Core.Windows/Managers/WindowsInputManager.cs b/FoxTunes.Core.Windows/Managers/WindowsInputManager.cs index d7d84cc53..6f5838e43 100644 --- a/FoxTunes.Core.Windows/Managers/WindowsInputManager.cs +++ b/FoxTunes.Core.Windows/Managers/WindowsInputManager.cs @@ -108,11 +108,11 @@ protected virtual void Enable() this.Hook = SetHook(this.Callback); if (this.Hook != IntPtr.Zero) { - //Logger.Write(this, LogLevel.Debug, "Added keyboard hook, global keyboard shortcuts are enabled."); + Logger.Write(this, LogLevel.Debug, "Added keyboard hook, global keyboard shortcuts are enabled."); } else { - //Logger.Write(this, LogLevel.Warn, "Failed to add keyboard hook, global keyboard shortcuts are disabled."); + Logger.Write(this, LogLevel.Warn, "Failed to add keyboard hook, global keyboard shortcuts are disabled."); } } } @@ -123,7 +123,7 @@ protected virtual void Disable() { UnhookWindowsHookEx(this.Hook); this.Hook = IntPtr.Zero; - //Logger.Write(this, LogLevel.Debug, "Removed keyboard hook, global keyboard shortcuts are disabled."); + Logger.Write(this, LogLevel.Debug, "Removed keyboard hook, global keyboard shortcuts are disabled."); } } diff --git a/FoxTunes.Core.Windows/Utilities/WindowMessages.cs b/FoxTunes.Core.Windows/Utilities/WindowMessages.cs index e6a906081..c308f0488 100644 --- a/FoxTunes.Core.Windows/Utilities/WindowMessages.cs +++ b/FoxTunes.Core.Windows/Utilities/WindowMessages.cs @@ -5,6 +5,14 @@ namespace FoxTunes { public static class WindowMessages { + private static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + public static readonly int WM_TASKBARCREATED; static WindowMessages() @@ -15,7 +23,7 @@ static WindowMessages() } catch { - //Logger.Write(typeof(TaskbarButtonsBehaviour), LogLevel.Warn, "Failed to register window message: TaskbarCreated"); + Logger.Write(typeof(TaskbarButtonsBehaviour), LogLevel.Warn, "Failed to register window message: TaskbarCreated"); } } diff --git a/FoxTunes.Core.Windows/Utilities/WindowsImaging.cs b/FoxTunes.Core.Windows/Utilities/WindowsImaging.cs index 4d5f364b5..fdcb15701 100644 --- a/FoxTunes.Core.Windows/Utilities/WindowsImaging.cs +++ b/FoxTunes.Core.Windows/Utilities/WindowsImaging.cs @@ -128,7 +128,15 @@ public struct BITMAPINFO public class ScopedDC : IDisposable { - public ScopedDC(IntPtr hwnd, IntPtr dc, IntPtr cdc) + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public ScopedDC(IntPtr hwnd, IntPtr dc, IntPtr cdc) { this.hwnd = hwnd; this.dc = dc; @@ -181,7 +189,7 @@ protected virtual void OnDisposing() ~ScopedDC() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core.Windows/Utilities/WindowsMessageSink.cs b/FoxTunes.Core.Windows/Utilities/WindowsMessageSink.cs index 9c214cb54..adc6fe657 100644 --- a/FoxTunes.Core.Windows/Utilities/WindowsMessageSink.cs +++ b/FoxTunes.Core.Windows/Utilities/WindowsMessageSink.cs @@ -18,7 +18,7 @@ static WindowsMessageSink() } catch { - //Logger.Write(typeof(WindowsMessageSink), LogLevel.Warn, "Failed to register window message: TaskbarCreated"); + Logger.Write(typeof(WindowsMessageSink), LogLevel.Warn, "Failed to register window message: TaskbarCreated"); } } diff --git a/FoxTunes.Core.Windows/Utilities/WindowsNotifyIcon.cs b/FoxTunes.Core.Windows/Utilities/WindowsNotifyIcon.cs index c1907bb74..02c6fccb0 100644 --- a/FoxTunes.Core.Windows/Utilities/WindowsNotifyIcon.cs +++ b/FoxTunes.Core.Windows/Utilities/WindowsNotifyIcon.cs @@ -42,7 +42,7 @@ protected virtual void OnTaskBarCreated(object sender, EventArgs e) { return; } - //Logger.Write(this, LogLevel.Debug, "explorer.exe was restarted, re-creating notify icon."); + Logger.Write(this, LogLevel.Debug, "explorer.exe was restarted, re-creating notify icon."); this.IsVisible = false; this.Show(); } @@ -62,7 +62,7 @@ public override void Show() var data = NotifyIconData.Create(ID, this.MessageSink.Handle, this.Icon); if (ShellNotifyIcon(NotifyCommand.Add, ref data)) { - //Logger.Write(this, LogLevel.Debug, "Successfully created notify icon."); + Logger.Write(this, LogLevel.Debug, "Successfully created notify icon."); this.IsVisible = true; return; } @@ -71,7 +71,7 @@ public override void Show() ID++; } } - //Logger.Write(this, LogLevel.Error, "Failed to create notify icon, Shell_NotifyIcon reports failure."); + Logger.Write(this, LogLevel.Error, "Failed to create notify icon, Shell_NotifyIcon reports failure."); } } @@ -86,12 +86,12 @@ public override bool Update() var data = NotifyIconData.Create(ID, this.MessageSink.Handle, this.Icon); if (ShellNotifyIcon(NotifyCommand.Modify, ref data)) { - //Logger.Write(this, LogLevel.Debug, "Successfully updated notify icon."); + Logger.Write(this, LogLevel.Debug, "Successfully updated notify icon."); return true; } else { - //Logger.Write(this, LogLevel.Error, "Failed to update notify icon, Shell_NotifyIcon reports failure."); + Logger.Write(this, LogLevel.Error, "Failed to update notify icon, Shell_NotifyIcon reports failure."); return false; } } @@ -108,11 +108,11 @@ public override void Hide() var data = NotifyIconData.Create(ID, this.MessageSink.Handle, this.Icon); if (ShellNotifyIcon(NotifyCommand.Delete, ref data)) { - //Logger.Write(this, LogLevel.Debug, "Successfully destroyed notify icon."); + Logger.Write(this, LogLevel.Debug, "Successfully destroyed notify icon."); } else { - //Logger.Write(this, LogLevel.Error, "Failed to destroy notify icon, Shell_NotifyIcon reports failure."); + Logger.Write(this, LogLevel.Error, "Failed to destroy notify icon, Shell_NotifyIcon reports failure."); } this.IsVisible = false; } diff --git a/FoxTunes.Core/ArtworkProvider.cs b/FoxTunes.Core/ArtworkProvider.cs index 4c44f73ce..f89608750 100644 --- a/FoxTunes.Core/ArtworkProvider.cs +++ b/FoxTunes.Core/ArtworkProvider.cs @@ -196,9 +196,9 @@ public string Find(string path, ArtworkType type) } } } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Error locating artwork of type {0} in {1}: {2}", Enum.GetName(typeof(ArtworkType), type), path, e.Message); + Logger.Write(this, LogLevel.Warn, "Error locating artwork of type {0} in {1}: {2}", Enum.GetName(typeof(ArtworkType), type), path, e.Message); } return null; }); diff --git a/FoxTunes.Core/BaseComponent.cs b/FoxTunes.Core/BaseComponent.cs index 4f9887d95..d5693919e 100644 --- a/FoxTunes.Core/BaseComponent.cs +++ b/FoxTunes.Core/BaseComponent.cs @@ -7,7 +7,15 @@ namespace FoxTunes { public abstract class BaseComponent : IBaseComponent, IInitializable, IObservable { - public bool IsInitialized { get; private set; } + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public bool IsInitialized { get; private set; } public virtual void InitializeComponent(ICore core) { diff --git a/FoxTunes.Core/BaseManager.cs b/FoxTunes.Core/BaseManager.cs index d71400271..4c0965a08 100644 --- a/FoxTunes.Core/BaseManager.cs +++ b/FoxTunes.Core/BaseManager.cs @@ -30,7 +30,7 @@ protected virtual void OnDisposing() ~BaseManager() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/Behaviours/DynamicPlaylistBehaviour.cs b/FoxTunes.Core/Behaviours/DynamicPlaylistBehaviour.cs index 7bf8dc790..595366148 100644 --- a/FoxTunes.Core/Behaviours/DynamicPlaylistBehaviour.cs +++ b/FoxTunes.Core/Behaviours/DynamicPlaylistBehaviour.cs @@ -108,7 +108,7 @@ protected virtual async Task Refresh(Playlist playlist, string expression, bool var libraryHierarchyNodes = this.LibraryHierarchyBrowser.GetNodes(libraryHierarchy, expression); if (!libraryHierarchyNodes.Any()) { - //Logger.Write(this, LogLevel.Debug, "Library search returned no results: {0}", expression); + Logger.Write(this, LogLevel.Debug, "Library search returned no results: {0}", expression); using (var task = new ClearPlaylistTask(playlist)) { task.InitializeComponent(this.Core); diff --git a/FoxTunes.Core/Behaviours/EnqueueNextItemBehaviour.cs b/FoxTunes.Core/Behaviours/EnqueueNextItemBehaviour.cs index 0317eacac..e38c9f48d 100644 --- a/FoxTunes.Core/Behaviours/EnqueueNextItemBehaviour.cs +++ b/FoxTunes.Core/Behaviours/EnqueueNextItemBehaviour.cs @@ -68,7 +68,7 @@ private async Task EnqueueItems() { if (!this.Output.IsStarted) { - //Logger.Write(this, LogLevel.Debug, "Output was stopped, cancelling."); + Logger.Write(this, LogLevel.Debug, "Output was stopped, cancelling."); break; } playlistItem = this.PlaylistBrowser.GetNextItem(playlistItem, this.Wrap.Value); @@ -86,7 +86,7 @@ private async Task EnqueueItems() #endif continue; } - //Logger.Write(this, LogLevel.Debug, "Preemptively buffering playlist item: {0} => {1}", playlistItem.Id, playlistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Preemptively buffering playlist item: {0} => {1}", playlistItem.Id, playlistItem.FileName); await this.PlaybackManager.Load(playlistItem, false).ConfigureAwait(false); } } @@ -128,7 +128,7 @@ protected virtual void OnDisposing() ~EnqueueNextItemsBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/Behaviours/ExternalPlaylistBehaviour.cs b/FoxTunes.Core/Behaviours/ExternalPlaylistBehaviour.cs index eaaa93222..c5c13b2e9 100644 --- a/FoxTunes.Core/Behaviours/ExternalPlaylistBehaviour.cs +++ b/FoxTunes.Core/Behaviours/ExternalPlaylistBehaviour.cs @@ -259,7 +259,7 @@ protected override async Task AddPlaylistItems(IEnumerable paths, Cancel var set = this.Database.Set(transaction); foreach (var playlistItem in playlistItems) { - //Logger.Write(this, LogLevel.Debug, "Adding file to playlist: {0}", playlistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Adding file to playlist: {0}", playlistItem.FileName); playlistItem.Playlist_Id = this.Playlist.Id; playlistItem.Sequence = this.Sequence; playlistItem.Status = PlaylistItemStatus.Import; diff --git a/FoxTunes.Core/Behaviours/LibraryHierarchyNodeRefreshBehaviour.cs b/FoxTunes.Core/Behaviours/LibraryHierarchyNodeRefreshBehaviour.cs index ed40baeb7..d94c51e47 100644 --- a/FoxTunes.Core/Behaviours/LibraryHierarchyNodeRefreshBehaviour.cs +++ b/FoxTunes.Core/Behaviours/LibraryHierarchyNodeRefreshBehaviour.cs @@ -79,7 +79,7 @@ protected virtual void OnDisposing() ~LibraryHierarchyNodeRefreshBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/Behaviours/MetaDataRefreshBehaviour.cs b/FoxTunes.Core/Behaviours/MetaDataRefreshBehaviour.cs index b7b84d980..21b436157 100644 --- a/FoxTunes.Core/Behaviours/MetaDataRefreshBehaviour.cs +++ b/FoxTunes.Core/Behaviours/MetaDataRefreshBehaviour.cs @@ -42,7 +42,7 @@ public void Enable() { this.SignalEmitter.Signal += this.OnSignal; this.Configuration.Saved += this.OnSaved; - //Logger.Write(this, LogLevel.Info, "Enabled."); + Logger.Write(this, LogLevel.Info, "Enabled."); } public void Disable() @@ -55,7 +55,7 @@ public void Disable() { this.Configuration.Saved -= this.OnSaved; } - //Logger.Write(this, LogLevel.Info, "Disabled."); + Logger.Write(this, LogLevel.Info, "Disabled."); } public void Monitor() @@ -126,7 +126,7 @@ protected virtual void OnSaved(object sender, EventArgs e) { return; } - //Logger.Write(this, LogLevel.Info, "Configuration was changed, updating meta data."); + Logger.Write(this, LogLevel.Info, "Configuration was changed, updating meta data."); var task = this.Refresh(); } @@ -168,7 +168,7 @@ protected virtual void OnDisposing() ~MetaDataRefreshBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/Behaviours/PlayNextItemBehaviour.cs b/FoxTunes.Core/Behaviours/PlayNextItemBehaviour.cs index 3a83b1293..7fdce5cbb 100644 --- a/FoxTunes.Core/Behaviours/PlayNextItemBehaviour.cs +++ b/FoxTunes.Core/Behaviours/PlayNextItemBehaviour.cs @@ -30,7 +30,7 @@ public override void InitializeComponent(ICore core) protected virtual void OnEnded(object sender, EventArgs e) { - //Logger.Write(this, LogLevel.Debug, "Stream was stopped likely due to reaching the end, playing next item."); + Logger.Write(this, LogLevel.Debug, "Stream was stopped likely due to reaching the end, playing next item."); this.Dispatch(() => this.PlaylistManager.Next(this.Wrap.Value)); } @@ -62,7 +62,7 @@ protected virtual void OnDisposing() ~PlayNextItemBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/Behaviours/PlaylistBehaviourBase.cs b/FoxTunes.Core/Behaviours/PlaylistBehaviourBase.cs index d7cc58cfe..54b4c59b4 100644 --- a/FoxTunes.Core/Behaviours/PlaylistBehaviourBase.cs +++ b/FoxTunes.Core/Behaviours/PlaylistBehaviourBase.cs @@ -123,7 +123,7 @@ protected virtual void OnDisposing() ~PlaylistBehaviourBase() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/Behaviours/PreemptNextItemBehaviour.cs b/FoxTunes.Core/Behaviours/PreemptNextItemBehaviour.cs index 614b14fc0..aa6a3a7b2 100644 --- a/FoxTunes.Core/Behaviours/PreemptNextItemBehaviour.cs +++ b/FoxTunes.Core/Behaviours/PreemptNextItemBehaviour.cs @@ -59,10 +59,10 @@ private async Task PreemptItems() { return; } - //Logger.Write(this, LogLevel.Debug, "Current stream is about to end, pre-empting the next stream: {0} => {1}", outputStream.Id, outputStream.FileName); + Logger.Write(this, LogLevel.Debug, "Current stream is about to end, pre-empting the next stream: {0} => {1}", outputStream.Id, outputStream.FileName); if (!await this.Output.Preempt(outputStream).ConfigureAwait(false)) { - //Logger.Write(this, LogLevel.Debug, "Pre-empt failed for stream: {0} => {1}", outputStream.Id, outputStream.FileName); + Logger.Write(this, LogLevel.Debug, "Pre-empt failed for stream: {0} => {1}", outputStream.Id, outputStream.FileName); } } @@ -94,7 +94,7 @@ protected virtual void OnDisposing() ~PreemptNextItemBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/ComponentActivator.cs b/FoxTunes.Core/ComponentActivator.cs index edd65ee59..2ebfbbf30 100644 --- a/FoxTunes.Core/ComponentActivator.cs +++ b/FoxTunes.Core/ComponentActivator.cs @@ -8,7 +8,15 @@ namespace FoxTunes { public class ComponentActivator : IComponentActivator { - private ComponentActivator() + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + private ComponentActivator() { } @@ -23,7 +31,7 @@ public T Activate(Type type) where T : IBaseComponent } if (type.GetConstructor(new Type[] { }) == null) { - //Logger.Write(typeof(ComponentActivator), LogLevel.Warn, "Failed to locate constructor for component {0}.", type.Name); + Logger.Write(typeof(ComponentActivator), LogLevel.Warn, "Failed to locate constructor for component {0}.", type.Name); return default(T); } if (FastActivator.Instance.Activate(type) is T component) @@ -32,13 +40,13 @@ public T Activate(Type type) where T : IBaseComponent } else { - //Logger.Write(typeof(ComponentActivator), LogLevel.Warn, "Component {0} is not of the expected type {1}.", type.Name, typeof(T).Name); + Logger.Write(typeof(ComponentActivator), LogLevel.Warn, "Component {0} is not of the expected type {1}.", type.Name, typeof(T).Name); return default(T); } } - catch + catch (Exception e) { - //Logger.Write(typeof(ComponentActivator), LogLevel.Warn, "Failed to activate component {0}: {1}.", type.Name, e.Message); + Logger.Write(typeof(ComponentActivator), LogLevel.Warn, "Failed to activate component {0}: {1}.", type.Name, e.Message); return default(T); } } diff --git a/FoxTunes.Core/ComponentRegistry.cs b/FoxTunes.Core/ComponentRegistry.cs index 28d40dee7..f7a90d46d 100644 --- a/FoxTunes.Core/ComponentRegistry.cs +++ b/FoxTunes.Core/ComponentRegistry.cs @@ -7,7 +7,15 @@ namespace FoxTunes { public class ComponentRegistry : IComponentRegistry { - private ComponentRegistry() + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + private ComponentRegistry() { this.Clear(); } @@ -40,7 +48,7 @@ public void AddComponent(IBaseComponent component) var componentType = component.GetType(); if (!this.ComponentsByType.TryAdd(componentType, component)) { - //Logger.Write(typeof(ComponentRegistry), LogLevel.Warn, "Cannot register component type \"{0}\", it was already registered.", componentType.FullName); + Logger.Write(typeof(ComponentRegistry), LogLevel.Warn, "Cannot register component type \"{0}\", it was already registered.", componentType.FullName); } foreach (var componentInterface in componentType.GetInterfaces()) { diff --git a/FoxTunes.Core/ComponentScanner.cs b/FoxTunes.Core/ComponentScanner.cs index a2eae6403..467fb183f 100644 --- a/FoxTunes.Core/ComponentScanner.cs +++ b/FoxTunes.Core/ComponentScanner.cs @@ -23,7 +23,15 @@ public class ComponentScanner : IComponentScanner typeof(IStandardBehaviour) }; - public static string Location + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public static string Location { get { @@ -69,12 +77,12 @@ private static IEnumerable GetTypes(string fileName) } catch (ReflectionTypeLoadException e) { - //Logger.Write(typeof(ComponentScanner), LogLevel.Trace, "Error was handled while getting exported types for assembly {0}: {1}", fileName, e.Message); + Logger.Write(typeof(ComponentScanner), LogLevel.Trace, "Error was handled while getting exported types for assembly {0}: {1}", fileName, e.Message); return e.Types; } - catch + catch (Exception e) { - //Logger.Write(typeof(ComponentScanner), LogLevel.Warn, "Failed to get exported types for assembly {0}: {1}", fileName, e.Message); + Logger.Write(typeof(ComponentScanner), LogLevel.Warn, "Failed to get exported types for assembly {0}: {1}", fileName, e.Message); return Enumerable.Empty(); } } @@ -102,7 +110,7 @@ private static IEnumerable GetAllStandardResolvedComponents() .ThenBy(ComponentSorter.Priority); if (!ComponentResolver.Instance.Enabled) { - //Logger.Write(typeof(ComponentScanner), LogLevel.Debug, "Component set is fixed, skipping config/dependency checks."); + Logger.Write(typeof(ComponentScanner), LogLevel.Debug, "Component set is fixed, skipping config/dependency checks."); return types.ToArray(); } try @@ -134,7 +142,7 @@ public IEnumerable GetComponents(Type type) .ThenBy(ComponentSorter.Priority); if (!ComponentResolver.Instance.Enabled) { - //Logger.Write(typeof(ComponentScanner), LogLevel.Debug, "Component set is fixed, skipping config/dependency checks."); + Logger.Write(typeof(ComponentScanner), LogLevel.Debug, "Component set is fixed, skipping config/dependency checks."); return types.ToArray(); } return types @@ -229,12 +237,12 @@ public static bool HasDependencies(Type type) } else if (string.Equals(id, ComponentSlots.Blocked, StringComparison.OrdinalIgnoreCase)) { - //Logger.Write(typeof(ComponentScanner), LogLevel.Debug, "Not loading component \"{0}\": Requires slot {1}", type.FullName, dependency.Slot); + Logger.Write(typeof(ComponentScanner), LogLevel.Debug, "Not loading component \"{0}\": Requires slot {1}", type.FullName, dependency.Slot); return false; } else if (!string.IsNullOrEmpty(dependency.Id) && !string.Equals(dependency.Id, id, StringComparison.OrdinalIgnoreCase)) { - //Logger.Write(typeof(ComponentScanner), LogLevel.Debug, "Not loading component \"{0}\": Requires component {1}", type.FullName, dependency.Id); + Logger.Write(typeof(ComponentScanner), LogLevel.Debug, "Not loading component \"{0}\": Requires component {1}", type.FullName, dependency.Id); return false; } } @@ -268,7 +276,7 @@ public static bool HasPlatform(Type type) var version = new Version(dependency.Major, dependency.Minor); if (Environment.OSVersion.Version < version) { - //Logger.Write(typeof(ComponentScanner), LogLevel.Debug, "Not loading component \"{0}\": Requires platform {1}.{2}.", type.FullName, dependency.Major, dependency.Minor); + Logger.Write(typeof(ComponentScanner), LogLevel.Debug, "Not loading component \"{0}\": Requires platform {1}.{2}.", type.FullName, dependency.Major, dependency.Minor); return false; } else if (dependency.Build > 0) @@ -276,7 +284,7 @@ public static bool HasPlatform(Type type) var osVersion = new OsVersion(); if (RtlGetVersion(ref osVersion) != 0 || osVersion.BuildNumber < dependency.Build) { - //Logger.Write(typeof(ComponentScanner), LogLevel.Debug, "Not loading component \"{0}\": Requires platform {1}.{2}.", type.FullName, dependency.Major, dependency.Minor); + Logger.Write(typeof(ComponentScanner), LogLevel.Debug, "Not loading component \"{0}\": Requires platform {1}.{2}.", type.FullName, dependency.Major, dependency.Minor); return false; } } @@ -286,12 +294,12 @@ public static bool HasPlatform(Type type) var is34BitProcess = !is64BitProcess; if (dependency.Architecture == ProcessorArchitecture.X86 && is64BitProcess) { - //Logger.Write(typeof(ComponentScanner), LogLevel.Debug, "Not loading component \"{0}\": Requires platform X86.", type.FullName); + Logger.Write(typeof(ComponentScanner), LogLevel.Debug, "Not loading component \"{0}\": Requires platform X86.", type.FullName); return false; } if (dependency.Architecture == ProcessorArchitecture.X64 && !is34BitProcess) { - //Logger.Write(typeof(ComponentScanner), LogLevel.Debug, "Not loading component \"{0}\": Requires platform X64.", type.FullName); + Logger.Write(typeof(ComponentScanner), LogLevel.Debug, "Not loading component \"{0}\": Requires platform X64.", type.FullName); return false; } } diff --git a/FoxTunes.Core/Configuration/CommandConfigurationElement.cs b/FoxTunes.Core/Configuration/CommandConfigurationElement.cs index e55422cb8..39cf91e89 100644 --- a/FoxTunes.Core/Configuration/CommandConfigurationElement.cs +++ b/FoxTunes.Core/Configuration/CommandConfigurationElement.cs @@ -36,15 +36,15 @@ public CommandConfigurationElement WithHandler(Action action) { action(); } - catch + catch (Exception exception) { - //Logger.Write( - // typeof(CommandConfigurationElement), - // LogLevel.Warn, - // "Failed to invoke command handler \"{0}\": {1}", - // this.Id, - // exception.Message - //); + Logger.Write( + typeof(CommandConfigurationElement), + LogLevel.Warn, + "Failed to invoke command handler \"{0}\": {1}", + this.Id, + exception.Message + ); } }); this.Invoked += handler; diff --git a/FoxTunes.Core/Configuration/ComponentResolver.cs b/FoxTunes.Core/Configuration/ComponentResolver.cs index 3cefc8368..718433892 100644 --- a/FoxTunes.Core/Configuration/ComponentResolver.cs +++ b/FoxTunes.Core/Configuration/ComponentResolver.cs @@ -10,7 +10,15 @@ namespace FoxTunes { public class ComponentResolver : IComponentResolver { - public static string Location + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public static string Location { get { @@ -60,7 +68,7 @@ public void Load() { if (File.Exists(FileName)) { - //Logger.Write(typeof(ComponentResolver), LogLevel.Debug, "Loading component slots from file: {0}", FileName); + Logger.Write(typeof(ComponentResolver), LogLevel.Debug, "Loading component slots from file: {0}", FileName); using (var stream = File.OpenRead(FileName)) { var pairs = Serializer.Load(stream); @@ -75,14 +83,14 @@ public void Load() { continue; } - //Logger.Write(typeof(ComponentResolver), LogLevel.Debug, "Loaded component slot: {0} => {1}", pair.Key, pair.Value); + Logger.Write(typeof(ComponentResolver), LogLevel.Debug, "Loaded component slot: {0} => {1}", pair.Key, pair.Value); } } } } - catch + catch (Exception e) { - //Logger.Write(typeof(ComponentResolver), LogLevel.Warn, "Failed to load component slots: {0}", e.Message); + Logger.Write(typeof(ComponentResolver), LogLevel.Warn, "Failed to load component slots: {0}", e.Message); } foreach (var slot in ComponentSlots.All) { @@ -90,7 +98,7 @@ public void Load() { continue; } - //Logger.Write(typeof(ComponentResolver), LogLevel.Debug, "Component slot {0} is not configured.", slot); + Logger.Write(typeof(ComponentResolver), LogLevel.Debug, "Component slot {0} is not configured.", slot); } } @@ -98,15 +106,15 @@ public void Save() { if (!this.Enabled) { - //Logger.Write(typeof(ComponentResolver), LogLevel.Debug, "Cannot save component slots."); + Logger.Write(typeof(ComponentResolver), LogLevel.Debug, "Cannot save component slots."); return; } if (!this.Slots.Any(pair => pair.Value.Flags.HasFlag(ComponentSlotFlags.Modified | ComponentSlotFlags.HasConflicts))) { - //Logger.Write(typeof(ComponentResolver), LogLevel.Debug, "Component slots are unmodified or have no conflicts, nothing to save."); + Logger.Write(typeof(ComponentResolver), LogLevel.Debug, "Component slots are unmodified or have no conflicts, nothing to save."); return; } - //Logger.Write(typeof(ComponentResolver), LogLevel.Debug, "Saving component slots from file: {0}", FileName); + Logger.Write(typeof(ComponentResolver), LogLevel.Debug, "Saving component slots from file: {0}", FileName); try { using (var stream = File.Create(FileName)) @@ -114,9 +122,9 @@ public void Save() Serializer.Save(stream, this.Slots); } } - catch + catch (Exception e) { - //Logger.Write(typeof(ComponentResolver), LogLevel.Warn, "Failed to save component slots: {0}", e.Message); + Logger.Write(typeof(ComponentResolver), LogLevel.Warn, "Failed to save component slots: {0}", e.Message); } } diff --git a/FoxTunes.Core/Configuration/ConfigurationElement.cs b/FoxTunes.Core/Configuration/ConfigurationElement.cs index d75075ad1..e30c6dd3d 100644 --- a/FoxTunes.Core/Configuration/ConfigurationElement.cs +++ b/FoxTunes.Core/Configuration/ConfigurationElement.cs @@ -8,6 +8,14 @@ namespace FoxTunes { public abstract class ConfigurationElement : INotifyPropertyChanged { + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + private ConfigurationElement() { this.IsHidden = false; @@ -319,16 +327,16 @@ public ConfigurationElement ConnectValue(Action action) { action(this.Value); } - catch + catch (Exception exception) { - //Logger.Write( - // typeof(ConfigurationElement), - // LogLevel.Warn, - // "Failed to connect configuration value \"{0}\" = \"{1}\": {2}", - // this.Id, - // Convert.ToString(this.Value), - // exception.Message - //); + Logger.Write( + typeof(ConfigurationElement), + LogLevel.Warn, + "Failed to connect configuration value \"{0}\" = \"{1}\": {2}", + this.Id, + Convert.ToString(this.Value), + exception.Message + ); } }); handler(this, EventArgs.Empty); @@ -339,7 +347,7 @@ public ConfigurationElement ConnectValue(Action action) public override void InitializeComponent() { //TODO: This log message is noisy. - ////Logger.Write(typeof(ConfigurationSection), LogLevel.Trace, "Setting default value for configuration element \"{0}\": {1}", this.Name, Convert.ToString(this.Value)); + //Logger.Write(typeof(ConfigurationSection), LogLevel.Trace, "Setting default value for configuration element \"{0}\": {1}", this.Name, Convert.ToString(this.Value)); this.DefaultValue = this.Value; base.InitializeComponent(); } diff --git a/FoxTunes.Core/Configuration/ConfigurationSection.cs b/FoxTunes.Core/Configuration/ConfigurationSection.cs index bd9e8f303..768adde93 100644 --- a/FoxTunes.Core/Configuration/ConfigurationSection.cs +++ b/FoxTunes.Core/Configuration/ConfigurationSection.cs @@ -8,7 +8,15 @@ namespace FoxTunes { public class ConfigurationSection : INotifyPropertyChanged { - public ConfigurationSection() + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public ConfigurationSection() { this.Elements = new Dictionary(StringComparer.OrdinalIgnoreCase); this.Flags = ConfigurationSectionFlags.None; @@ -121,20 +129,20 @@ public void Update(ConfigurationSection section) protected virtual void Add(ConfigurationElement element) { - //Logger.Write(typeof(ConfigurationSection), LogLevel.Debug, "Adding configuration element: {0} => {1}", element.Id, element.Name); + Logger.Write(typeof(ConfigurationSection), LogLevel.Debug, "Adding configuration element: {0} => {1}", element.Id, element.Name); this.Elements.Add(element.Id, element); } protected virtual void Update(ConfigurationElement element) { - //Logger.Write(typeof(ConfigurationSection), LogLevel.Debug, "Updating configuration element: {0} => {1}", element.Id, element.Name); + Logger.Write(typeof(ConfigurationSection), LogLevel.Debug, "Updating configuration element: {0} => {1}", element.Id, element.Name); var existing = this.GetElement(element.Id); existing.Update(element); } private void Hide(ConfigurationElement element) { - //Logger.Write(typeof(ConfigurationSection), LogLevel.Debug, "Hiding configuration element: {0} => {1}", element.Id, element.Name); + Logger.Write(typeof(ConfigurationSection), LogLevel.Debug, "Hiding configuration element: {0} => {1}", element.Id, element.Name); var existing = this.GetElement(element.Id); existing.Hide(); } diff --git a/FoxTunes.Core/Configuration/SelectionConfigurationElement.cs b/FoxTunes.Core/Configuration/SelectionConfigurationElement.cs index 6ce426923..6939f71b9 100644 --- a/FoxTunes.Core/Configuration/SelectionConfigurationElement.cs +++ b/FoxTunes.Core/Configuration/SelectionConfigurationElement.cs @@ -44,7 +44,7 @@ public SelectionConfigurationElement WithOptions(IEnumerable components) ComponentRegistry.Instance.AddComponents(components); this.LoadConfiguration(); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Debug, "Failed to load the core, we will crash soon: {0}", e.Message); + Logger.Write(this, LogLevel.Debug, "Failed to load the core, we will crash soon: {0}", e.Message); throw; } } @@ -86,9 +86,9 @@ public void Initialize() { this.InitializeComponents(); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Debug, "Failed to initialize the core, we will crash soon: {0}", e.Message); + Logger.Write(this, LogLevel.Debug, "Failed to initialize the core, we will crash soon: {0}", e.Message); throw; } } @@ -106,7 +106,7 @@ protected virtual void LoadComponents() ); #if DEBUG stopwatch.Stop(); - //Logger.Write(this, LogLevel.Trace, "Components loaded in {0}ms.", stopwatch.ElapsedMilliseconds); + Logger.Write(this, LogLevel.Trace, "Components loaded in {0}ms.", stopwatch.ElapsedMilliseconds); #endif } @@ -120,14 +120,14 @@ protected virtual void LoadConfiguration() var sections = new ConcurrentBag(); Parallel.ForEach(components, component => { - //Logger.Write(this, LogLevel.Debug, "Getting configuration for component {0}.", component.GetType().Name); + Logger.Write(this, LogLevel.Debug, "Getting configuration for component {0}.", component.GetType().Name); try { sections.AddRange(component.GetConfigurationSections()); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to get configuration for component {0}: {1}", component.GetType().Name, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to get configuration for component {0}: {1}", component.GetType().Name, e.Message); } }); foreach (var section in sections) @@ -138,7 +138,7 @@ protected virtual void LoadConfiguration() this.Components.Configuration.ConnectDependencies(); #if DEBUG stopwatch.Stop(); - //Logger.Write(this, LogLevel.Trace, "Configuration loaded in {0}ms.", stopwatch.ElapsedMilliseconds); + Logger.Write(this, LogLevel.Trace, "Configuration loaded in {0}ms.", stopwatch.ElapsedMilliseconds); #endif } @@ -150,9 +150,9 @@ protected virtual void InitializeComponents() { component.InitializeComponent(this); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to initialize component {0}: {1}", component.GetType().Name, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to initialize component {0}: {1}", component.GetType().Name, e.Message); } }); } @@ -165,9 +165,9 @@ public void InitializeDatabase(IDatabaseComponent database, DatabaseInitializeTy { component.InitializeDatabase(database, type); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to initialize database {0}: {1}", component.GetType().Name, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to initialize database {0}: {1}", component.GetType().Name, e.Message); } }); } @@ -213,9 +213,9 @@ protected virtual void OnDisposing() { component.Dispose(); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to dispose component {0}: {1}", component.GetType().Name, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to dispose component {0}: {1}", component.GetType().Name, e.Message); } }); Instance = null; @@ -223,7 +223,7 @@ protected virtual void OnDisposing() ~Core() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/Deferral.cs b/FoxTunes.Core/Deferral.cs index a4f5e2765..5447be340 100644 --- a/FoxTunes.Core/Deferral.cs +++ b/FoxTunes.Core/Deferral.cs @@ -5,7 +5,15 @@ namespace FoxTunes { public class Deferral : IDisposable { - public Deferral(Action action) + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public Deferral(Action action) { this.Action = action; } @@ -39,7 +47,7 @@ protected virtual void OnDisposing() ~Deferral() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/Error/ErrorEmitter.cs b/FoxTunes.Core/Error/ErrorEmitter.cs index fc9bbe2d8..bb6767abd 100644 --- a/FoxTunes.Core/Error/ErrorEmitter.cs +++ b/FoxTunes.Core/Error/ErrorEmitter.cs @@ -24,7 +24,7 @@ public Task Send(IBaseComponent source, string message, Exception exception) protected virtual Task OnError(object sender, ComponentErrorEventArgs e) { - //Logger.Write(this, LogLevel.Error, e.Message); + Logger.Write(this, LogLevel.Error, e.Message); if (this.Error == null) { #if NET40 diff --git a/FoxTunes.Core/Interfaces/Logging/ILogger.cs b/FoxTunes.Core/Interfaces/Logging/ILogger.cs new file mode 100644 index 000000000..f50e3f22d --- /dev/null +++ b/FoxTunes.Core/Interfaces/Logging/ILogger.cs @@ -0,0 +1,52 @@ +using System; +using System.Threading.Tasks; + +namespace FoxTunes.Interfaces +{ + public interface ILogger : IBaseComponent + { + bool IsTraceEnabled(IBaseComponent component); + + bool IsDebugEnabled(IBaseComponent component); + + bool IsInfoEnabled(IBaseComponent component); + + bool IsWarnEnabled(IBaseComponent component); + + bool IsErrorEnabled(IBaseComponent component); + + bool IsFatalEnabled(IBaseComponent component); + + bool IsTraceEnabled(Type type); + + bool IsDebugEnabled(Type type); + + bool IsInfoEnabled(Type type); + + bool IsWarnEnabled(Type type); + + bool IsErrorEnabled(Type type); + + bool IsFatalEnabled(Type type); + + void Write(IBaseComponent component, LogLevel level, string message, params object[] args); + + void Write(Type type, LogLevel level, string message, params object[] args); + + Task WriteAsync(IBaseComponent component, LogLevel level, string message, params object[] args); + + Task WriteAsync(Type type, LogLevel level, string message, params object[] args); + } + + [Flags] + public enum LogLevel : byte + { + None = 0, + Trace = 1 | Debug, + Debug = 2 | Info, + Info = 4 | Warn, + Warn = 8 | Error, + Error = 16 | Fatal, + Fatal = 32 + } +} diff --git a/FoxTunes.Core/Library/LibraryCache.cs b/FoxTunes.Core/Library/LibraryCache.cs index 37ab704d7..b0328d591 100644 --- a/FoxTunes.Core/Library/LibraryCache.cs +++ b/FoxTunes.Core/Library/LibraryCache.cs @@ -111,7 +111,7 @@ protected virtual void OnDisposing() ~LibraryCache() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/Library/LibraryHierarchyBrowser.cs b/FoxTunes.Core/Library/LibraryHierarchyBrowser.cs index 4cb0b16a0..ad70f6678 100644 --- a/FoxTunes.Core/Library/LibraryHierarchyBrowser.cs +++ b/FoxTunes.Core/Library/LibraryHierarchyBrowser.cs @@ -133,7 +133,7 @@ protected virtual Task OnMetaDataUpdated(MetaDataUpdatedSignalState state) return Task.CompletedTask; #endif } - //Logger.Write(this, LogLevel.Debug, "Meta data was updated and there is an active filter which applies to it, refreshing."); + Logger.Write(this, LogLevel.Debug, "Meta data was updated and there is an active filter which applies to it, refreshing."); return this.SignalEmitter.Send(new Signal(this, CommonSignals.HierarchiesUpdated)); } #if NET40 @@ -372,7 +372,7 @@ protected virtual void OnDisposing() ~LibraryHierarchyBrowser() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/Library/LibraryHierarchyCache.cs b/FoxTunes.Core/Library/LibraryHierarchyCache.cs index c75d17d8c..6e44afd5b 100644 --- a/FoxTunes.Core/Library/LibraryHierarchyCache.cs +++ b/FoxTunes.Core/Library/LibraryHierarchyCache.cs @@ -75,7 +75,7 @@ protected virtual Task OnSignal(object sender, ISignal signal) this.OnMetaDataUpdated(signal.State as MetaDataUpdatedSignalState); break; case CommonSignals.HierarchiesUpdated: - //Logger.Write(this, LogLevel.Debug, "Hierarchies were updated, resetting cache."); + Logger.Write(this, LogLevel.Debug, "Hierarchies were updated, resetting cache."); this.Reset(); break; } @@ -138,7 +138,7 @@ public void Reset() public void Evict(LibraryHierarchyCacheKey key) { - //Logger.Write(this, LogLevel.Debug, "Evicting cache entry: {0}", key); + Logger.Write(this, LogLevel.Debug, "Evicting cache entry: {0}", key); this.Nodes.TryRemove(key); this.Items.TryRemove(key); } @@ -171,7 +171,7 @@ protected virtual void OnDisposing() ~LibraryHierarchyCache() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/Library/LibraryHierarchyPopulator.cs b/FoxTunes.Core/Library/LibraryHierarchyPopulator.cs index 05b0beda5..d4a1add6a 100644 --- a/FoxTunes.Core/Library/LibraryHierarchyPopulator.cs +++ b/FoxTunes.Core/Library/LibraryHierarchyPopulator.cs @@ -59,7 +59,7 @@ public async Task Populate(LibraryItemStatus? status, CancellationToken cancella if (libraryHierarchies.Length == 0) { - //Logger.Write(this, LogLevel.Warn, "No library hierarchies are defined (or enabled)."); + Logger.Write(this, LogLevel.Warn, "No library hierarchies are defined (or enabled)."); return; } @@ -199,7 +199,7 @@ private string[] GetPathSegments(string fileName) } else { - //Logger.Write(this, LogLevel.Warn, "Failed to parse library item path: {0}", fileName); + Logger.Write(this, LogLevel.Warn, "Failed to parse library item path: {0}", fileName); return new string[] { }; } } diff --git a/FoxTunes.Core/Library/LibraryPopulator.cs b/FoxTunes.Core/Library/LibraryPopulator.cs index ada09180c..0aad3ac2b 100644 --- a/FoxTunes.Core/Library/LibraryPopulator.cs +++ b/FoxTunes.Core/Library/LibraryPopulator.cs @@ -78,10 +78,10 @@ protected virtual async Task AddLibraryItem(LibraryWriter writer, string f { if (!this.PlaybackManager.IsSupported(fileName)) { - //Logger.Write(this, LogLevel.Debug, "File is not supported: {0}", fileName); + Logger.Write(this, LogLevel.Debug, "File is not supported: {0}", fileName); return false; } - //Logger.Write(this, LogLevel.Trace, "Adding file to library: {0}", fileName); + Logger.Write(this, LogLevel.Trace, "Adding file to library: {0}", fileName); var libraryItem = new LibraryItem() { DirectoryName = Path.GetDirectoryName(fileName), @@ -92,9 +92,9 @@ protected virtual async Task AddLibraryItem(LibraryWriter writer, string f await writer.Write(libraryItem).ConfigureAwait(false); return true; } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Debug, "Failed to add file \"{0}\" to library: {0}", fileName, e.Message); + Logger.Write(this, LogLevel.Debug, "Failed to add file \"{0}\" to library: {0}", fileName, e.Message); return false; } } diff --git a/FoxTunes.Core/LogManager.cs b/FoxTunes.Core/LogManager.cs new file mode 100644 index 000000000..05ec6d28a --- /dev/null +++ b/FoxTunes.Core/LogManager.cs @@ -0,0 +1,115 @@ +using FoxTunes.Interfaces; +using System; +using System.Threading.Tasks; + +namespace FoxTunes +{ + public static class LogManager + { + public static ILogger Logger + { + get + { + return NullLogger.Instance; + } + } + + private class NullLogger : BaseComponent, ILogger + { + public bool IsTraceEnabled(IBaseComponent component) + { + return false; + } + + public bool IsDebugEnabled(IBaseComponent component) + { + return false; + } + + public bool IsInfoEnabled(IBaseComponent component) + { + return false; + } + + public bool IsWarnEnabled(IBaseComponent component) + { + return false; + } + + public bool IsErrorEnabled(IBaseComponent component) + { + return false; + } + + public bool IsFatalEnabled(IBaseComponent component) + { + return false; + } + + public bool IsTraceEnabled(Type type) + { + return false; + } + + public bool IsDebugEnabled(Type type) + { + return false; + } + + public bool IsInfoEnabled(Type type) + { + return false; + } + + public bool IsWarnEnabled(Type type) + { + return false; + } + + public bool IsErrorEnabled(Type type) + { + return false; + } + + public bool IsFatalEnabled(Type type) + { + return false; + } + + public void Write(IBaseComponent component, LogLevel level, string message, params object[] args) + { + + } + + public void Write(Type type, LogLevel level, string message, params object[] args) + { + + } + + public Task WriteAsync(IBaseComponent component, LogLevel level, string message, params object[] args) + { +#if NET40 + return TaskEx.FromResult(false); +#else + return Task.CompletedTask; +#endif + } + + public Task WriteAsync(Type type, LogLevel level, string message, params object[] args) + { +#if NET40 + return TaskEx.FromResult(false); +#else + return Task.CompletedTask; +#endif + } + + public void Dispose() + { + //Nothing to do. + } + + public static readonly ILogger Instance = new NullLogger(); + } + } +} diff --git a/FoxTunes.Core/Managers/InputManager.cs b/FoxTunes.Core/Managers/InputManager.cs index a896c0517..bb4374adf 100644 --- a/FoxTunes.Core/Managers/InputManager.cs +++ b/FoxTunes.Core/Managers/InputManager.cs @@ -70,7 +70,7 @@ protected virtual void OnInputEvent(int modifiers, int keys) { return; } - //Logger.Write(this, LogLevel.Debug, "Executing global keyboard shortcut: {0} => {1}", modifiers, keys); + Logger.Write(this, LogLevel.Debug, "Executing global keyboard shortcut: {0} => {1}", modifiers, keys); value(); } diff --git a/FoxTunes.Core/Managers/LibraryManager.cs b/FoxTunes.Core/Managers/LibraryManager.cs index 1b4d7dc7f..7301dfcae 100644 --- a/FoxTunes.Core/Managers/LibraryManager.cs +++ b/FoxTunes.Core/Managers/LibraryManager.cs @@ -165,11 +165,11 @@ protected virtual void RefreshSelectedHierarchy() selectedHierarchy = this.HierarchyBrowser.GetHierarchies().FirstOrDefault(libraryHierarchy => libraryHierarchy.Id == selectedHierarchy.Id); if (selectedHierarchy != null) { - //Logger.Write(this, LogLevel.Debug, "Refreshed selected hierarchy: {0} => {1}", selectedHierarchy.Id, selectedHierarchy.Name); + Logger.Write(this, LogLevel.Debug, "Refreshed selected hierarchy: {0} => {1}", selectedHierarchy.Id, selectedHierarchy.Name); } else { - //Logger.Write(this, LogLevel.Debug, "Failed to refresh selected hierarchy, it was removed or disabled."); + Logger.Write(this, LogLevel.Debug, "Failed to refresh selected hierarchy, it was removed or disabled."); } } if (selectedHierarchy == null) @@ -177,11 +177,11 @@ protected virtual void RefreshSelectedHierarchy() selectedHierarchy = this.HierarchyBrowser.GetHierarchies().FirstOrDefault(); if (selectedHierarchy != null) { - //Logger.Write(this, LogLevel.Debug, "Selected first hierarchy: {0} => {1}", selectedHierarchy.Id, selectedHierarchy.Name); + Logger.Write(this, LogLevel.Debug, "Selected first hierarchy: {0} => {1}", selectedHierarchy.Id, selectedHierarchy.Name); } else { - //Logger.Write(this, LogLevel.Warn, "Failed to select a hierarchy, perhaps none are enabled?"); + Logger.Write(this, LogLevel.Warn, "Failed to select a hierarchy, perhaps none are enabled?"); } } if (object.ReferenceEquals(this.SelectedHierarchy, selectedHierarchy)) @@ -221,11 +221,11 @@ protected virtual void RefreshSelectedItem(LibraryHierarchy libraryHierarchy) selectedItem = this.HierarchyBrowser.GetNode(libraryHierarchy, selectedItem); if (selectedItem != null) { - //Logger.Write(this, LogLevel.Debug, "Refreshed selected item: {0} => {1}", selectedItem.Id, selectedItem.Value); + Logger.Write(this, LogLevel.Debug, "Refreshed selected item: {0} => {1}", selectedItem.Id, selectedItem.Value); } else { - //Logger.Write(this, LogLevel.Debug, "Failed to refresh selected item, it was removed."); + Logger.Write(this, LogLevel.Debug, "Failed to refresh selected item, it was removed."); } } if (selectedItem == null) @@ -233,11 +233,11 @@ protected virtual void RefreshSelectedItem(LibraryHierarchy libraryHierarchy) selectedItem = this.HierarchyBrowser.GetNodes(libraryHierarchy).FirstOrDefault(); if (selectedItem != null) { - //Logger.Write(this, LogLevel.Debug, "Selected first item: {0} => {1}", selectedItem.Id, selectedItem.Value); + Logger.Write(this, LogLevel.Debug, "Selected first item: {0} => {1}", selectedItem.Id, selectedItem.Value); } else { - //Logger.Write(this, LogLevel.Warn, "Failed to select an item, perhaps none are available?"); + Logger.Write(this, LogLevel.Warn, "Failed to select an item, perhaps none are available?"); } } if (object.ReferenceEquals(this._SelectedItem[libraryHierarchy], selectedItem)) diff --git a/FoxTunes.Core/Managers/PlaybackManager.cs b/FoxTunes.Core/Managers/PlaybackManager.cs index d5ab9def7..121676b39 100644 --- a/FoxTunes.Core/Managers/PlaybackManager.cs +++ b/FoxTunes.Core/Managers/PlaybackManager.cs @@ -44,12 +44,12 @@ protected virtual async void OutputStreamQueueDequeued(object sender, OutputStre var exception = default(Exception); try { - //Logger.Write(this, LogLevel.Debug, "Output stream is about to change, pre-empting the next stream: {0} => {1}", e.OutputStream.Id, e.OutputStream.FileName); + Logger.Write(this, LogLevel.Debug, "Output stream is about to change, pre-empting the next stream: {0} => {1}", e.OutputStream.Id, e.OutputStream.FileName); if (!await this.Output.Preempt(e.OutputStream).ConfigureAwait(false)) { - //Logger.Write(this, LogLevel.Debug, "Preempt failed for stream: {0} => {1}", e.OutputStream.Id, e.OutputStream.FileName); + Logger.Write(this, LogLevel.Debug, "Preempt failed for stream: {0} => {1}", e.OutputStream.Id, e.OutputStream.FileName); } - //Logger.Write(this, LogLevel.Debug, "Output stream de-queued, loading it: {0} => {1}", e.OutputStream.Id, e.OutputStream.FileName); + Logger.Write(this, LogLevel.Debug, "Output stream de-queued, loading it: {0} => {1}", e.OutputStream.Id, e.OutputStream.FileName); await this.SetCurrentStream(e.OutputStream).ConfigureAwait(false); } catch (Exception ex) @@ -87,7 +87,7 @@ protected virtual async Task SetCurrentStream(IOutputStream stream) { return; } - //Logger.Write(this, LogLevel.Debug, "Unloading current stream: {0} => {1}", currentStream.Id, currentStream.FileName); + Logger.Write(this, LogLevel.Debug, "Unloading current stream: {0} => {1}", currentStream.Id, currentStream.FileName); this.OnCurrentStreamChanging(); this._CurrentStream = stream; await this.Unload(currentStream).ConfigureAwait(false); @@ -99,7 +99,7 @@ protected virtual async Task SetCurrentStream(IOutputStream stream) } if (stream != null) { - //Logger.Write(this, LogLevel.Debug, "Playing stream: {0} => {1}", stream.Id, stream.FileName); + Logger.Write(this, LogLevel.Debug, "Playing stream: {0} => {1}", stream.Id, stream.FileName); try { await stream.Play().ConfigureAwait(false); diff --git a/FoxTunes.Core/Managers/PlaylistManager.cs b/FoxTunes.Core/Managers/PlaylistManager.cs index 243ee3959..3111592a6 100644 --- a/FoxTunes.Core/Managers/PlaylistManager.cs +++ b/FoxTunes.Core/Managers/PlaylistManager.cs @@ -149,11 +149,11 @@ protected virtual void RefreshSelectedPlaylist() selectedPlaylist = this.PlaylistBrowser.GetPlaylists().FirstOrDefault(playlist => playlist.Id == this.SelectedPlaylist.Id); if (selectedPlaylist != null) { - //Logger.Write(this, LogLevel.Debug, "Refreshed selected playlist: {0} => {1}", this.SelectedPlaylist.Id, this.SelectedPlaylist.Name); + Logger.Write(this, LogLevel.Debug, "Refreshed selected playlist: {0} => {1}", this.SelectedPlaylist.Id, this.SelectedPlaylist.Name); } else { - //Logger.Write(this, LogLevel.Debug, "Failed to refresh selected playlist, it was removed or disabled."); + Logger.Write(this, LogLevel.Debug, "Failed to refresh selected playlist, it was removed or disabled."); } } if (selectedPlaylist == null) @@ -161,11 +161,11 @@ protected virtual void RefreshSelectedPlaylist() selectedPlaylist = this.PlaylistBrowser.GetPlaylists().FirstOrDefault(); if (selectedPlaylist == null) { - //Logger.Write(this, LogLevel.Warn, "Failed to select a playlist, perhaps none are enabled?"); + Logger.Write(this, LogLevel.Warn, "Failed to select a playlist, perhaps none are enabled?"); } else { - //Logger.Write(this, LogLevel.Debug, "Selected first playlist: {0} => {1}", selectedPlaylist.Id, selectedPlaylist.Name); + Logger.Write(this, LogLevel.Debug, "Selected first playlist: {0} => {1}", selectedPlaylist.Id, selectedPlaylist.Name); } } if (object.ReferenceEquals(this.SelectedPlaylist, selectedPlaylist)) @@ -183,11 +183,11 @@ protected virtual void RefreshCurrentPlaylist() currentPlaylist = this.PlaylistBrowser.GetPlaylists().FirstOrDefault(playlist => playlist.Id == currentPlaylist.Id); if (currentPlaylist != null) { - //Logger.Write(this, LogLevel.Debug, "Refreshed current playlist: {0} => {1}", currentPlaylist.Id, currentPlaylist.Name); + Logger.Write(this, LogLevel.Debug, "Refreshed current playlist: {0} => {1}", currentPlaylist.Id, currentPlaylist.Name); } else { - //Logger.Write(this, LogLevel.Debug, "Failed to refresh current playlist, it was removed or disabled."); + Logger.Write(this, LogLevel.Debug, "Failed to refresh current playlist, it was removed or disabled."); } } if (object.ReferenceEquals(this.CurrentPlaylist, currentPlaylist)) @@ -211,7 +211,7 @@ protected virtual void RefreshCurrentItem() } if (currentItem == null) { - //Logger.Write(this, LogLevel.Warn, "Failed to refresh current item."); + Logger.Write(this, LogLevel.Warn, "Failed to refresh current item."); } } if (object.ReferenceEquals(this.CurrentItem, currentItem)) @@ -223,16 +223,16 @@ protected virtual void RefreshCurrentItem() protected virtual void OnCurrentStreamChanged(object sender, EventArgs e) { - //Logger.Write(this, LogLevel.Debug, "Playback manager output stream changed, updating current playlist item."); + Logger.Write(this, LogLevel.Debug, "Playback manager output stream changed, updating current playlist item."); if (this.PlaybackManager.CurrentStream == null) { this.CurrentItem = null; - //Logger.Write(this, LogLevel.Debug, "Playback manager output stream is empty. Cleared current playlist item."); + Logger.Write(this, LogLevel.Debug, "Playback manager output stream is empty. Cleared current playlist item."); } else if (this.PlaybackManager.CurrentStream.PlaylistItem != this.CurrentItem) { this.CurrentItem = this.PlaybackManager.CurrentStream.PlaylistItem; - //Logger.Write(this, LogLevel.Debug, "Updated current playlist item: {0} => {1}", this.CurrentItem.Id, this.CurrentItem.FileName); + Logger.Write(this, LogLevel.Debug, "Updated current playlist item: {0} => {1}", this.CurrentItem.Id, this.CurrentItem.FileName); } } @@ -288,14 +288,14 @@ public async Task Remove(Playlist playlist) public Task Add(Playlist playlist, IEnumerable paths, bool clear) { - //Logger.Write(this, LogLevel.Debug, "Adding paths to playlist."); + Logger.Write(this, LogLevel.Debug, "Adding paths to playlist."); var index = this.PlaylistBrowser.GetInsertIndex(this.SelectedPlaylist); return this.Insert(playlist, index, paths, clear); } public async Task Insert(Playlist playlist, int index, IEnumerable paths, bool clear) { - //Logger.Write(this, LogLevel.Debug, "Inserting paths into playlist at index: {0}", index); + Logger.Write(this, LogLevel.Debug, "Inserting paths into playlist at index: {0}", index); using (var task = new AddPathsToPlaylistTask(playlist, index, paths, clear)) { task.InitializeComponent(this.Core); @@ -306,14 +306,14 @@ public async Task Insert(Playlist playlist, int index, IEnumerable paths public Task Add(Playlist playlist, LibraryHierarchyNode libraryHierarchyNode, bool clear) { - //Logger.Write(this, LogLevel.Debug, "Adding library node to playlist."); + Logger.Write(this, LogLevel.Debug, "Adding library node to playlist."); var index = this.PlaylistBrowser.GetInsertIndex(this.SelectedPlaylist); return this.Insert(playlist, index, libraryHierarchyNode, clear); } public async Task Insert(Playlist playlist, int index, LibraryHierarchyNode libraryHierarchyNode, bool clear) { - //Logger.Write(this, LogLevel.Debug, "Inserting library node into playlist at index: {0}", index); + Logger.Write(this, LogLevel.Debug, "Inserting library node into playlist at index: {0}", index); using (var task = new AddLibraryHierarchyNodeToPlaylistTask(playlist, index, libraryHierarchyNode, clear)) { task.InitializeComponent(this.Core); @@ -324,14 +324,14 @@ public async Task Insert(Playlist playlist, int index, LibraryHierarchyNode libr public Task Add(Playlist playlist, IEnumerable libraryHierarchyNodes, bool clear) { - //Logger.Write(this, LogLevel.Debug, "Adding library nodes to playlist."); + Logger.Write(this, LogLevel.Debug, "Adding library nodes to playlist."); var index = this.PlaylistBrowser.GetInsertIndex(this.SelectedPlaylist); return this.Insert(playlist, index, libraryHierarchyNodes, clear); } public async Task Insert(Playlist playlist, int index, IEnumerable libraryHierarchyNodes, bool clear) { - //Logger.Write(this, LogLevel.Debug, "Inserting library nodes into playlist at index: {0}", index); + Logger.Write(this, LogLevel.Debug, "Inserting library nodes into playlist at index: {0}", index); using (var task = new AddLibraryHierarchyNodesToPlaylistTask(playlist, index, libraryHierarchyNodes, this.LibraryHierarchyBrowser.Filter, clear)) { task.InitializeComponent(this.Core); @@ -342,14 +342,14 @@ public async Task Insert(Playlist playlist, int index, IEnumerable playlistItems, bool clear) { - //Logger.Write(this, LogLevel.Debug, "Adding items to playlist."); + Logger.Write(this, LogLevel.Debug, "Adding items to playlist."); var index = this.PlaylistBrowser.GetInsertIndex(this.SelectedPlaylist); return this.Insert(playlist, index, playlistItems, clear); } public async Task Insert(Playlist playlist, int index, IEnumerable playlistItems, bool clear) { - //Logger.Write(this, LogLevel.Debug, "Inserting items into playlist at index: {0}", index); + Logger.Write(this, LogLevel.Debug, "Inserting items into playlist at index: {0}", index); using (var task = new MovePlaylistItemsTask(playlist, index, playlistItems, clear)) { task.InitializeComponent(this.Core); @@ -360,14 +360,14 @@ public async Task Insert(Playlist playlist, int index, IEnumerable public Task Move(Playlist playlist, IEnumerable playlistItems) { - //Logger.Write(this, LogLevel.Debug, "Re-ordering playlist items."); + Logger.Write(this, LogLevel.Debug, "Re-ordering playlist items."); var index = this.PlaylistBrowser.GetInsertIndex(this.SelectedPlaylist); return this.Move(playlist, index, playlistItems); } public async Task Move(Playlist playlist, int index, IEnumerable playlistItems) { - //Logger.Write(this, LogLevel.Debug, "Re-ordering playlist items at index: {0}", index); + Logger.Write(this, LogLevel.Debug, "Re-ordering playlist items at index: {0}", index); using (var task = new MovePlaylistItemsTask(playlist, index, playlistItems, false)) { task.InitializeComponent(this.Core); @@ -417,13 +417,13 @@ public async Task Next(bool wrap) { if (this.SelectedPlaylist == null) { - //Logger.Write(this, LogLevel.Debug, "No playlist."); + Logger.Write(this, LogLevel.Debug, "No playlist."); return; } - //Logger.Write(this, LogLevel.Debug, "Navigating to next playlist item."); + Logger.Write(this, LogLevel.Debug, "Navigating to next playlist item."); if (this.IsNavigating) { - //Logger.Write(this, LogLevel.Debug, "Already navigating, ignoring request."); + Logger.Write(this, LogLevel.Debug, "Already navigating, ignoring request."); return; } try @@ -432,12 +432,12 @@ public async Task Next(bool wrap) var playlistItem = this.PlaylistBrowser.GetNextItem(this.CurrentPlaylist, wrap); if (playlistItem == null) { - //Logger.Write(this, LogLevel.Debug, "Playlist ended, stopping."); + Logger.Write(this, LogLevel.Debug, "Playlist ended, stopping."); await this.PlaybackManager.Stop(); } else { - //Logger.Write(this, LogLevel.Debug, "Playing playlist item: {0} => {1}", playlistItem.Id, playlistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Playing playlist item: {0} => {1}", playlistItem.Id, playlistItem.FileName); await this.Play(playlistItem).ConfigureAwait(false); } } @@ -451,13 +451,13 @@ public async Task Previous() { if (this.SelectedPlaylist == null) { - //Logger.Write(this, LogLevel.Debug, "No playlist."); + Logger.Write(this, LogLevel.Debug, "No playlist."); return; } - //Logger.Write(this, LogLevel.Debug, "Navigating to previous playlist item."); + Logger.Write(this, LogLevel.Debug, "Navigating to previous playlist item."); if (this.IsNavigating) { - //Logger.Write(this, LogLevel.Debug, "Already navigating, ignoring request."); + Logger.Write(this, LogLevel.Debug, "Already navigating, ignoring request."); return; } try @@ -468,7 +468,7 @@ public async Task Previous() { return; } - //Logger.Write(this, LogLevel.Debug, "Playing playlist item: {0} => {1}", playlistItem.Id, playlistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Playing playlist item: {0} => {1}", playlistItem.Id, playlistItem.FileName); await this.Play(playlistItem).ConfigureAwait(false); } finally diff --git a/FoxTunes.Core/MessageSink.cs b/FoxTunes.Core/MessageSink.cs index 8925ee0f7..24307b549 100644 --- a/FoxTunes.Core/MessageSink.cs +++ b/FoxTunes.Core/MessageSink.cs @@ -102,7 +102,7 @@ protected virtual void OnDisposing() ~MessageSink() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/MetaData/FileMetaDataStore.cs b/FoxTunes.Core/MetaData/FileMetaDataStore.cs index f29744feb..ad2df7397 100644 --- a/FoxTunes.Core/MetaData/FileMetaDataStore.cs +++ b/FoxTunes.Core/MetaData/FileMetaDataStore.cs @@ -36,7 +36,7 @@ public static bool Exists(string prefix, string id, out string fileName) public static string Write(string prefix, string id, byte[] data) { var fileName = GetFileName(prefix, id); - //Logger.Write(typeof(FileMetaDataStore), LogLevel.Trace, "Writing data: {0} => {1}", id, fileName); + LogManager.Logger.Write(typeof(FileMetaDataStore), LogLevel.Trace, "Writing data: {0} => {1}", id, fileName); Directory.CreateDirectory(Path.GetDirectoryName(fileName)); try { @@ -45,9 +45,9 @@ public static string Write(string prefix, string id, byte[] data) stream.Write(data, 0, data.Length); } } - catch + catch (Exception e) { - //Logger.Write(typeof(FileMetaDataStore), LogLevel.Error, "Failed to write data: {0} => {1} => {2}", id, fileName, e.Message); + LogManager.Logger.Write(typeof(FileMetaDataStore), LogLevel.Error, "Failed to write data: {0} => {1} => {2}", id, fileName, e.Message); } return fileName; } @@ -55,7 +55,7 @@ public static string Write(string prefix, string id, byte[] data) public static async Task WriteAsync(string prefix, string id, byte[] data) { var fileName = GetFileName(prefix, id); - //Logger.Write(typeof(FileMetaDataStore), LogLevel.Trace, "Writing data: {0} => {1}", id, fileName); + LogManager.Logger.Write(typeof(FileMetaDataStore), LogLevel.Trace, "Writing data: {0} => {1}", id, fileName); Directory.CreateDirectory(Path.GetDirectoryName(fileName)); try { @@ -64,9 +64,9 @@ public static async Task WriteAsync(string prefix, string id, byte[] dat await stream.WriteAsync(data, 0, data.Length).ConfigureAwait(false); } } - catch + catch (Exception e) { - //Logger.Write(typeof(FileMetaDataStore), LogLevel.Error, "Failed to write data: {0} => {1} => {2}", id, fileName, e.Message); + LogManager.Logger.Write(typeof(FileMetaDataStore), LogLevel.Error, "Failed to write data: {0} => {1} => {2}", id, fileName, e.Message); } return fileName; } @@ -74,7 +74,7 @@ public static async Task WriteAsync(string prefix, string id, byte[] dat public static string Write(string prefix, string id, Stream stream) { var fileName = GetFileName(prefix, id); - //Logger.Write(typeof(FileMetaDataStore), LogLevel.Trace, "Writing data: {0} => {1}", id, fileName); + LogManager.Logger.Write(typeof(FileMetaDataStore), LogLevel.Trace, "Writing data: {0} => {1}", id, fileName); Directory.CreateDirectory(Path.GetDirectoryName(fileName)); using (var file = File.OpenWrite(fileName)) { @@ -82,9 +82,9 @@ public static string Write(string prefix, string id, Stream stream) { stream.CopyTo(file); } - catch + catch (Exception e) { - //Logger.Write(typeof(FileMetaDataStore), LogLevel.Error, "Failed to write data: {0} => {1} => {2}", id, fileName, e.Message); + LogManager.Logger.Write(typeof(FileMetaDataStore), LogLevel.Error, "Failed to write data: {0} => {1} => {2}", id, fileName, e.Message); } } return fileName; @@ -93,7 +93,7 @@ public static string Write(string prefix, string id, Stream stream) public static async Task WriteAsync(string prefix, string id, Stream stream) { var fileName = GetFileName(prefix, id); - //Logger.Write(typeof(FileMetaDataStore), LogLevel.Trace, "Writing data: {0} => {1}", id, fileName); + LogManager.Logger.Write(typeof(FileMetaDataStore), LogLevel.Trace, "Writing data: {0} => {1}", id, fileName); Directory.CreateDirectory(Path.GetDirectoryName(fileName)); using (var file = File.OpenWrite(fileName)) { @@ -101,9 +101,9 @@ public static async Task WriteAsync(string prefix, string id, Stream str { await stream.CopyToAsync(file).ConfigureAwait(false); } - catch + catch (Exception e) { - //Logger.Write(typeof(FileMetaDataStore), LogLevel.Error, "Failed to write data: {0} => {1} => {2}", id, fileName, e.Message); + LogManager.Logger.Write(typeof(FileMetaDataStore), LogLevel.Error, "Failed to write data: {0} => {1} => {2}", id, fileName, e.Message); } } return fileName; @@ -138,9 +138,9 @@ public static void Clear(string prefix) { Directory.Delete(directoryName, true); } - catch + catch (Exception e) { - //Logger.Write(typeof(FileMetaDataStore), LogLevel.Error, "Failed to clear data: {0} => {1}", prefix, e.Message); + LogManager.Logger.Write(typeof(FileMetaDataStore), LogLevel.Error, "Failed to clear data: {0} => {1}", prefix, e.Message); } } } diff --git a/FoxTunes.Core/MetaData/MetaDataCache.cs b/FoxTunes.Core/MetaData/MetaDataCache.cs index 17b450054..1a47e8659 100644 --- a/FoxTunes.Core/MetaData/MetaDataCache.cs +++ b/FoxTunes.Core/MetaData/MetaDataCache.cs @@ -46,7 +46,7 @@ protected virtual Task OnSignal(object sender, ISignal signal) this.OnMetaDataUpdated(signal.State as MetaDataUpdatedSignalState); break; case CommonSignals.HierarchiesUpdated: - //Logger.Write(this, LogLevel.Debug, "Hierarchies were updated, resetting cache."); + Logger.Write(this, LogLevel.Debug, "Hierarchies were updated, resetting cache."); this.Reset(); break; } @@ -61,7 +61,7 @@ protected virtual void OnMetaDataUpdated(MetaDataUpdatedSignalState state) { if (state == null) { - //Logger.Write(this, LogLevel.Debug, "Meta data was updated, resetting cache."); + Logger.Write(this, LogLevel.Debug, "Meta data was updated, resetting cache."); this.Reset(); } else @@ -128,7 +128,7 @@ public void Reset() public void Evict(MetaDataCacheKey key) { - //Logger.Write(this, LogLevel.Debug, "Evicting cache entry: {0}", key); + Logger.Write(this, LogLevel.Debug, "Evicting cache entry: {0}", key); this.Values.TryRemove(key); } @@ -160,7 +160,7 @@ protected virtual void OnDisposing() ~MetaDataCache() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/MetaData/MetaDataPopulator.cs b/FoxTunes.Core/MetaData/MetaDataPopulator.cs index 3f3dc8f27..c128e4af4 100644 --- a/FoxTunes.Core/MetaData/MetaDataPopulator.cs +++ b/FoxTunes.Core/MetaData/MetaDataPopulator.cs @@ -69,7 +69,7 @@ public override void InitializeComponent(ICore core) public async Task Populate(IEnumerable fileDatas, CancellationToken cancellationToken) where T : IFileData { - //Logger.Write(this, LogLevel.Debug, "Begin populating meta data."); + Logger.Write(this, LogLevel.Debug, "Begin populating meta data."); if (this.ReportProgress) { @@ -95,7 +95,7 @@ public async Task Populate(IEnumerable fileDatas, CancellationToken cancel await AsyncParallel.ForEach(fileDatas, async fileData => { - //Logger.Write(this, LogLevel.Debug, "Reading meta data from file \"{0}\".", fileData.FileName); + Logger.Write(this, LogLevel.Debug, "Reading meta data from file \"{0}\".", fileData.FileName); try { var metaData = await metaDataSource.GetMetaData(fileData.FileName).ConfigureAwait(false); @@ -121,7 +121,7 @@ await AsyncParallel.ForEach(fileDatas, async fileData => } catch (Exception e) { - //Logger.Write(this, LogLevel.Debug, "Failed to write meta data entry from file \"{0}\" with name \"{1}\": {2}", fileData.FileName, metaDataItem.Name, e.Message); + Logger.Write(this, LogLevel.Debug, "Failed to write meta data entry from file \"{0}\" with name \"{1}\": {2}", fileData.FileName, metaDataItem.Name, e.Message); this.AddWarning(fileData, e.Message); } } @@ -139,7 +139,7 @@ await AsyncParallel.ForEach(fileDatas, async fileData => } catch (Exception e) { - //Logger.Write(this, LogLevel.Debug, "Failed to read meta data from file \"{0}\": {1}", fileData.FileName, e.Message); + Logger.Write(this, LogLevel.Debug, "Failed to read meta data from file \"{0}\": {1}", fileData.FileName, e.Message); this.AddWarning(fileData, e.Message); } }, cancellationToken, this.ParallelOptions).ConfigureAwait(false); diff --git a/FoxTunes.Core/MetaData/MetaDataProviderCache.cs b/FoxTunes.Core/MetaData/MetaDataProviderCache.cs index 178c0c137..f446d1d49 100644 --- a/FoxTunes.Core/MetaData/MetaDataProviderCache.cs +++ b/FoxTunes.Core/MetaData/MetaDataProviderCache.cs @@ -39,7 +39,7 @@ protected virtual Task OnSignal(object sender, ISignal signal) } else { - //Logger.Write(this, LogLevel.Debug, "Providers were updated, resetting cache."); + Logger.Write(this, LogLevel.Debug, "Providers were updated, resetting cache."); this.Providers = null; } break; @@ -93,7 +93,7 @@ protected virtual void OnDisposing() ~MetaDataProviderCache() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/MetaData/MetaDataSynchronizer.cs b/FoxTunes.Core/MetaData/MetaDataSynchronizer.cs index f9cf1ca73..a938de11e 100644 --- a/FoxTunes.Core/MetaData/MetaDataSynchronizer.cs +++ b/FoxTunes.Core/MetaData/MetaDataSynchronizer.cs @@ -67,7 +67,7 @@ private void Enable() this.Timer.AutoReset = false; this.Timer.Elapsed += this.OnElapsed; this.Timer.Start(); - //Logger.Write(this, LogLevel.Debug, "Background meta data synchronization enabled."); + Logger.Write(this, LogLevel.Debug, "Background meta data synchronization enabled."); } } } @@ -82,7 +82,7 @@ private void Disable() this.Timer.Elapsed -= this.OnElapsed; this.Timer.Dispose(); this.Timer = null; - //Logger.Write(this, LogLevel.Debug, "Background meta data synchronization disabled."); + Logger.Write(this, LogLevel.Debug, "Background meta data synchronization disabled."); } } } @@ -98,7 +98,7 @@ protected virtual async void OnElapsed(object sender, ElapsedEventArgs e) { if (global::FoxTunes.BackgroundTask.Active.Any()) { - //Logger.Write(this, LogLevel.Debug, "Other tasks are running, deferring."); + Logger.Write(this, LogLevel.Debug, "Other tasks are running, deferring."); } else { @@ -154,7 +154,7 @@ protected virtual void OnDisposing() ~MetaDataSynchronizer() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); this.Dispose(true); } } diff --git a/FoxTunes.Core/NotifyIcon.cs b/FoxTunes.Core/NotifyIcon.cs index c4b03ae4a..ded49a289 100644 --- a/FoxTunes.Core/NotifyIcon.cs +++ b/FoxTunes.Core/NotifyIcon.cs @@ -46,7 +46,7 @@ protected virtual void OnDisposing() ~NotifyIcon() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/OrderedEventArgs.cs b/FoxTunes.Core/OrderedEventArgs.cs index 6b9c30f8f..9e9601db4 100644 --- a/FoxTunes.Core/OrderedEventArgs.cs +++ b/FoxTunes.Core/OrderedEventArgs.cs @@ -13,7 +13,15 @@ public class OrderedEventArgs : EventArgs, IDisposable public const byte PRIORITY_LOW = 255; - protected OrderedEventArgs() + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + protected OrderedEventArgs() { this.Actions = new List>(); } @@ -56,7 +64,7 @@ protected virtual void OnDisposing() ~OrderedEventArgs() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/Playlist/PlaylistCache.cs b/FoxTunes.Core/Playlist/PlaylistCache.cs index 93b6bcd8b..c1dc159f6 100644 --- a/FoxTunes.Core/Playlist/PlaylistCache.cs +++ b/FoxTunes.Core/Playlist/PlaylistCache.cs @@ -62,13 +62,13 @@ protected virtual void OnPlaylistUpdated(PlaylistUpdatedSignalState state) { foreach (var playlist in state.Playlists) { - //Logger.Write(this, LogLevel.Debug, "Playlist \"{0}\" was updated, resetting cache.", playlist.Name); + Logger.Write(this, LogLevel.Debug, "Playlist \"{0}\" was updated, resetting cache.", playlist.Name); this.Reset(playlist); } } else { - //Logger.Write(this, LogLevel.Debug, "Playlists were updated, resetting cache."); + Logger.Write(this, LogLevel.Debug, "Playlists were updated, resetting cache."); this.Reset(); } } @@ -81,7 +81,7 @@ protected virtual void OnPlaylistColumnsUpdated(PlaylistColumnsUpdatedSignalStat } else { - //Logger.Write(this, LogLevel.Debug, "Columns were updated, resetting cache."); + Logger.Write(this, LogLevel.Debug, "Columns were updated, resetting cache."); this.Columns = null; } } @@ -222,7 +222,7 @@ protected virtual void OnDisposing() ~PlaylistCache() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/Playlist/PlaylistItemScriptComparer.cs b/FoxTunes.Core/Playlist/PlaylistItemScriptComparer.cs index dacb74dfc..28c7db191 100644 --- a/FoxTunes.Core/Playlist/PlaylistItemScriptComparer.cs +++ b/FoxTunes.Core/Playlist/PlaylistItemScriptComparer.cs @@ -88,7 +88,7 @@ protected virtual void OnDisposing() ~PlaylistItemScriptComparer() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/Playlist/PlaylistPopulator.cs b/FoxTunes.Core/Playlist/PlaylistPopulator.cs index 52f37ee72..fbf0d211a 100644 --- a/FoxTunes.Core/Playlist/PlaylistPopulator.cs +++ b/FoxTunes.Core/Playlist/PlaylistPopulator.cs @@ -61,7 +61,7 @@ public async Task Populate(Playlist playlist, IEnumerable paths, Cancell { return; } - //Logger.Write(this, LogLevel.Debug, "Adding file to playlist: {0}", fileName); + Logger.Write(this, LogLevel.Debug, "Adding file to playlist: {0}", fileName); var success = await this.AddPlaylistItem(playlist, writer, fileName).ConfigureAwait(false); if (success && this.ReportProgress) { @@ -71,7 +71,7 @@ public async Task Populate(Playlist playlist, IEnumerable paths, Cancell } else if (File.Exists(path)) { - //Logger.Write(this, LogLevel.Debug, "Adding file to playlist: {0}", path); + Logger.Write(this, LogLevel.Debug, "Adding file to playlist: {0}", path); var success = await this.AddPlaylistItem(playlist, writer, path).ConfigureAwait(false); if (success && this.ReportProgress) { @@ -88,10 +88,10 @@ protected virtual async Task AddPlaylistItem(Playlist playlist, PlaylistWr { if (!this.PlaybackManager.IsSupported(fileName)) { - //Logger.Write(this, LogLevel.Debug, "File is not supported: {0}", fileName); + Logger.Write(this, LogLevel.Debug, "File is not supported: {0}", fileName); return false; } - //Logger.Write(this, LogLevel.Trace, "Adding file to playlist: {0}", fileName); + Logger.Write(this, LogLevel.Trace, "Adding file to playlist: {0}", fileName); var playlistItem = new PlaylistItem() { Playlist_Id = playlist.Id, @@ -104,9 +104,9 @@ protected virtual async Task AddPlaylistItem(Playlist playlist, PlaylistWr this.Offset++; return true; } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Debug, "Failed to add file \"{0}\" to playlist: {0}", fileName, e.Message); + Logger.Write(this, LogLevel.Debug, "Failed to add file \"{0}\" to playlist: {0}", fileName, e.Message); return false; } } diff --git a/FoxTunes.Core/Tasks/BackgroundTask.cs b/FoxTunes.Core/Tasks/BackgroundTask.cs index e4269cd1d..e2bb65bb9 100644 --- a/FoxTunes.Core/Tasks/BackgroundTask.cs +++ b/FoxTunes.Core/Tasks/BackgroundTask.cs @@ -204,7 +204,7 @@ public override void InitializeComponent(ICore core) public virtual async Task Run() { - //Logger.Write(this, LogLevel.Debug, "Running background task."); + Logger.Write(this, LogLevel.Debug, "Running background task."); await this.OnStarted().ConfigureAwait(false); try { @@ -212,7 +212,7 @@ public virtual async Task Run() { await this.OnRun().ConfigureAwait(false); } - //Logger.Write(this, LogLevel.Debug, "Background task succeeded."); + Logger.Write(this, LogLevel.Debug, "Background task succeeded."); await this.OnCompleted().ConfigureAwait(false); return; } @@ -220,13 +220,13 @@ public virtual async Task Run() { foreach (var innerException in e.InnerExceptions) { - //Logger.Write(this, LogLevel.Error, "Background task failed: {0}", innerException.Message); + Logger.Write(this, LogLevel.Error, "Background task failed: {0}", innerException.Message); } this.Exception = e; } catch (Exception e) { - //Logger.Write(this, LogLevel.Error, "Background task failed: {0}", e.Message); + Logger.Write(this, LogLevel.Error, "Background task failed: {0}", e.Message); this.Exception = e; } await this.OnFaulted().ConfigureAwait(false); @@ -387,7 +387,7 @@ protected virtual void OnDisposing() ~BackgroundTask() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/Tasks/LibraryTaskBase.cs b/FoxTunes.Core/Tasks/LibraryTaskBase.cs index 076bcfad1..5f2a89a1d 100644 --- a/FoxTunes.Core/Tasks/LibraryTaskBase.cs +++ b/FoxTunes.Core/Tasks/LibraryTaskBase.cs @@ -67,11 +67,11 @@ protected virtual async Task AddRoots(IEnumerable paths) using (var transaction = this.Database.BeginTransaction(this.Database.PreferredIsolationLevel)) { var set = this.Database.Set(transaction); - //Logger.Write(this, LogLevel.Debug, "Clearing library roots."); + Logger.Write(this, LogLevel.Debug, "Clearing library roots."); await set.ClearAsync().ConfigureAwait(false); foreach (var path in roots) { - //Logger.Write(this, LogLevel.Debug, "Creating library root: {0}", path); + Logger.Write(this, LogLevel.Debug, "Creating library root: {0}", path); await set.AddAsync( set.Create().With( libraryRoot => libraryRoot.DirectoryName = path @@ -96,7 +96,7 @@ protected virtual async Task ClearRoots() using (var transaction = this.Database.BeginTransaction(this.Database.PreferredIsolationLevel)) { var set = this.Database.Set(transaction); - //Logger.Write(this, LogLevel.Debug, "Clearing library roots."); + Logger.Write(this, LogLevel.Debug, "Clearing library roots."); await set.ClearAsync().ConfigureAwait(false); transaction.Commit(); } diff --git a/FoxTunes.Core/Tasks/LoadOutputStreamTask.cs b/FoxTunes.Core/Tasks/LoadOutputStreamTask.cs index 3381bfde8..453c068b1 100644 --- a/FoxTunes.Core/Tasks/LoadOutputStreamTask.cs +++ b/FoxTunes.Core/Tasks/LoadOutputStreamTask.cs @@ -57,10 +57,10 @@ protected override async Task OnRun() { if (this.OutputStreamQueue.IsQueued(this.PlaylistItem)) { - //Logger.Write(this, LogLevel.Debug, "Play list item already exists in the queue: {0} => {1}", this.PlaylistItem.Id, this.PlaylistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Play list item already exists in the queue: {0} => {1}", this.PlaylistItem.Id, this.PlaylistItem.FileName); if (this.Immediate) { - //Logger.Write(this, LogLevel.Debug, "Immediate load was requested, de-queuing: {0} => {1}", this.PlaylistItem.Id, this.PlaylistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Immediate load was requested, de-queuing: {0} => {1}", this.PlaylistItem.Id, this.PlaylistItem.FileName); await this.OutputStreamQueue.Dequeue(this.PlaylistItem).ConfigureAwait(false); } return; @@ -69,7 +69,7 @@ protected override async Task OnRun() var outputStream = await this.Output.Load(this.PlaylistItem, this.Immediate).ConfigureAwait(false); if (outputStream == null) { - //Logger.Write(this, LogLevel.Warn, "Failed to load play list item into output stream: {0} => {1}", this.PlaylistItem.Id, this.PlaylistItem.FileName); + Logger.Write(this, LogLevel.Warn, "Failed to load play list item into output stream: {0} => {1}", this.PlaylistItem.Id, this.PlaylistItem.FileName); if (this.Immediate) { throw new InvalidOperationException(string.Format("Failed to load stream: {0}", this.PlaylistItem.FileName)); @@ -80,15 +80,15 @@ protected override async Task OnRun() return; } } - //Logger.Write(this, LogLevel.Debug, "Play list item loaded into output stream: {0} => {1}", this.PlaylistItem.Id, this.PlaylistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Play list item loaded into output stream: {0} => {1}", this.PlaylistItem.Id, this.PlaylistItem.FileName); await this.OutputStreamQueue.Enqueue(outputStream, this.Immediate).ConfigureAwait(false); if (this.Immediate) { - //Logger.Write(this, LogLevel.Debug, "Immediate load was requested, output stream was automatically de-queued: {0} => {1}", this.PlaylistItem.Id, this.PlaylistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Immediate load was requested, output stream was automatically de-queued: {0} => {1}", this.PlaylistItem.Id, this.PlaylistItem.FileName); } else { - //Logger.Write(this, LogLevel.Debug, "Output stream added to the queue: {0} => {1}", this.PlaylistItem.Id, this.PlaylistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Output stream added to the queue: {0} => {1}", this.PlaylistItem.Id, this.PlaylistItem.FileName); } } diff --git a/FoxTunes.Core/Tasks/PlaylistTaskBase.cs b/FoxTunes.Core/Tasks/PlaylistTaskBase.cs index f82a39041..e91967117 100644 --- a/FoxTunes.Core/Tasks/PlaylistTaskBase.cs +++ b/FoxTunes.Core/Tasks/PlaylistTaskBase.cs @@ -173,7 +173,7 @@ protected virtual async Task AddPlaylistItems(IEnumerable playlist var position = 0; foreach (var playlistItem in PlaylistItem.Clone(playlistItems)) { - //Logger.Write(this, LogLevel.Debug, "Adding file to playlist: {0}", playlistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Adding file to playlist: {0}", playlistItem.FileName); playlistItem.Playlist_Id = this.Playlist.Id; playlistItem.Sequence = this.Sequence + position; playlistItem.Status = PlaylistItemStatus.Import; @@ -228,7 +228,7 @@ protected virtual async Task RemoveItems(IEnumerable playlistItems protected virtual async Task RemoveItems(PlaylistItemStatus status) { - //Logger.Write(this, LogLevel.Debug, "Removing playlist items."); + Logger.Write(this, LogLevel.Debug, "Removing playlist items."); using (var task = new SingletonReentrantTask(this, ComponentSlots.Database, SingletonReentrantTask.PRIORITY_HIGH, async cancellationToken => { using (var transaction = this.Database.BeginTransaction(this.Database.PreferredIsolationLevel)) @@ -249,14 +249,14 @@ protected virtual async Task ShiftItems(QueryOperator @operator, int at, int by) //Nothing to do. return; } - //Logger.Write( - // this, - // LogLevel.Debug, - // "Shifting playlist items at position {0} {1} by offset {2}.", - // Enum.GetName(typeof(QueryOperator), @operator), - // at, - // by - //); + Logger.Write( + this, + LogLevel.Debug, + "Shifting playlist items at position {0} {1} by offset {2}.", + Enum.GetName(typeof(QueryOperator), @operator), + at, + by + ); var query = this.Database.QueryFactory.Build(); var playlistId = this.Database.Tables.PlaylistItem.Column("Playlist_Id"); var sequence = this.Database.Tables.PlaylistItem.Column("Sequence"); @@ -295,7 +295,7 @@ await this.Database.ExecuteAsync(query, (parameters, phase) => protected virtual async Task SequenceItems() { - //Logger.Write(this, LogLevel.Debug, "Sequencing playlist items."); + Logger.Write(this, LogLevel.Debug, "Sequencing playlist items."); using (var transaction = this.Database.BeginTransaction(this.Database.PreferredIsolationLevel)) { var query = this.Database.Queries.SequencePlaylistItems(this.Sort.Value); @@ -315,7 +315,7 @@ await this.Database.ExecuteAsync(query, (parameters, phase) => protected virtual Task SortItems(PlaylistColumn playlistColumn, bool descending) { - //Logger.Write(this, LogLevel.Debug, "Sorting playlist {0} by column {1}.", this.Playlist.Name, playlistColumn.Name); + Logger.Write(this, LogLevel.Debug, "Sorting playlist {0} by column {1}.", this.Playlist.Name, playlistColumn.Name); switch (playlistColumn.Type) { case PlaylistColumnType.Script: @@ -361,7 +361,7 @@ protected virtual async Task SortItemsByTag(string tag, bool descending) protected virtual async Task SortItems(IComparer comparer, bool descending) { - //Logger.Write(this, LogLevel.Debug, "Sorting playlist using comparer: \"{0}\"", comparer.GetType().Name); + Logger.Write(this, LogLevel.Debug, "Sorting playlist using comparer: \"{0}\"", comparer.GetType().Name); using (var task = new SingletonReentrantTask(this, ComponentSlots.Database, SingletonReentrantTask.PRIORITY_HIGH, async cancellationToken => { using (var transaction = this.Database.BeginTransaction(this.Database.PreferredIsolationLevel)) @@ -371,7 +371,7 @@ protected virtual async Task SortItems(IComparer comparer, bool de Array.Sort(playlistItems, comparer); if (descending) { - //Logger.Write(this, LogLevel.Debug, "Sort is descending, reversing sequence."); + Logger.Write(this, LogLevel.Debug, "Sort is descending, reversing sequence."); Array.Reverse(playlistItems); } for (var a = 0; a < playlistItems.Length; a++) @@ -399,7 +399,7 @@ await EntityHelper.Create( protected virtual async Task SetPlaylistItemsStatus(PlaylistItemStatus status) { - //Logger.Write(this, LogLevel.Debug, "Setting playlist status: {0}", Enum.GetName(typeof(LibraryItemStatus), LibraryItemStatus.None)); + Logger.Write(this, LogLevel.Debug, "Setting playlist status: {0}", Enum.GetName(typeof(LibraryItemStatus), LibraryItemStatus.None)); var query = this.Database.QueryFactory.Build(); query.Update.SetTable(this.Database.Tables.PlaylistItem); query.Update.AddColumn(this.Database.Tables.PlaylistItem.Column("Status")); diff --git a/FoxTunes.Core/Tasks/RefreshLibraryMetaDataTask.cs b/FoxTunes.Core/Tasks/RefreshLibraryMetaDataTask.cs index a2b548904..b9e031efe 100644 --- a/FoxTunes.Core/Tasks/RefreshLibraryMetaDataTask.cs +++ b/FoxTunes.Core/Tasks/RefreshLibraryMetaDataTask.cs @@ -79,7 +79,7 @@ protected override async Task OnRun() if (!File.Exists(libraryItem.FileName)) { - //Logger.Write(this, LogLevel.Debug, "File \"{0}\" no longer exists: Cannot refresh.", libraryItem.FileName); + Logger.Write(this, LogLevel.Debug, "File \"{0}\" no longer exists: Cannot refresh.", libraryItem.FileName); continue; } diff --git a/FoxTunes.Core/Tasks/RefreshPlaylistMetaDataTask.cs b/FoxTunes.Core/Tasks/RefreshPlaylistMetaDataTask.cs index d9823bdce..74ec2fa7b 100644 --- a/FoxTunes.Core/Tasks/RefreshPlaylistMetaDataTask.cs +++ b/FoxTunes.Core/Tasks/RefreshPlaylistMetaDataTask.cs @@ -83,7 +83,7 @@ protected override async Task OnRun() if (!File.Exists(playlistItem.FileName)) { - //Logger.Write(this, LogLevel.Debug, "File \"{0}\" no longer exists: Cannot refresh.", playlistItem.FileName); + Logger.Write(this, LogLevel.Debug, "File \"{0}\" no longer exists: Cannot refresh.", playlistItem.FileName); continue; } diff --git a/FoxTunes.Core/Tasks/RescanLibraryTask.cs b/FoxTunes.Core/Tasks/RescanLibraryTask.cs index a4426e05b..e9415a2d6 100644 --- a/FoxTunes.Core/Tasks/RescanLibraryTask.cs +++ b/FoxTunes.Core/Tasks/RescanLibraryTask.cs @@ -73,7 +73,7 @@ protected virtual async Task RescanLibrary(IEnumerable paths) } if (!paths.Any(path => libraryItem.FileName.StartsWith(path))) { - //Logger.Write(this, LogLevel.Debug, "Removing unparented file: {0} => {1}", libraryItem.Id, libraryItem.FileName); + Logger.Write(this, LogLevel.Debug, "Removing unparented file: {0} => {1}", libraryItem.Id, libraryItem.FileName); return true; } if (!string.IsNullOrEmpty(Path.GetPathRoot(libraryItem.FileName))) @@ -81,12 +81,12 @@ protected virtual async Task RescanLibrary(IEnumerable paths) var file = new FileInfo(libraryItem.FileName); if (!file.Exists) { - //Logger.Write(this, LogLevel.Debug, "Removing dead file: {0} => {1}", libraryItem.Id, libraryItem.FileName); + Logger.Write(this, LogLevel.Debug, "Removing dead file: {0} => {1}", libraryItem.Id, libraryItem.FileName); return true; } if (file.LastWriteTimeUtc > libraryItem.GetImportDate()) { - //Logger.Write(this, LogLevel.Debug, "Refreshing modified file: {0} => {1}", libraryItem.Id, libraryItem.FileName); + Logger.Write(this, LogLevel.Debug, "Refreshing modified file: {0} => {1}", libraryItem.Id, libraryItem.FileName); return true; } } diff --git a/FoxTunes.Core/Tasks/SynchronizeLibraryMetaDataTask.cs b/FoxTunes.Core/Tasks/SynchronizeLibraryMetaDataTask.cs index d3ea70e0b..a36342259 100644 --- a/FoxTunes.Core/Tasks/SynchronizeLibraryMetaDataTask.cs +++ b/FoxTunes.Core/Tasks/SynchronizeLibraryMetaDataTask.cs @@ -51,14 +51,14 @@ protected override async Task OnRun() { if (MetaDataBehaviourConfiguration.GetWriteBehaviour(this.Write.Value) == WriteBehaviour.None) { - //Logger.Write(this, LogLevel.Debug, "Meta data writing is disabled."); + Logger.Write(this, LogLevel.Debug, "Meta data writing is disabled."); return; } foreach (var libraryItem in this.LibraryItems) { if (this.Output.IsLoaded(libraryItem.FileName)) { - //Logger.Write(this, LogLevel.Debug, "File \"{0}\" could not be written, the update will be retried: The file is in use.", libraryItem.FileName); + Logger.Write(this, LogLevel.Debug, "File \"{0}\" could not be written, the update will be retried: The file is in use.", libraryItem.FileName); this.AddError(libraryItem, string.Format("File \"{0}\" could not be written, the update will be retried: The file is in use.", libraryItem.FileName)); await this.Schedule(libraryItem).ConfigureAwait(false); continue; @@ -69,13 +69,13 @@ protected override async Task OnRun() } catch (IOException e) { - //Logger.Write(this, LogLevel.Debug, "File \"{0}\" could not be written, the update will be retried: {1}", libraryItem.FileName, e.Message); + Logger.Write(this, LogLevel.Debug, "File \"{0}\" could not be written, the update will be retried: {1}", libraryItem.FileName, e.Message); this.AddError(libraryItem, string.Format("File \"{0}\" could not be written, the update will be retried: {1}", libraryItem.FileName, e.Message)); await this.Schedule(libraryItem).ConfigureAwait(false); } catch (Exception e) { - //Logger.Write(this, LogLevel.Debug, "File \"{0}\" could not be written: {1}", libraryItem.FileName, e.Message); + Logger.Write(this, LogLevel.Debug, "File \"{0}\" could not be written: {1}", libraryItem.FileName, e.Message); this.AddError(libraryItem, string.Format("File \"{0}\" could not be written: {1}", libraryItem.FileName, e.Message)); await this.Deschedule(libraryItem).ConfigureAwait(false); } @@ -86,13 +86,13 @@ protected virtual async Task Synchronize(LibraryItem libraryItem) { if (!FileSystemHelper.IsLocalPath(libraryItem.FileName)) { - //Logger.Write(this, LogLevel.Debug, "File \"{0}\" is not a local file: Cannot update.", libraryItem.FileName); + Logger.Write(this, LogLevel.Debug, "File \"{0}\" is not a local file: Cannot update.", libraryItem.FileName); return; } if (!File.Exists(libraryItem.FileName)) { - //Logger.Write(this, LogLevel.Debug, "File \"{0}\" no longer exists: Cannot update.", libraryItem.FileName); + Logger.Write(this, LogLevel.Debug, "File \"{0}\" no longer exists: Cannot update.", libraryItem.FileName); return; } diff --git a/FoxTunes.Core/Tasks/SynchronizePlaylistMetaDataTask.cs b/FoxTunes.Core/Tasks/SynchronizePlaylistMetaDataTask.cs index 60567967d..79e7adcd9 100644 --- a/FoxTunes.Core/Tasks/SynchronizePlaylistMetaDataTask.cs +++ b/FoxTunes.Core/Tasks/SynchronizePlaylistMetaDataTask.cs @@ -52,14 +52,14 @@ protected override async Task OnRun() { if (MetaDataBehaviourConfiguration.GetWriteBehaviour(this.Write.Value) == WriteBehaviour.None) { - //Logger.Write(this, LogLevel.Debug, "Meta data writing is disabled."); + Logger.Write(this, LogLevel.Debug, "Meta data writing is disabled."); return; } foreach (var playlistItem in this.PlaylistItems) { if (this.Output.IsLoaded(playlistItem.FileName)) { - //Logger.Write(this, LogLevel.Debug, "File \"{0}\" could not be written, the update will be retried: The file is in use.", playlistItem.FileName); + Logger.Write(this, LogLevel.Debug, "File \"{0}\" could not be written, the update will be retried: The file is in use.", playlistItem.FileName); this.AddError(playlistItem, string.Format("File \"{0}\" could not be written, the update will be retried: The file is in use.", playlistItem.FileName)); await this.Schedule(playlistItem).ConfigureAwait(false); continue; @@ -70,13 +70,13 @@ protected override async Task OnRun() } catch (IOException e) { - //Logger.Write(this, LogLevel.Debug, "File \"{0}\" could not be written, the update will be retried: {1}", playlistItem.FileName, e.Message); + Logger.Write(this, LogLevel.Debug, "File \"{0}\" could not be written, the update will be retried: {1}", playlistItem.FileName, e.Message); this.AddError(playlistItem, string.Format("File \"{0}\" could not be written, the update will be retried: {1}", playlistItem.FileName, e.Message)); await this.Schedule(playlistItem).ConfigureAwait(false); } catch (Exception e) { - //Logger.Write(this, LogLevel.Debug, "File \"{0}\" could not be written: {1}", playlistItem.FileName, e.Message); + Logger.Write(this, LogLevel.Debug, "File \"{0}\" could not be written: {1}", playlistItem.FileName, e.Message); this.AddError(playlistItem, string.Format("File \"{0}\" could not be written: {1}", playlistItem.FileName, e.Message)); } } @@ -86,13 +86,13 @@ protected virtual async Task Synchronize(PlaylistItem playlistItem) { if (!FileSystemHelper.IsLocalPath(playlistItem.FileName)) { - //Logger.Write(this, LogLevel.Debug, "File \"{0}\" is not a local file: Cannot update.", playlistItem.FileName); + Logger.Write(this, LogLevel.Debug, "File \"{0}\" is not a local file: Cannot update.", playlistItem.FileName); return; } if (!File.Exists(playlistItem.FileName)) { - //Logger.Write(this, LogLevel.Debug, "File \"{0}\" no longer exists: Cannot update.", playlistItem.FileName); + Logger.Write(this, LogLevel.Debug, "File \"{0}\" no longer exists: Cannot update.", playlistItem.FileName); return; } diff --git a/FoxTunes.Core/Tasks/UnloadOutputStreamTask.cs b/FoxTunes.Core/Tasks/UnloadOutputStreamTask.cs index cc3ba79d2..1d3a35e37 100644 --- a/FoxTunes.Core/Tasks/UnloadOutputStreamTask.cs +++ b/FoxTunes.Core/Tasks/UnloadOutputStreamTask.cs @@ -30,7 +30,7 @@ protected override Task OnRun() { if (this.OutputStream != null && !this.OutputStream.IsDisposed) { - //Logger.Write(this, LogLevel.Debug, "Unloading output stream: {0} => {1}", this.OutputStream.Id, this.OutputStream.FileName); + Logger.Write(this, LogLevel.Debug, "Unloading output stream: {0} => {1}", this.OutputStream.Id, this.OutputStream.FileName); return this.Output.Unload(this.OutputStream); } #if NET40 diff --git a/FoxTunes.Core/Utilities/AsyncDebouncer.cs b/FoxTunes.Core/Utilities/AsyncDebouncer.cs index 83dd6a6e4..9a06ea771 100644 --- a/FoxTunes.Core/Utilities/AsyncDebouncer.cs +++ b/FoxTunes.Core/Utilities/AsyncDebouncer.cs @@ -11,7 +11,15 @@ namespace FoxTunes { public class AsyncDebouncer : IDisposable { - public static readonly object SyncRoot = new object(); + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public static readonly object SyncRoot = new object(); private AsyncDebouncer() { @@ -99,14 +107,14 @@ protected virtual void OnElapsed(object sender, ElapsedEventArgs e) var exception = task.Exception.Unwrap(); if (!pair.Value.TrySetException(exception)) { - //Logger.Write(typeof(AsyncDebouncer), LogLevel.Warn, "Failed to propagate exception: {0}", exception.Message); + Logger.Write(typeof(AsyncDebouncer), LogLevel.Warn, "Failed to propagate exception: {0}", exception.Message); } } else { if (!pair.Value.TrySetResult(true)) { - //Logger.Write(typeof(AsyncDebouncer), LogLevel.Warn, "Failed to propagate result."); + Logger.Write(typeof(AsyncDebouncer), LogLevel.Warn, "Failed to propagate result."); } } }); @@ -163,7 +171,7 @@ protected virtual void OnDisposing() ~AsyncDebouncer() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/Utilities/Debouncer.cs b/FoxTunes.Core/Utilities/Debouncer.cs index 77f46f6b7..6e480793d 100644 --- a/FoxTunes.Core/Utilities/Debouncer.cs +++ b/FoxTunes.Core/Utilities/Debouncer.cs @@ -8,7 +8,15 @@ namespace FoxTunes { public class Debouncer : IDisposable { - public static readonly object SyncRoot = new object(); + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public static readonly object SyncRoot = new object(); private Debouncer() { @@ -115,7 +123,7 @@ protected virtual void OnDisposing() ~Debouncer() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/Utilities/FileSystemHelper.cs b/FoxTunes.Core/Utilities/FileSystemHelper.cs index e0880887d..cdf95bed0 100644 --- a/FoxTunes.Core/Utilities/FileSystemHelper.cs +++ b/FoxTunes.Core/Utilities/FileSystemHelper.cs @@ -12,6 +12,14 @@ public static class FileSystemHelper { const int CACHE_SIZE = 128; + private static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + public static HashSet IgnoredNames = new HashSet(StringComparer.OrdinalIgnoreCase) { "FoxTunes.Launcher.exe", @@ -135,9 +143,9 @@ public static bool IsLocalPath(string fileName) //Some kind of abstraction. return false; } - catch + catch (Exception e) { - //Logger.Write(typeof(FileSystemHelper), LogLevel.Warn, "Failed to determine whether \"{0}\" is a local path: {1}", fileName, e.Message); + Logger.Write(typeof(FileSystemHelper), LogLevel.Warn, "Failed to determine whether \"{0}\" is a local path: {1}", fileName, e.Message); return false; } } diff --git a/FoxTunes.Core/Utilities/PLSHelper.cs b/FoxTunes.Core/Utilities/PLSHelper.cs index 8b24e9e9d..0c98a9f03 100644 --- a/FoxTunes.Core/Utilities/PLSHelper.cs +++ b/FoxTunes.Core/Utilities/PLSHelper.cs @@ -137,7 +137,15 @@ public static Reader FromFile(string fileName) public class Writer : IDisposable { - public Writer(IEnumerable content, StreamWriter writer) + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public Writer(IEnumerable content, StreamWriter writer) { this.Content = content; this.StreamWriter = writer; @@ -218,7 +226,7 @@ protected virtual void OnDisposing() ~Writer() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); @@ -270,9 +278,9 @@ public async Task Create(string fileName) var metaData = await metaDataSource.GetMetaData(playlistItem.FileName).ConfigureAwait(false); playlistItem.AddOrUpdate(metaData, out names); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Debug, "Failed to read meta data from file \"{0}\": {1}", fileName, e.Message); + Logger.Write(this, LogLevel.Debug, "Failed to read meta data from file \"{0}\": {1}", fileName, e.Message); } } } diff --git a/FoxTunes.Core/Utilities/PendingQueue.cs b/FoxTunes.Core/Utilities/PendingQueue.cs index 57ef4f95b..00b7b0c9d 100644 --- a/FoxTunes.Core/Utilities/PendingQueue.cs +++ b/FoxTunes.Core/Utilities/PendingQueue.cs @@ -7,7 +7,15 @@ namespace FoxTunes { public class PendingQueue : IDisposable { - public static readonly object SyncRoot = new object(); + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public static readonly object SyncRoot = new object(); private PendingQueue() { @@ -111,7 +119,7 @@ protected virtual void OnDisposing() ~PendingQueue() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/Utilities/PopulatorBase.cs b/FoxTunes.Core/Utilities/PopulatorBase.cs index 1122473e2..641e7c9f5 100644 --- a/FoxTunes.Core/Utilities/PopulatorBase.cs +++ b/FoxTunes.Core/Utilities/PopulatorBase.cs @@ -243,7 +243,7 @@ protected virtual void OnDisposing() ~PopulatorBase() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/Utilities/RateLimiter.cs b/FoxTunes.Core/Utilities/RateLimiter.cs index cfdbd098e..587d20055 100644 --- a/FoxTunes.Core/Utilities/RateLimiter.cs +++ b/FoxTunes.Core/Utilities/RateLimiter.cs @@ -7,7 +7,15 @@ namespace FoxTunes { public class RateLimiter : IDisposable { - public RateLimiter(int interval) + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public RateLimiter(int interval) { this.Interval = interval; this.WaitHandle = new AutoResetEvent(true); @@ -84,7 +92,7 @@ protected virtual void OnDisposing() ~RateLimiter() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/Utilities/RegistryMonitor.cs b/FoxTunes.Core/Utilities/RegistryMonitor.cs index 66a55de67..159ce639f 100644 --- a/FoxTunes.Core/Utilities/RegistryMonitor.cs +++ b/FoxTunes.Core/Utilities/RegistryMonitor.cs @@ -182,7 +182,7 @@ protected virtual void OnDisposing() ~RegistryMonitor() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/Utilities/SingletonReentrantTask.cs b/FoxTunes.Core/Utilities/SingletonReentrantTask.cs index a2dc83981..0d80d89e4 100644 --- a/FoxTunes.Core/Utilities/SingletonReentrantTask.cs +++ b/FoxTunes.Core/Utilities/SingletonReentrantTask.cs @@ -58,7 +58,7 @@ public SingletonReentrantTask(ICancellable cancellable, string id, int timeout, public virtual async Task Run() { - //Logger.Write(this, LogLevel.Trace, "Begin executing task: {0} with priority {1}.", this.Instance.Id, this.Priority); + Logger.Write(this, LogLevel.Trace, "Begin executing task: {0} with priority {1}.", this.Instance.Id, this.Priority); do { #if NET40 @@ -67,38 +67,38 @@ public virtual async Task Run() if (!await this.Instance.Semaphore.WaitAsync(this.Timeout).ConfigureAwait(false)) #endif { - //Logger.Write(this, LogLevel.Trace, "Failed to acquire lock after {0}ms", this.Timeout); + Logger.Write(this, LogLevel.Trace, "Failed to acquire lock after {0}ms", this.Timeout); if (object.ReferenceEquals(this, this.Instance.Instances.OrderBy(instance => instance.Priority).FirstOrDefault())) { - //Logger.Write(this, LogLevel.Trace, "Cancelling other tasks."); + Logger.Write(this, LogLevel.Trace, "Cancelling other tasks."); this.Instance.CancellationToken.Cancel(); } else { - //Logger.Write(this, LogLevel.Trace, "Yielding to other tasks."); + Logger.Write(this, LogLevel.Trace, "Yielding to other tasks."); } continue; } - //Logger.Write(this, LogLevel.Trace, "Acquired lock."); + Logger.Write(this, LogLevel.Trace, "Acquired lock."); var success = true; try { if (this.Cancellable.IsCancellationRequested) { - //Logger.Write(this, LogLevel.Trace, "Task was cancelled."); + Logger.Write(this, LogLevel.Trace, "Task was cancelled."); return; } this.Instance.CancellationToken.Reset(); await this.Factory(this.Instance.CancellationToken).ConfigureAwait(false); if (this.Instance.CancellationToken.IsCancellationRequested) { - //Logger.Write(this, LogLevel.Trace, "Task was cancelled."); + Logger.Write(this, LogLevel.Trace, "Task was cancelled."); success = false; } } finally { - //Logger.Write(this, LogLevel.Trace, "Releasing lock."); + Logger.Write(this, LogLevel.Trace, "Releasing lock."); this.Instance.Semaphore.Release(); } if (success) @@ -107,7 +107,7 @@ public virtual async Task Run() } else { - //Logger.Write(this, LogLevel.Trace, "Retrying in {0}ms", this.Timeout); + Logger.Write(this, LogLevel.Trace, "Retrying in {0}ms", this.Timeout); #if NET40 await TaskEx.Delay(this.Timeout).ConfigureAwait(false); #else @@ -115,7 +115,7 @@ public virtual async Task Run() #endif } } while (true); - //Logger.Write(this, LogLevel.Trace, "Task was executed successfully."); + Logger.Write(this, LogLevel.Trace, "Task was executed successfully."); } protected virtual void OnCancellationRequested(object sender, EventArgs e) @@ -156,7 +156,7 @@ protected virtual void OnDisposing() ~SingletonReentrantTask() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Core/Utilities/TrackingThreadLocal.cs b/FoxTunes.Core/Utilities/TrackingThreadLocal.cs index 14966590a..42c757a9b 100644 --- a/FoxTunes.Core/Utilities/TrackingThreadLocal.cs +++ b/FoxTunes.Core/Utilities/TrackingThreadLocal.cs @@ -9,7 +9,15 @@ namespace FoxTunes { public class TrackingThreadLocal : IDisposable { - public TrackingThreadLocal() + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public TrackingThreadLocal() { this.ThreadLocal = new ThreadLocal(); this.Values = new ConcurrentBag(); @@ -65,7 +73,7 @@ protected virtual void OnDisposing() ~TrackingThreadLocal() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.DB/Database.cs b/FoxTunes.DB/Database.cs index 9122a2d80..ad957aa07 100644 --- a/FoxTunes.DB/Database.cs +++ b/FoxTunes.DB/Database.cs @@ -8,7 +8,16 @@ namespace FoxTunes { public abstract class Database : global::FoxDb.Database, IDatabaseComponent { - public Database(IProvider provider) : base(provider) + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public Database(IProvider provider) + : base(provider) { } diff --git a/FoxTunes.DB/DatabaseChecksum.cs b/FoxTunes.DB/DatabaseChecksum.cs index c2b0ff822..f7796da51 100644 --- a/FoxTunes.DB/DatabaseChecksum.cs +++ b/FoxTunes.DB/DatabaseChecksum.cs @@ -35,9 +35,9 @@ public string Get(IDatabase database) } } } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to retrieve checksum from database: {0}", e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to retrieve checksum from database: {0}", e.Message); return null; } } @@ -63,7 +63,7 @@ public bool Validate(IDatabase database, string setup) var actual = this.Get(database); if (!string.Equals(expected, actual, StringComparison.OrdinalIgnoreCase)) { - //Logger.Write(this, LogLevel.Warn, "Database checksum does not match. Expected \"{0}\" but found \"{1}\".", expected, actual); + Logger.Write(this, LogLevel.Warn, "Database checksum does not match. Expected \"{0}\" but found \"{1}\".", expected, actual); return false; } return true; diff --git a/FoxTunes.DB/Filter/FilterParser.cs b/FoxTunes.DB/Filter/FilterParser.cs index 95cc9574c..ce3ac9321 100644 --- a/FoxTunes.DB/Filter/FilterParser.cs +++ b/FoxTunes.DB/Filter/FilterParser.cs @@ -47,7 +47,7 @@ public bool TryParse(string filter, out IFilterParserResult result) } if (!success && !string.IsNullOrWhiteSpace(filter)) { - //Logger.Write(this, LogLevel.Warn, "Failed to parse filter: {0}", filter.Trim()); + Logger.Write(this, LogLevel.Warn, "Failed to parse filter: {0}", filter.Trim()); } if (groups.Any()) { diff --git a/FoxTunes.DB/Sort/SortParser.cs b/FoxTunes.DB/Sort/SortParser.cs index 1f1523a9d..ac4cd9441 100644 --- a/FoxTunes.DB/Sort/SortParser.cs +++ b/FoxTunes.DB/Sort/SortParser.cs @@ -49,7 +49,7 @@ public bool TryParse(string sort, out ISortParserResult result) } if (!success) { - //Logger.Write(this, LogLevel.Warn, "Failed to parse sort: {0}", line.Trim()); + Logger.Write(this, LogLevel.Warn, "Failed to parse sort: {0}", line.Trim()); } } if (expressions.Any()) diff --git a/FoxTunes.Encoder.Bass/Apple/AppleLosslessEncoderSettings.cs b/FoxTunes.Encoder.Bass/Apple/AppleLosslessEncoderSettings.cs index 6a6330175..62b49d70a 100644 --- a/FoxTunes.Encoder.Bass/Apple/AppleLosslessEncoderSettings.cs +++ b/FoxTunes.Encoder.Bass/Apple/AppleLosslessEncoderSettings.cs @@ -81,12 +81,12 @@ public override int GetDepth(EncoderItem encoderItem, IBassStream stream) var depth = base.GetDepth(encoderItem, stream); if (depth < DEPTH_16) { - //Logger.Write(this.GetType(), LogLevel.Warn, "Requsted bit depth {0} is invalid, using minimum: 16 bit", depth); + Logger.Write(this.GetType(), LogLevel.Warn, "Requsted bit depth {0} is invalid, using minimum: 16 bit", depth); return DEPTH_16; } if (depth > DEPTH_32) { - //Logger.Write(this.GetType(), LogLevel.Warn, "Requsted bit depth {0} is invalid, using maximum: 32 bit", depth); + Logger.Write(this.GetType(), LogLevel.Warn, "Requsted bit depth {0} is invalid, using maximum: 32 bit", depth); return DEPTH_32; } return depth; diff --git a/FoxTunes.Encoder.Bass/BassEncoder.cs b/FoxTunes.Encoder.Bass/BassEncoder.cs index 9c182d15a..953c8b343 100644 --- a/FoxTunes.Encoder.Bass/BassEncoder.cs +++ b/FoxTunes.Encoder.Bass/BassEncoder.cs @@ -31,11 +31,11 @@ public void Encode() { if (this.Threads > 1) { - //Logger.Write(this, LogLevel.Debug, "Beginning parallel encoding with {0} threads.", this.Threads); + Logger.Write(this, LogLevel.Debug, "Beginning parallel encoding with {0} threads.", this.Threads); } else { - //Logger.Write(this, LogLevel.Debug, "Beginning single threaded encoding."); + Logger.Write(this, LogLevel.Debug, "Beginning single threaded encoding."); } var parallelOptions = new ParallelOptions() { @@ -48,53 +48,53 @@ public void Encode() var settings = ComponentRegistry.Instance.GetComponent().CreateSettings(encoderItem.Profile); if (this.CancellationToken.IsCancellationRequested) { - //Logger.Write(this, LogLevel.Warn, "Skipping file \"{0}\" due to cancellation.", encoderItem.InputFileName); + Logger.Write(this, LogLevel.Warn, "Skipping file \"{0}\" due to cancellation.", encoderItem.InputFileName); encoderItem.Status = EncoderItemStatus.Cancelled; return; } if (!this.CheckInput(encoderItem.InputFileName)) { - //Logger.Write(this, LogLevel.Warn, "Skipping file \"{0}\" due to output file \"{1}\" does not exist.", encoderItem.InputFileName, encoderItem.OutputFileName); + Logger.Write(this, LogLevel.Warn, "Skipping file \"{0}\" due to output file \"{1}\" does not exist.", encoderItem.InputFileName, encoderItem.OutputFileName); encoderItem.Status = EncoderItemStatus.Failed; encoderItem.AddError(string.Format("Input file \"{0}\" does not exist.", encoderItem.OutputFileName)); return; } if (!this.CheckOutput(encoderItem.OutputFileName)) { - //Logger.Write(this, LogLevel.Warn, "Skipping file \"{0}\": Output file \"{1}\" cannot be written.", encoderItem.InputFileName, encoderItem.OutputFileName); + Logger.Write(this, LogLevel.Warn, "Skipping file \"{0}\": Output file \"{1}\" cannot be written.", encoderItem.InputFileName, encoderItem.OutputFileName); encoderItem.Status = EncoderItemStatus.Failed; encoderItem.AddError(string.Format("Output file \"{0}\" cannot be written.", encoderItem.OutputFileName)); return; } if (File.Exists(encoderItem.OutputFileName)) { - //Logger.Write(this, LogLevel.Warn, "Skipping file \"{0}\": Output file \"{1}\" already exists.", encoderItem.InputFileName, encoderItem.OutputFileName); + Logger.Write(this, LogLevel.Warn, "Skipping file \"{0}\": Output file \"{1}\" already exists.", encoderItem.InputFileName, encoderItem.OutputFileName); encoderItem.Status = EncoderItemStatus.Failed; encoderItem.AddError(string.Format("Output file \"{0}\" already exists.", encoderItem.OutputFileName)); return; } - //Logger.Write(this, LogLevel.Debug, "Beginning encoding file \"{0}\" to output file \"{1}\".", encoderItem.InputFileName, encoderItem.OutputFileName); + Logger.Write(this, LogLevel.Debug, "Beginning encoding file \"{0}\" to output file \"{1}\".", encoderItem.InputFileName, encoderItem.OutputFileName); encoderItem.Progress = EncoderItem.PROGRESS_NONE; encoderItem.Status = EncoderItemStatus.Processing; this.Encode(encoderItem, settings); if (encoderItem.Status == EncoderItemStatus.Complete) { - //Logger.Write(this, LogLevel.Debug, "Encoding file \"{0}\" to output file \"{1}\" completed successfully.", encoderItem.InputFileName, encoderItem.OutputFileName); + Logger.Write(this, LogLevel.Debug, "Encoding file \"{0}\" to output file \"{1}\" completed successfully.", encoderItem.InputFileName, encoderItem.OutputFileName); } else { - //Logger.Write(this, LogLevel.Warn, "Encoding file \"{0}\" failed: Unknown error.", encoderItem.InputFileName); + Logger.Write(this, LogLevel.Warn, "Encoding file \"{0}\" failed: Unknown error.", encoderItem.InputFileName); } } catch (OperationCanceledException) { - //Logger.Write(this, LogLevel.Warn, "Skipping file \"{0}\" due to cancellation.", encoderItem.InputFileName); + Logger.Write(this, LogLevel.Warn, "Skipping file \"{0}\" due to cancellation.", encoderItem.InputFileName); encoderItem.Status = EncoderItemStatus.Cancelled; return; } catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Encoding file \"{0}\" failed: {1}", encoderItem.InputFileName, e.Message); + Logger.Write(this, LogLevel.Warn, "Encoding file \"{0}\" failed: {1}", encoderItem.InputFileName, e.Message); encoderItem.Status = EncoderItemStatus.Failed; encoderItem.AddError(e.Message); } @@ -103,7 +103,7 @@ public void Encode() encoderItem.Progress = EncoderItem.PROGRESS_COMPLETE; } }); - //Logger.Write(this, LogLevel.Debug, "Encoding completed successfully."); + Logger.Write(this, LogLevel.Debug, "Encoding completed successfully."); } protected virtual void Encode(EncoderItem encoderItem, IBassEncoderSettings settings) @@ -111,21 +111,21 @@ protected virtual void Encode(EncoderItem encoderItem, IBassEncoderSettings sett var flags = BassFlags.Decode; if (this.ShouldDecodeFloat(encoderItem, settings)) { - //Logger.Write(this, LogLevel.Debug, "Decoding file \"{0}\" in high quality mode (32 bit floating point).", encoderItem.InputFileName); + Logger.Write(this, LogLevel.Debug, "Decoding file \"{0}\" in high quality mode (32 bit floating point).", encoderItem.InputFileName); flags |= BassFlags.Float; } else { - //Logger.Write(this, LogLevel.Debug, "Decoding file \"{0}\" in standaed quality mode (16 bit integer).", encoderItem.InputFileName); + Logger.Write(this, LogLevel.Debug, "Decoding file \"{0}\" in standaed quality mode (16 bit integer).", encoderItem.InputFileName); } using (var stream = this.CreateStream(encoderItem.InputFileName, flags)) { if (stream.IsEmpty) { - //Logger.Write(this, LogLevel.Debug, "Failed to create stream for file \"{0}\": Unknown error.", encoderItem.InputFileName); + Logger.Write(this, LogLevel.Debug, "Failed to create stream for file \"{0}\": Unknown error.", encoderItem.InputFileName); return; } - //Logger.Write(this, LogLevel.Debug, "Created stream for file \"{0}\": {1}", encoderItem.InputFileName, stream.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Created stream for file \"{0}\": {1}", encoderItem.InputFileName, stream.ChannelHandle); if (settings is IBassEncoderTool) { if (this.ShouldResample(encoderItem, stream, settings)) @@ -158,7 +158,7 @@ protected virtual void Encode(EncoderItem encoderItem, IBassEncoderSettings sett encoderItem.Status = EncoderItemStatus.Cancelled; if (File.Exists(encoderItem.OutputFileName)) { - //Logger.Write(this, LogLevel.Debug, "Deleting incomplete output \"{0}\": Cancelled.", encoderItem.OutputFileName); + Logger.Write(this, LogLevel.Debug, "Deleting incomplete output \"{0}\": Cancelled.", encoderItem.OutputFileName); File.Delete(encoderItem.OutputFileName); } } @@ -195,9 +195,9 @@ protected virtual void Encode(EncoderItem encoderItem, IBassStream stream, Proce Name = string.Format("ChannelReader(\"{0}\", {1})", encoderItem.InputFileName, stream.ChannelHandle), IsBackground = true }; - //Logger.Write(this, LogLevel.Debug, "Starting background thread for file \"{0}\".", encoderItem.InputFileName); + Logger.Write(this, LogLevel.Debug, "Starting background thread for file \"{0}\".", encoderItem.InputFileName); thread.Start(); - //Logger.Write(this, LogLevel.Debug, "Completing background thread for file \"{0}\".", encoderItem.InputFileName); + Logger.Write(this, LogLevel.Debug, "Completing background thread for file \"{0}\".", encoderItem.InputFileName); this.Join(thread); } @@ -260,12 +260,12 @@ protected virtual void EncodeWithResampler(EncoderItem encoderItem, IBassStream IsBackground = true } }; - //Logger.Write(this, LogLevel.Debug, "Starting background threads for file \"{0}\".", encoderItem.InputFileName); + Logger.Write(this, LogLevel.Debug, "Starting background threads for file \"{0}\".", encoderItem.InputFileName); foreach (var thread in threads) { thread.Start(); } - //Logger.Write(this, LogLevel.Debug, "Completing background threads for file \"{0}\".", encoderItem.InputFileName); + Logger.Write(this, LogLevel.Debug, "Completing background threads for file \"{0}\".", encoderItem.InputFileName); foreach (var thread in threads) { this.Join(thread); @@ -284,9 +284,9 @@ protected virtual void Encode(EncoderItem encoderItem, IBassStream stream, IBass Name = string.Format("ChannelReader(\"{0}\", {1})", encoderItem.InputFileName, stream.ChannelHandle), IsBackground = true }; - //Logger.Write(this, LogLevel.Debug, "Starting background thread for file \"{0}\".", encoderItem.InputFileName); + Logger.Write(this, LogLevel.Debug, "Starting background thread for file \"{0}\".", encoderItem.InputFileName); thread.Start(); - //Logger.Write(this, LogLevel.Debug, "Completing background thread for file \"{0}\".", encoderItem.InputFileName); + Logger.Write(this, LogLevel.Debug, "Completing background thread for file \"{0}\".", encoderItem.InputFileName); this.Join(thread); } @@ -321,12 +321,12 @@ protected virtual void EncodeWithResampler(EncoderItem encoderItem, IBassStream IsBackground = true } }; - //Logger.Write(this, LogLevel.Debug, "Starting background threads for file \"{0}\".", encoderItem.InputFileName); + Logger.Write(this, LogLevel.Debug, "Starting background threads for file \"{0}\".", encoderItem.InputFileName); foreach (var thread in threads) { thread.Start(); } - //Logger.Write(this, LogLevel.Debug, "Completing background threads for file \"{0}\".", encoderItem.InputFileName); + Logger.Write(this, LogLevel.Debug, "Completing background threads for file \"{0}\".", encoderItem.InputFileName); foreach (var thread in threads) { this.Join(thread); @@ -336,7 +336,7 @@ protected virtual void EncodeWithResampler(EncoderItem encoderItem, IBassStream protected virtual Process CreateEncoderProcess(EncoderItem encoderItem, IBassStream stream, IBassEncoderTool settings) { - //Logger.Write(this, LogLevel.Debug, "Creating encoder process for file \"{0}\".", encoderItem.InputFileName); + Logger.Write(this, LogLevel.Debug, "Creating encoder process for file \"{0}\".", encoderItem.InputFileName); var arguments = settings.GetArguments(encoderItem, stream); var process = this.CreateProcess( encoderItem, @@ -348,7 +348,7 @@ protected virtual Process CreateEncoderProcess(EncoderItem encoderItem, IBassStr false, true ); - //Logger.Write(this, LogLevel.Debug, "Created encoder process for file \"{0}\": \"{1}\" {2}", encoderItem.InputFileName, settings.Executable, arguments); + Logger.Write(this, LogLevel.Debug, "Created encoder process for file \"{0}\": \"{1}\" {2}", encoderItem.InputFileName, settings.Executable, arguments); return process; } @@ -386,7 +386,7 @@ protected virtual Process CreateProcess(EncoderItem encoderItem, IBassStream str { return; } - //Logger.Write(this, LogLevel.Trace, "{0}: {1}", executable, e.Data); + Logger.Write(this, LogLevel.Trace, "{0}: {1}", executable, e.Data); encoderItem.AddError(e.Data); }; process.BeginErrorReadLine(); @@ -398,20 +398,20 @@ protected virtual bool ShouldDecodeFloat(EncoderItem encoderItem, IBassEncoderSe { if (encoderItem.BitsPerSample == 0) { - //Logger.Write(this, LogLevel.Debug, "Suggesting high quality mode for file \"{0}\": Unknown bit depth.", encoderItem.InputFileName); + Logger.Write(this, LogLevel.Debug, "Suggesting high quality mode for file \"{0}\": Unknown bit depth.", encoderItem.InputFileName); return true; } else if (encoderItem.BitsPerSample == 1) { - //Logger.Write(this, LogLevel.Debug, "Suggesting high quality mode for file \"{0}\": dsd.", encoderItem.InputFileName); + Logger.Write(this, LogLevel.Debug, "Suggesting high quality mode for file \"{0}\": dsd.", encoderItem.InputFileName); return true; } if (encoderItem.BitsPerSample > 16 || settings.Format.Depth > 16) { - //Logger.Write(this, LogLevel.Debug, "Suggesting high quality mode for file \"{0}\": >16 bit.", encoderItem.InputFileName); + Logger.Write(this, LogLevel.Debug, "Suggesting high quality mode for file \"{0}\": >16 bit.", encoderItem.InputFileName); return true; } - //Logger.Write(this, LogLevel.Debug, "Suggesting standard quality mode for file \"{0}\": <=16 bit.", encoderItem.InputFileName); + Logger.Write(this, LogLevel.Debug, "Suggesting standard quality mode for file \"{0}\": <=16 bit.", encoderItem.InputFileName); return false; } @@ -440,27 +440,27 @@ protected virtual bool ShouldResample(EncoderItem encoderItem, IBassStream strea var result = default(bool); if (settings.Format.BinaryFormat != binaryFormat) { - //Logger.Write(this, LogLevel.Debug, "Resampling required for binary format: {0} => {1}", Enum.GetName(typeof(BassEncoderBinaryFormat), binaryFormat), Enum.GetName(typeof(BassEncoderBinaryFormat), settings.Format.BinaryFormat)); + Logger.Write(this, LogLevel.Debug, "Resampling required for binary format: {0} => {1}", Enum.GetName(typeof(BassEncoderBinaryFormat), binaryFormat), Enum.GetName(typeof(BassEncoderBinaryFormat), settings.Format.BinaryFormat)); result = true; } if (settings.Format.BinaryEndian != binaryEndian) { - //Logger.Write(this, LogLevel.Debug, "Resampling required for binary endian: {0} => {1}", Enum.GetName(typeof(BassEncoderBinaryEndian), binaryEndian), Enum.GetName(typeof(BassEncoderBinaryEndian), settings.Format.BinaryEndian)); + Logger.Write(this, LogLevel.Debug, "Resampling required for binary endian: {0} => {1}", Enum.GetName(typeof(BassEncoderBinaryEndian), binaryEndian), Enum.GetName(typeof(BassEncoderBinaryEndian), settings.Format.BinaryEndian)); result = true; } if (settings.GetDepth(encoderItem, stream) != depth) { - //Logger.Write(this, LogLevel.Debug, "Resampling required for depth: {0} => {1}", depth, settings.GetDepth(encoderItem, stream)); + Logger.Write(this, LogLevel.Debug, "Resampling required for depth: {0} => {1}", depth, settings.GetDepth(encoderItem, stream)); result = true; } if (settings.GetRate(encoderItem, stream) != rate) { - //Logger.Write(this, LogLevel.Debug, "Resampling required for rate: {0} => {1}", rate, settings.GetRate(encoderItem, stream)); + Logger.Write(this, LogLevel.Debug, "Resampling required for rate: {0} => {1}", rate, settings.GetRate(encoderItem, stream)); result = true; } if (settings.GetChannels(encoderItem, stream) != channels) { - //Logger.Write(this, LogLevel.Debug, "Resampling required for channels: {0} => {1}", channels, settings.GetChannels(encoderItem, stream)); + Logger.Write(this, LogLevel.Debug, "Resampling required for channels: {0} => {1}", channels, settings.GetChannels(encoderItem, stream)); result = true; } return result; @@ -470,7 +470,7 @@ protected virtual Action GetErrorHandler(EncoderItem encoderItem) { return e => { - //Logger.Write(this, LogLevel.Warn, "Encoder background thread for file \"{0}\" error: {1}", encoderItem.InputFileName, e.Message); + Logger.Write(this, LogLevel.Warn, "Encoder background thread for file \"{0}\" error: {1}", encoderItem.InputFileName, e.Message); encoderItem.AddError(e.Message); }; } diff --git a/FoxTunes.Encoder.Bass/BassEncoderBehaviour.cs b/FoxTunes.Encoder.Bass/BassEncoderBehaviour.cs index b6b3c7de8..e5e005161 100644 --- a/FoxTunes.Encoder.Bass/BassEncoderBehaviour.cs +++ b/FoxTunes.Encoder.Bass/BassEncoderBehaviour.cs @@ -275,10 +275,10 @@ public override void InitializeComponent(ICore core) protected override async Task OnRun() { - //Logger.Write(this, LogLevel.Debug, "Creating encoder."); + Logger.Write(this, LogLevel.Debug, "Creating encoder."); using (var encoder = EncoderFactory.CreateEncoder(this.EncoderItems)) { - //Logger.Write(this, LogLevel.Debug, "Starting encoder."); + Logger.Write(this, LogLevel.Debug, "Starting encoder."); using (var monitor = new BassEncoderMonitor(encoder, this.Visible, this.CancellationToken)) { monitor.StatusChanged += this.OnStatusChanged; @@ -295,7 +295,7 @@ await this.WithSubTask(monitor, this.EncoderItems = monitor.EncoderItems.Values.ToArray(); } } - //Logger.Write(this, LogLevel.Debug, "Encoder completed successfully."); + Logger.Write(this, LogLevel.Debug, "Encoder completed successfully."); } protected virtual void OnStatusChanged(object sender, BassEncoderMonitorEventArgs e) @@ -313,7 +313,7 @@ protected virtual async Task CopyTags(EncoderItem encoderItem) { try { - //Logger.Write(this, LogLevel.Debug, "Copying tags from \"{0}\" to \"{1}\".", encoderItem.InputFileName, encoderItem.OutputFileName); + Logger.Write(this, LogLevel.Debug, "Copying tags from \"{0}\" to \"{1}\".", encoderItem.InputFileName, encoderItem.OutputFileName); var fileData = this.GetFileData(encoderItem); using (var task = new WriteFileMetaDataTask(encoderItem.OutputFileName, fileData.MetaDatas)) { @@ -323,7 +323,7 @@ protected virtual async Task CopyTags(EncoderItem encoderItem) } catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to copy tags from \"{0}\" to \"{1}\": {2}", encoderItem.InputFileName, encoderItem.OutputFileName, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to copy tags from \"{0}\" to \"{1}\": {2}", encoderItem.InputFileName, encoderItem.OutputFileName, e.Message); await this.ErrorEmitter.Send(this, e).ConfigureAwait(false); } } diff --git a/FoxTunes.Encoder.Bass/BassEncoderFactory.cs b/FoxTunes.Encoder.Bass/BassEncoderFactory.cs index 27786a58d..c62576940 100644 --- a/FoxTunes.Encoder.Bass/BassEncoderFactory.cs +++ b/FoxTunes.Encoder.Bass/BassEncoderFactory.cs @@ -24,7 +24,7 @@ public IBassEncoder CreateEncoder(IEnumerable encoderItems) protected virtual Process CreateProcess() { - //Logger.Write(this, LogLevel.Debug, "Creating encoder container process: {0}", this.Location); + Logger.Write(this, LogLevel.Debug, "Creating encoder container process: {0}", this.Location); var processStartInfo = new ProcessStartInfo() { FileName = this.Location, @@ -41,7 +41,7 @@ protected virtual Process CreateProcess() { return; } - //Logger.Write(this, LogLevel.Trace, "{0}: {1}", this.Location, e.Data); + Logger.Write(this, LogLevel.Trace, "{0}: {1}", this.Location, e.Data); }; process.BeginErrorReadLine(); return process; diff --git a/FoxTunes.Encoder.Bass/BassEncoderHost.cs b/FoxTunes.Encoder.Bass/BassEncoderHost.cs index 01dcb3d11..405923244 100644 --- a/FoxTunes.Encoder.Bass/BassEncoderHost.cs +++ b/FoxTunes.Encoder.Bass/BassEncoderHost.cs @@ -8,6 +8,14 @@ namespace FoxTunes { public static class BassEncoderHost { + private static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + public static string Location { get @@ -65,25 +73,25 @@ private static void Encode(Stream input, Stream output, Stream error) }); core.Initialize(); } - catch + catch (Exception e) { - //Logger.Write(typeof(BassEncoderHost), LogLevel.Error, "Failed to initialize core: {0}", e.Message); + Logger.Write(typeof(BassEncoderHost), LogLevel.Error, "Failed to initialize core: {0}", e.Message); throw; } try { - //Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Begin reading items."); + Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Begin reading items."); var encoderItems = ReadInput(input); - //Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Read {0} items.", encoderItems.Length); + Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Read {0} items.", encoderItems.Length); using (var encoder = new BassEncoder(encoderItems)) { encoder.InitializeComponent(core); Encode(encoder, input, output, error); } } - catch + catch (Exception e) { - //Logger.Write(typeof(BassEncoderHost), LogLevel.Error, "Failed to encode items: {0}", e.Message); + Logger.Write(typeof(BassEncoderHost), LogLevel.Error, "Failed to encode items: {0}", e.Message); throw; } } @@ -95,15 +103,15 @@ private static void Encode(IBassEncoder encoder, Stream input, Stream output, St { try { - //Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Starting encoder main thread."); + Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Starting encoder main thread."); encoder.Encode(); - //Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Finished encoder main thread."); + Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Finished encoder main thread."); WriteOutput(output, new EncoderStatus(EncoderStatusType.Complete)); error.Flush(); } catch (Exception e) { - //Logger.Write(typeof(BassEncoderHost), LogLevel.Error, "Error on encoder main thread: {0}", e.Message); + Logger.Write(typeof(BassEncoderHost), LogLevel.Error, "Error on encoder main thread: {0}", e.Message); WriteOutput(output, new EncoderStatus(EncoderStatusType.Error)); new StreamWriter(error).Write(e.Message); error.Flush(); @@ -116,18 +124,18 @@ private static void Encode(IBassEncoder encoder, Stream input, Stream output, St { try { - //Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Starting encoder output thread."); + Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Starting encoder output thread."); while (thread1.IsAlive) { ProcessOutput(encoder, output); Thread.Sleep(INTERVAL); } ProcessOutput(encoder, output); - //Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Finished encoder output thread."); + Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Finished encoder output thread."); } - catch + catch (Exception e) { - //Logger.Write(typeof(BassEncoderHost), LogLevel.Error, "Error on encoder output thread: {0}", e.Message); + Logger.Write(typeof(BassEncoderHost), LogLevel.Error, "Error on encoder output thread: {0}", e.Message); } }) { @@ -138,7 +146,7 @@ private static void Encode(IBassEncoder encoder, Stream input, Stream output, St var exit = default(bool); try { - //Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Starting encoder input thread."); + Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Starting encoder input thread."); while (thread1.IsAlive) { ProcessInput(encoder, input, output, out exit); @@ -152,11 +160,11 @@ private static void Encode(IBassEncoder encoder, Stream input, Stream output, St { ProcessInput(encoder, input, output, out exit); } - //Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Finished encoder input thread."); + Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Finished encoder input thread."); } - catch + catch (Exception e) { - //Logger.Write(typeof(BassEncoderHost), LogLevel.Error, "Error on encoder input thread: {0}", e.Message); + Logger.Write(typeof(BassEncoderHost), LogLevel.Error, "Error on encoder input thread: {0}", e.Message); } }) { @@ -168,32 +176,32 @@ private static void Encode(IBassEncoder encoder, Stream input, Stream output, St thread1.Join(); if (!thread2.Join(TIMEOUT)) { - //Logger.Write(typeof(BassEncoderHost), LogLevel.Warn, "Encoder output thread did not complete gracefully, aborting."); + Logger.Write(typeof(BassEncoderHost), LogLevel.Warn, "Encoder output thread did not complete gracefully, aborting."); thread2.Abort(); } if (!thread3.Join(TIMEOUT)) { - //Logger.Write(typeof(BassEncoderHost), LogLevel.Warn, "Encoder input thread did not complete gracefully, aborting."); + Logger.Write(typeof(BassEncoderHost), LogLevel.Warn, "Encoder input thread did not complete gracefully, aborting."); thread3.Abort(); } } private static void ProcessInput(IBassEncoder encoder, Stream input, Stream output, out bool exit) { - //Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Begin reading command."); + Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Begin reading command."); var command = ReadInput(input); - //Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Read command: {0}", Enum.GetName(typeof(EncoderCommandType), command.Type)); + Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Read command: {0}", Enum.GetName(typeof(EncoderCommandType), command.Type)); switch (command.Type) { case EncoderCommandType.Cancel: - //Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Sending cancellation signal to encoder."); + Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Sending cancellation signal to encoder."); encoder.Cancel(); - //Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Closing stdin."); + Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Closing stdin."); input.Close(); exit = true; break; case EncoderCommandType.Quit: - //Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Closing stdin/stdout."); + Logger.Write(typeof(BassEncoderHost), LogLevel.Debug, "Closing stdin/stdout."); input.Close(); output.Close(); exit = true; diff --git a/FoxTunes.Encoder.Bass/BassEncoderMonitor.cs b/FoxTunes.Encoder.Bass/BassEncoderMonitor.cs index e8f65142a..44c46a201 100644 --- a/FoxTunes.Encoder.Bass/BassEncoderMonitor.cs +++ b/FoxTunes.Encoder.Bass/BassEncoderMonitor.cs @@ -49,7 +49,7 @@ protected virtual async Task Monitor(Task task) { if (this.CancellationToken.IsCancellationRequested) { - //Logger.Write(this, LogLevel.Debug, "Requesting cancellation from encoder."); + Logger.Write(this, LogLevel.Debug, "Requesting cancellation from encoder."); this.Encoder.Cancel(); this.Name = "Cancelling"; break; @@ -90,7 +90,7 @@ protected virtual async Task Monitor(Task task) } while (!task.IsCompleted) { - //Logger.Write(this, LogLevel.Debug, "Waiting for encoder to complete."); + Logger.Write(this, LogLevel.Debug, "Waiting for encoder to complete."); this.Encoder.Update(); #if NET40 await TaskEx.Delay(INTERVAL).ConfigureAwait(false); @@ -105,7 +105,7 @@ protected virtual void UpdateStatus(EncoderItem encoderItem) var currentEncoderItem = default(EncoderItem); if (this.EncoderItems.TryGetValue(encoderItem.Id, out currentEncoderItem) && currentEncoderItem.Status != encoderItem.Status) { - //Logger.Write(this, LogLevel.Debug, "Encoder status changed for file \"{0}\": {1}", encoderItem.InputFileName, Enum.GetName(typeof(EncoderItemStatus), encoderItem.Status)); + Logger.Write(this, LogLevel.Debug, "Encoder status changed for file \"{0}\": {1}", encoderItem.InputFileName, Enum.GetName(typeof(EncoderItemStatus), encoderItem.Status)); this.OnStatusChanged(encoderItem); } this.EncoderItems[encoderItem.Id] = encoderItem; diff --git a/FoxTunes.Encoder.Bass/BassEncoderOutputPath.cs b/FoxTunes.Encoder.Bass/BassEncoderOutputPath.cs index a1840acda..da0cc1d14 100644 --- a/FoxTunes.Encoder.Bass/BassEncoderOutputPath.cs +++ b/FoxTunes.Encoder.Bass/BassEncoderOutputPath.cs @@ -85,12 +85,12 @@ protected virtual bool GetBrowseFolder(string fileName, out string directoryName var result = this.FileSystemBrowser.Browse(options); if (!result.Success) { - //Logger.Write(this, LogLevel.Debug, "Save As folder browse dialog was cancelled."); + Logger.Write(this, LogLevel.Debug, "Save As folder browse dialog was cancelled."); directoryName = null; return false; } this._BrowseFolder = result.Paths.FirstOrDefault(); - //Logger.Write(this, LogLevel.Debug, "Browse folder: {0}", this._BrowseFolder); + Logger.Write(this, LogLevel.Debug, "Browse folder: {0}", this._BrowseFolder); } } directoryName = this._BrowseFolder; diff --git a/FoxTunes.Encoder.Bass/BassEncoderProxy.cs b/FoxTunes.Encoder.Bass/BassEncoderProxy.cs index 6ec4dad45..de8a02300 100644 --- a/FoxTunes.Encoder.Bass/BassEncoderProxy.cs +++ b/FoxTunes.Encoder.Bass/BassEncoderProxy.cs @@ -37,9 +37,9 @@ public BassEncoderProxy(Process process, IEnumerable encoderItems) public void Encode() { - //Logger.Write(this, LogLevel.Debug, "Sending {0} items to encoder container process.", this.EncoderItems.Count()); + Logger.Write(this, LogLevel.Debug, "Sending {0} items to encoder container process.", this.EncoderItems.Count()); this.Send(this.EncoderItems.ToArray()); - //Logger.Write(this, LogLevel.Debug, "Waiting for encoder container process to complete."); + Logger.Write(this, LogLevel.Debug, "Waiting for encoder container process to complete."); this.Process.WaitForExit(); this.TerminateCallback.Disable(); if (this.Process.ExitCode != 0) @@ -78,7 +78,7 @@ public void Update() public void Cancel() { - //Logger.Write(this, LogLevel.Debug, "Sending cancel command to encoder container process."); + Logger.Write(this, LogLevel.Debug, "Sending cancel command to encoder container process."); this.Send(new EncoderCommand(EncoderCommandType.Cancel)); this.Process.StandardInput.Close(); this.TerminateCallback.Enable(); @@ -86,7 +86,7 @@ public void Cancel() public void Quit() { - //Logger.Write(this, LogLevel.Debug, "Sending quit command to encoder container process."); + Logger.Write(this, LogLevel.Debug, "Sending quit command to encoder container process."); this.Send(new EncoderCommand(EncoderCommandType.Quit)); this.Process.StandardInput.Close(); this.TerminateCallback.Enable(); @@ -100,12 +100,12 @@ protected virtual void Terminate() { return; } - //Logger.Write(this, LogLevel.Warn, "Encoder container process did not exit after {0}ms, terminating it.", TIMEOUT); + Logger.Write(this, LogLevel.Warn, "Encoder container process did not exit after {0}ms, terminating it.", TIMEOUT); this.Process.Kill(); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Error, "Failed to terminate encoder container process: {0}", e.Message); + Logger.Write(this, LogLevel.Error, "Failed to terminate encoder container process: {0}", e.Message); } } @@ -150,12 +150,12 @@ protected virtual object Recieve() protected virtual void UpdateStatus(EncoderStatus status) { - //Logger.Write(this, LogLevel.Debug, "Recieved status from encoder container process: {0}", Enum.GetName(typeof(EncoderStatusType), status.Type)); + Logger.Write(this, LogLevel.Debug, "Recieved status from encoder container process: {0}", Enum.GetName(typeof(EncoderStatusType), status.Type)); switch (status.Type) { case EncoderStatusType.Complete: case EncoderStatusType.Error: - //Logger.Write(this, LogLevel.Debug, "Fetching final status and shutting down encoder container process."); + Logger.Write(this, LogLevel.Debug, "Fetching final status and shutting down encoder container process."); this.Update(); this.Quit(); this.Process.StandardInput.Close(); @@ -193,7 +193,7 @@ protected virtual void OnDisposing() { if (!this.Process.HasExited) { - //Logger.Write(this, LogLevel.Warn, "Process is incomplete."); + Logger.Write(this, LogLevel.Warn, "Process is incomplete."); this.Process.Kill(); } this.Process.Dispose(); @@ -202,7 +202,7 @@ protected virtual void OnDisposing() ~BassEncoderProxy() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Encoder.Bass/BassEncoderSettings.cs b/FoxTunes.Encoder.Bass/BassEncoderSettings.cs index 5db6f32fd..dcb77e7f2 100644 --- a/FoxTunes.Encoder.Bass/BassEncoderSettings.cs +++ b/FoxTunes.Encoder.Bass/BassEncoderSettings.cs @@ -38,7 +38,7 @@ public virtual int GetDepth(EncoderItem encoderItem, IBassStream stream) case DEPTH_16: case DEPTH_24: case DEPTH_32: - //Logger.Write(this, LogLevel.Debug, "Using meta data suggested bit depth for file \"{0}\": {1} bit", encoderItem.InputFileName, encoderItem.BitsPerSample); + Logger.Write(this, LogLevel.Debug, "Using meta data suggested bit depth for file \"{0}\": {1} bit", encoderItem.InputFileName, encoderItem.BitsPerSample); return encoderItem.BitsPerSample; } var channelInfo = default(ChannelInfo); @@ -48,16 +48,16 @@ public virtual int GetDepth(EncoderItem encoderItem, IBassStream stream) } if (channelInfo.Flags.HasFlag(BassFlags.Float)) { - //Logger.Write(this, LogLevel.Debug, "Using decoder bit depth for file \"{0}\": 32 bit", encoderItem.InputFileName); + Logger.Write(this, LogLevel.Debug, "Using decoder bit depth for file \"{0}\": 32 bit", encoderItem.InputFileName); return DEPTH_32; } else { - //Logger.Write(this, LogLevel.Debug, "Using decoder bit depth for file \"{0}\": 16 bit", encoderItem.InputFileName); + Logger.Write(this, LogLevel.Debug, "Using decoder bit depth for file \"{0}\": 16 bit", encoderItem.InputFileName); return DEPTH_16; } } - //Logger.Write(this, LogLevel.Debug, "Using user defined bit depth for file \"{0}\": {1} bit", encoderItem.InputFileName, this.Format.Depth); + Logger.Write(this, LogLevel.Debug, "Using user defined bit depth for file \"{0}\": {1} bit", encoderItem.InputFileName, this.Format.Depth); return this.Format.Depth; } @@ -103,7 +103,7 @@ public virtual long GetLength(EncoderItem encoderItem, IBassStream stream) var outputLength = (long)(inputLength / (source / (float)this.GetDepth(encoderItem, stream))); if (inputLength != outputLength) { - //Logger.Write(this, LogLevel.Debug, "Conversion requires change of data length: {0} bytes => {1} bytes.", inputLength, outputLength); + Logger.Write(this, LogLevel.Debug, "Conversion requires change of data length: {0} bytes => {1} bytes.", inputLength, outputLength); } return outputLength; } diff --git a/FoxTunes.Encoder.Bass/BassEncoderSettingsFactory.cs b/FoxTunes.Encoder.Bass/BassEncoderSettingsFactory.cs index 691f536d2..c3e99aedc 100644 --- a/FoxTunes.Encoder.Bass/BassEncoderSettingsFactory.cs +++ b/FoxTunes.Encoder.Bass/BassEncoderSettingsFactory.cs @@ -16,13 +16,13 @@ public override void InitializeComponent(ICore core) public IBassEncoderSettings CreateSettings(string name) { - //Logger.Write(this, LogLevel.Debug, "Creating settings for profile: {0}", name); + Logger.Write(this, LogLevel.Debug, "Creating settings for profile: {0}", name); var format = ComponentRegistry.Instance.GetComponents().FirstOrDefault( settings => string.Equals(settings.Name, name, StringComparison.OrdinalIgnoreCase) ); if (format == null) { - //Logger.Write(this, LogLevel.Debug, "Failed to locate settings for profile: {0}", name); + Logger.Write(this, LogLevel.Debug, "Failed to locate settings for profile: {0}", name); } return format; } diff --git a/FoxTunes.Encoder.Bass/ChannelReader.cs b/FoxTunes.Encoder.Bass/ChannelReader.cs index 876e1e9ff..e16ff9d55 100644 --- a/FoxTunes.Encoder.Bass/ChannelReader.cs +++ b/FoxTunes.Encoder.Bass/ChannelReader.cs @@ -5,7 +5,15 @@ namespace FoxTunes { public class ChannelReader { - const int BUFFER_SIZE = 102400; + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + const int BUFFER_SIZE = 102400; const int BASS_ERROR_UNKNOWN = -1; @@ -26,7 +34,7 @@ public void CopyTo(ProcessWriter writer, CancellationToken cancellationToken) try { this.CopyTo(writer.Write, cancellationToken); - //Logger.Write(this.GetType(), LogLevel.Debug, "Finished reading data from channel {0}, closing process input.", this.Stream.ChannelHandle); + Logger.Write(this.GetType(), LogLevel.Debug, "Finished reading data from channel {0}, closing process input.", this.Stream.ChannelHandle); } finally { @@ -39,7 +47,7 @@ public void CopyTo(IBassEncoderWriter writer, CancellationToken cancellationToke try { this.CopyTo(writer.Write, cancellationToken); - //Logger.Write(this.GetType(), LogLevel.Debug, "Finished reading data from channel {0}, closing writer input.", this.Stream.ChannelHandle); + Logger.Write(this.GetType(), LogLevel.Debug, "Finished reading data from channel {0}, closing writer input.", this.Stream.ChannelHandle); } finally { @@ -49,7 +57,7 @@ public void CopyTo(IBassEncoderWriter writer, CancellationToken cancellationToke public void CopyTo(Writer writer, CancellationToken cancellationToken) { - //Logger.Write(this.GetType(), LogLevel.Debug, "Begin reading data from channel {0} with {1} byte buffer.", this.Stream.ChannelHandle, BUFFER_SIZE); + Logger.Write(this.GetType(), LogLevel.Debug, "Begin reading data from channel {0} with {1} byte buffer.", this.Stream.ChannelHandle, BUFFER_SIZE); var buffer = new byte[BUFFER_SIZE]; while (Bass.ChannelIsActive(this.Stream.ChannelHandle) != PlaybackState.Stopped) { diff --git a/FoxTunes.Encoder.Bass/Flac/FlacEncoderSettings.cs b/FoxTunes.Encoder.Bass/Flac/FlacEncoderSettings.cs index bdc2b8edb..b7a35d074 100644 --- a/FoxTunes.Encoder.Bass/Flac/FlacEncoderSettings.cs +++ b/FoxTunes.Encoder.Bass/Flac/FlacEncoderSettings.cs @@ -101,12 +101,12 @@ public override int GetDepth(EncoderItem encoderItem, IBassStream stream) var depth = base.GetDepth(encoderItem, stream); if (depth < DEPTH_16) { - //Logger.Write(this.GetType(), LogLevel.Warn, "Requsted bit depth {0} is invalid, using minimum: 16 bit", depth); + Logger.Write(this.GetType(), LogLevel.Warn, "Requsted bit depth {0} is invalid, using minimum: 16 bit", depth); return DEPTH_16; } if (depth > DEPTH_24) { - //Logger.Write(this.GetType(), LogLevel.Warn, "Requsted bit depth {0} is invalid, using maximum: 24 bit", depth); + Logger.Write(this.GetType(), LogLevel.Warn, "Requsted bit depth {0} is invalid, using maximum: 24 bit", depth); return DEPTH_24; } return depth; diff --git a/FoxTunes.Encoder.Bass/ProcessReader.cs b/FoxTunes.Encoder.Bass/ProcessReader.cs index 31a6d4915..c34a080e0 100644 --- a/FoxTunes.Encoder.Bass/ProcessReader.cs +++ b/FoxTunes.Encoder.Bass/ProcessReader.cs @@ -5,7 +5,15 @@ namespace FoxTunes { public class ProcessReader { - const int BUFFER_SIZE = 10240; + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + const int BUFFER_SIZE = 10240; public ProcessReader(Process process) { @@ -19,7 +27,7 @@ public void CopyTo(ProcessWriter writer, CancellationToken cancellationToken) try { this.CopyTo(writer.Write, cancellationToken); - //Logger.Write(this.GetType(), LogLevel.Debug, "Finished reading data from process {0}, closing process input.", this.Process.Id); + Logger.Write(this.GetType(), LogLevel.Debug, "Finished reading data from process {0}, closing process input.", this.Process.Id); } finally { @@ -32,7 +40,7 @@ public void CopyTo(IBassEncoderWriter writer, CancellationToken cancellationToke try { this.CopyTo(writer.Write, cancellationToken); - //Logger.Write(this.GetType(), LogLevel.Debug, "Finished reading data from process {0}, closing writer input.", this.Process.Id); + Logger.Write(this.GetType(), LogLevel.Debug, "Finished reading data from process {0}, closing writer input.", this.Process.Id); } finally { @@ -42,7 +50,7 @@ public void CopyTo(IBassEncoderWriter writer, CancellationToken cancellationToke public void CopyTo(Writer writer, CancellationToken cancellationToken) { - //Logger.Write(this.GetType(), LogLevel.Debug, "Begin reading data from process {0} with {1} byte buffer.", this.Process.Id, BUFFER_SIZE); + Logger.Write(this.GetType(), LogLevel.Debug, "Begin reading data from process {0} with {1} byte buffer.", this.Process.Id, BUFFER_SIZE); var length = default(int); var buffer = new byte[BUFFER_SIZE]; while (!this.Process.HasExited) diff --git a/FoxTunes.Encoder.Bass/Resampler.cs b/FoxTunes.Encoder.Bass/Resampler.cs index cf1a6ec5a..e3743d3b7 100644 --- a/FoxTunes.Encoder.Bass/Resampler.cs +++ b/FoxTunes.Encoder.Bass/Resampler.cs @@ -44,7 +44,7 @@ protected virtual void OnErrorDataReceived(object sender, DataReceivedEventArgs { return; } - //Logger.Write(typeof(Resampler), LogLevel.Trace, "{0}: {1}", FileName, e.Data); + Logger.Write(typeof(Resampler), LogLevel.Trace, "{0}: {1}", FileName, e.Data); } public bool IsDisposed { get; private set; } @@ -76,7 +76,7 @@ protected virtual void OnDisposing() ~Resampler() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); @@ -93,7 +93,7 @@ private static Process CreateProcess(ResamplerFormat inputFormat, ResamplerForma { throw new InvalidOperationException(string.Format("A required utility was not found: {0}", FileName)); } - //Logger.Write(typeof(Resampler), LogLevel.Debug, "Creating resampler process: {0} => {1}", inputFormat, outputFormat); + Logger.Write(typeof(Resampler), LogLevel.Debug, "Creating resampler process: {0} => {1}", inputFormat, outputFormat); var arguments = GetArguments(inputFormat, outputFormat); var processStartInfo = new ProcessStartInfo() { @@ -115,7 +115,7 @@ private static Process CreateProcess(ResamplerFormat inputFormat, ResamplerForma { //Nothing can be done, probably access denied. } - //Logger.Write(typeof(Resampler), LogLevel.Debug, "Created resampler process: \"{0}\" {1}", FileName, arguments); + Logger.Write(typeof(Resampler), LogLevel.Debug, "Created resampler process: \"{0}\" {1}", FileName, arguments); return process; } diff --git a/FoxTunes.Encoder.Bass/WavPack/WavPackSettings.cs b/FoxTunes.Encoder.Bass/WavPack/WavPackSettings.cs index 3f6ba017a..62506c536 100644 --- a/FoxTunes.Encoder.Bass/WavPack/WavPackSettings.cs +++ b/FoxTunes.Encoder.Bass/WavPack/WavPackSettings.cs @@ -145,12 +145,12 @@ public override int GetDepth(EncoderItem encoderItem, IBassStream stream) var depth = base.GetDepth(encoderItem, stream); if (depth < DEPTH_16) { - //Logger.Write(this.GetType(), LogLevel.Warn, "Requsted bit depth {0} is invalid, using minimum: 16 bit", depth); + Logger.Write(this.GetType(), LogLevel.Warn, "Requsted bit depth {0} is invalid, using minimum: 16 bit", depth); return DEPTH_16; } if (depth > DEPTH_32) { - //Logger.Write(this.GetType(), LogLevel.Warn, "Requsted bit depth {0} is invalid, using maximum: 32 bit", depth); + Logger.Write(this.GetType(), LogLevel.Warn, "Requsted bit depth {0} is invalid, using maximum: 32 bit", depth); return DEPTH_32; } return depth; diff --git a/FoxTunes.Launcher/Server.cs b/FoxTunes.Launcher/Server.cs index f2e36bc60..c421a9910 100644 --- a/FoxTunes.Launcher/Server.cs +++ b/FoxTunes.Launcher/Server.cs @@ -10,7 +10,15 @@ namespace FoxTunes { public class Server : IDisposable { - public static readonly string Id = typeof(Server).Assembly.FullName; + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public static readonly string Id = typeof(Server).Assembly.FullName; public Server() { @@ -94,7 +102,7 @@ protected virtual void OnDisposing() ~Server() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.MetaData.Discogs/Discogs.cs b/FoxTunes.MetaData.Discogs/Discogs.cs index 91e2d2b42..bfe1594e7 100644 --- a/FoxTunes.MetaData.Discogs/Discogs.cs +++ b/FoxTunes.MetaData.Discogs/Discogs.cs @@ -52,13 +52,13 @@ public Discogs(string baseUrl = BASE_URL, string key = KEY, string secret = SECR public async Task> GetReleases(ReleaseLookup releaseLookup, bool master) { var url = this.GetUrl(releaseLookup, master); - //Logger.Write(this, LogLevel.Debug, "Querying the API: {0}", url); + Logger.Write(this, LogLevel.Debug, "Querying the API: {0}", url); var request = this.CreateRequest(url); using (var response = (HttpWebResponse)request.GetResponse()) { if (response.StatusCode != HttpStatusCode.OK) { - //Logger.Write(this, LogLevel.Warn, "Status code does not indicate success."); + Logger.Write(this, LogLevel.Warn, "Status code does not indicate success."); return Enumerable.Empty(); } return await this.GetReleases(response.GetResponseStream()).ConfigureAwait(false); @@ -87,13 +87,13 @@ protected virtual async Task> GetReleases(Stream stream) public async Task GetRelease(Release release) { var url = release.ResourceUrl; - //Logger.Write(this, LogLevel.Debug, "Querying the API: {0}", url); + Logger.Write(this, LogLevel.Debug, "Querying the API: {0}", url); var request = this.CreateRequest(url); using (var response = (HttpWebResponse)request.GetResponse()) { if (response.StatusCode != HttpStatusCode.OK) { - //Logger.Write(this, LogLevel.Warn, "Status code does not indicate success."); + Logger.Write(this, LogLevel.Warn, "Status code does not indicate success."); return null; } return await this.GetRelease(response.GetResponseStream()).ConfigureAwait(false); @@ -116,13 +116,13 @@ protected virtual async Task GetRelease(Stream stream) public Task GetData(string url) { - //Logger.Write(this, LogLevel.Debug, "Querying the API: {0}", url); + Logger.Write(this, LogLevel.Debug, "Querying the API: {0}", url); var request = this.CreateRequest(url); using (var response = (HttpWebResponse)request.GetResponse()) { if (response.StatusCode != HttpStatusCode.OK) { - //Logger.Write(this, LogLevel.Warn, "Status code does not indicate success."); + Logger.Write(this, LogLevel.Warn, "Status code does not indicate success."); #if NET40 return TaskEx.FromResult(default(byte[])); #else @@ -243,7 +243,7 @@ protected virtual void OnDisposing() ~Discogs() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.MetaData.Discogs/DiscogsFetchArtworkTask.cs b/FoxTunes.MetaData.Discogs/DiscogsFetchArtworkTask.cs index fd5ba2356..e00ccd06a 100644 --- a/FoxTunes.MetaData.Discogs/DiscogsFetchArtworkTask.cs +++ b/FoxTunes.MetaData.Discogs/DiscogsFetchArtworkTask.cs @@ -31,7 +31,7 @@ protected override async Task OnLookupSuccess(Discogs.ReleaseLookup releas } else { - //Logger.Write(this, LogLevel.Warn, "Failed to download artwork for album {0} - {1}: Releases don't contain images or they count not be downloaded.", releaseLookup.Artist, releaseLookup.Album); + Logger.Write(this, LogLevel.Warn, "Failed to download artwork for album {0} - {1}: Releases don't contain images or they count not be downloaded.", releaseLookup.Artist, releaseLookup.Album); releaseLookup.AddError(Strings.DiscogsFetchArtworkTask_NotFound); return false; } @@ -52,11 +52,11 @@ protected virtual async Task ImportImage(Discogs.ReleaseLookup releaseLo { var fileName = await FileMetaDataStore.IfNotExistsAsync(PREFIX, url, async result => { - //Logger.Write(this, LogLevel.Debug, "Downloading data from url: {0}", url); + Logger.Write(this, LogLevel.Debug, "Downloading data from url: {0}", url); var data = await this.Discogs.GetData(url).ConfigureAwait(false); if (data == null) { - //Logger.Write(this, LogLevel.Error, "Failed to download data from url \"{0}\": Unknown error.", url); + Logger.Write(this, LogLevel.Error, "Failed to download data from url \"{0}\": Unknown error.", url); return string.Empty; } return await FileMetaDataStore.WriteAsync(PREFIX, url, data).ConfigureAwait(false); @@ -68,7 +68,7 @@ protected virtual async Task ImportImage(Discogs.ReleaseLookup releaseLo } catch (Exception e) { - //Logger.Write(this, LogLevel.Error, "Failed to download data from url \"{0}\": {1}", url, e.Message); + Logger.Write(this, LogLevel.Error, "Failed to download data from url \"{0}\": {1}", url, e.Message); releaseLookup.AddError(e.Message); } } diff --git a/FoxTunes.MetaData.Discogs/DiscogsFetchTagsTask.cs b/FoxTunes.MetaData.Discogs/DiscogsFetchTagsTask.cs index 716627d00..71b6eb24d 100644 --- a/FoxTunes.MetaData.Discogs/DiscogsFetchTagsTask.cs +++ b/FoxTunes.MetaData.Discogs/DiscogsFetchTagsTask.cs @@ -31,17 +31,17 @@ protected virtual async Task ImportTags(Discogs.ReleaseLookup releaseLooku var release = default(Discogs.ReleaseDetails); try { - //Logger.Write(this, LogLevel.Debug, "Fetching release details: {0}", releaseLookup.Release.ResourceUrl); + Logger.Write(this, LogLevel.Debug, "Fetching release details: {0}", releaseLookup.Release.ResourceUrl); release = await this.Discogs.GetRelease(releaseLookup.Release).ConfigureAwait(false); if (release == null) { - //Logger.Write(this, LogLevel.Error, "Failed to fetch release details \"{0}\": Unknown error.", releaseLookup.Release.ResourceUrl); + Logger.Write(this, LogLevel.Error, "Failed to fetch release details \"{0}\": Unknown error.", releaseLookup.Release.ResourceUrl); return false; } } catch (Exception e) { - //Logger.Write(this, LogLevel.Error, "Failed to fetch release details \"{0}\": {1}", releaseLookup.Release.ResourceUrl, e.Message); + Logger.Write(this, LogLevel.Error, "Failed to fetch release details \"{0}\": {1}", releaseLookup.Release.ResourceUrl, e.Message); releaseLookup.AddError(e.Message); } var names = new HashSet(StringComparer.OrdinalIgnoreCase); @@ -162,7 +162,7 @@ protected virtual int GetTrackNumber(IFileData fileData, IDictionary Lookup(Discogs.ReleaseLookup releaseLookup) { var description = releaseLookup.ToString(); - //Logger.Write(this, LogLevel.Debug, "Fetching master releases: {0}", description); + Logger.Write(this, LogLevel.Debug, "Fetching master releases: {0}", description); var releases = await this.Discogs.GetReleases(releaseLookup, true).ConfigureAwait(false); if (!releases.Any()) { - //Logger.Write(this, LogLevel.Warn, "No master releases: {0}, fetching others", description); + Logger.Write(this, LogLevel.Warn, "No master releases: {0}, fetching others", description); releases = await this.Discogs.GetReleases(releaseLookup, false).ConfigureAwait(false); if (!releases.Any()) { - //Logger.Write(this, LogLevel.Warn, "No releases: {0}", description); + Logger.Write(this, LogLevel.Warn, "No releases: {0}", description); return false; } } - //Logger.Write(this, LogLevel.Debug, "Selecting releases: {0}", description); + Logger.Write(this, LogLevel.Debug, "Selecting releases: {0}", description); releaseLookup.Release = await this.ConfirmRelease(releaseLookup, releases.ToArray()).ConfigureAwait(false); if (releaseLookup.Release != null) { - //Logger.Write(this, LogLevel.Debug, "Selected {0}: {1}", description, releaseLookup.Release.Url); + Logger.Write(this, LogLevel.Debug, "Selected {0}: {1}", description, releaseLookup.Release.Url); return await this.OnLookupSuccess(releaseLookup).ConfigureAwait(false); } else { - //Logger.Write(this, LogLevel.Warn, "No matches: {0}", description); + Logger.Write(this, LogLevel.Warn, "No matches: {0}", description); } return false; } @@ -203,7 +203,7 @@ protected virtual async Task SaveMetaData(Discogs.ReleaseLookup releaseLookup) { fileData.AddOrUpdate(CustomMetaData.DiscogsRelease, MetaDataItemType.Tag, value); } - //Logger.Write(this, LogLevel.Debug, "Discogs release: {0} => {1}", fileData.FileName, value); + Logger.Write(this, LogLevel.Debug, "Discogs release: {0} => {1}", fileData.FileName, value); } await this.MetaDataManager.Save( releaseLookup.FileDatas, diff --git a/FoxTunes.MetaData.TagLib/Managers/DocumentManager.cs b/FoxTunes.MetaData.TagLib/Managers/DocumentManager.cs index 80a5226d9..dfcf81174 100644 --- a/FoxTunes.MetaData.TagLib/Managers/DocumentManager.cs +++ b/FoxTunes.MetaData.TagLib/Managers/DocumentManager.cs @@ -15,13 +15,21 @@ public static class DocumentManager static readonly Regex Base64 = new Regex("^([a-z0-9+/]{4})*([a-z0-9+/]{3}=|[a-z0-9+/]{2}==)?$", RegexOptions.IgnoreCase | RegexOptions.Compiled); + private static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + public static void Read(TagLibMetaDataSource source, IList metaDatas, File file) { try { if (file.InvariantStartPosition > TagLibMetaDataSource.MAX_TAG_SIZE) { - //Logger.Write(typeof(ImageManager), LogLevel.Warn, "Not importing documents from file \"{0}\" due to size: {1} > {2}", file.Name, file.InvariantStartPosition, TagLibMetaDataSource.MAX_TAG_SIZE); + Logger.Write(typeof(ImageManager), LogLevel.Warn, "Not importing documents from file \"{0}\" due to size: {1} > {2}", file.Name, file.InvariantStartPosition, TagLibMetaDataSource.MAX_TAG_SIZE); return; } @@ -45,15 +53,15 @@ public static void Read(TagLibMetaDataSource source, IList metaDat }); } } - catch + catch (Exception e) { - //Logger.Write(typeof(DocumentManager), LogLevel.Warn, "Failed to read document: {0} => {1} => {2}", file.Name, picture.Description, e.Message); + Logger.Write(typeof(DocumentManager), LogLevel.Warn, "Failed to read document: {0} => {1} => {2}", file.Name, picture.Description, e.Message); } } } - catch + catch (Exception e) { - //Logger.Write(typeof(DocumentManager), LogLevel.Warn, "Failed to read documents: {0} => {1}", file.Name, e.Message); + Logger.Write(typeof(DocumentManager), LogLevel.Warn, "Failed to read documents: {0} => {1}", file.Name, e.Message); } } @@ -123,7 +131,7 @@ private static IPicture CreateDocument(MetaDataItem metaDataItem, File file) var parts = metaDataItem.Value.Split(new[] { ':' }, 2); if (parts.Length != 2) { - //Logger.Write(typeof(DocumentManager), LogLevel.Warn, "Failed to parse document: {0}", metaDataItem.Value); + Logger.Write(typeof(DocumentManager), LogLevel.Warn, "Failed to parse document: {0}", metaDataItem.Value); return null; } var mimeType = parts[0]; diff --git a/FoxTunes.MetaData.TagLib/Managers/ImageManager.cs b/FoxTunes.MetaData.TagLib/Managers/ImageManager.cs index db5408f5b..698b4c132 100644 --- a/FoxTunes.MetaData.TagLib/Managers/ImageManager.cs +++ b/FoxTunes.MetaData.TagLib/Managers/ImageManager.cs @@ -9,6 +9,14 @@ namespace FoxTunes { public static class ImageManager { + private static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + private static readonly string PREFIX = typeof(TagLibMetaDataSource).Name; public static ArtworkType ArtworkTypes = ArtworkType.FrontCover; @@ -68,7 +76,7 @@ private static async Task ReadEmbedded(TagLibMetaDataSource source, IList< { if (file.InvariantStartPosition > TagLibMetaDataSource.MAX_TAG_SIZE) { - //Logger.Write(typeof(ImageManager), LogLevel.Warn, "Not importing images from file \"{0}\" due to size: {1} > {2}", file.Name, file.InvariantStartPosition, TagLibMetaDataSource.MAX_TAG_SIZE); + Logger.Write(typeof(ImageManager), LogLevel.Warn, "Not importing images from file \"{0}\" due to size: {1} > {2}", file.Name, file.InvariantStartPosition, TagLibMetaDataSource.MAX_TAG_SIZE); return false; } @@ -90,27 +98,27 @@ private static async Task ReadEmbedded(TagLibMetaDataSource source, IList< if (!string.IsNullOrEmpty(picture.Description)) { //If we're in fallback (i.e the picture type isn't right) then ignore "pictures" with a description as it likely means the data has a specific purpose. - //Logger.Write(typeof(ImageManager), LogLevel.Warn, "Not importing image from file \"{0}\" due to description: {1}", file.Name, picture.Description); + Logger.Write(typeof(ImageManager), LogLevel.Warn, "Not importing image from file \"{0}\" due to description: {1}", file.Name, picture.Description); continue; } - //Logger.Write(typeof(ImageManager), LogLevel.Warn, "Importing image from file \"{0}\" with bad type: {1}.", file.Name, Enum.GetName(typeof(PictureType), picture.Type)); + Logger.Write(typeof(ImageManager), LogLevel.Warn, "Importing image from file \"{0}\" with bad type: {1}.", file.Name, Enum.GetName(typeof(PictureType), picture.Type)); source.AddWarning(file.Name, string.Format("Image has bad type: {0}.", Enum.GetName(typeof(PictureType), picture.Type))); } if (string.IsNullOrEmpty(picture.MimeType)) { - //Logger.Write(typeof(ImageManager), LogLevel.Warn, "Importing image from file \"{0}\" with empty mime type.", file.Name); + Logger.Write(typeof(ImageManager), LogLevel.Warn, "Importing image from file \"{0}\" with empty mime type.", file.Name); source.AddWarning(file.Name, "Image has empty mime type."); } else if (!MimeMapping.Instance.IsImage(picture.MimeType)) { - //Logger.Write(typeof(ImageManager), LogLevel.Warn, "Importing image from file \"{0}\" with bad mime type: {1}", file.Name, picture.MimeType); + Logger.Write(typeof(ImageManager), LogLevel.Warn, "Importing image from file \"{0}\" with bad mime type: {1}", file.Name, picture.MimeType); source.AddWarning(file.Name, string.Format("Image has bad mime type: {0}", picture.MimeType)); } if (picture.Data.Count > source.MaxImageSize.Value * 1024000) { - //Logger.Write(typeof(ImageManager), LogLevel.Warn, "Not importing image from file \"{0}\" due to size: {1} > {2}", file.Name, picture.Data.Count, source.MaxImageSize.Value * 1024000); + Logger.Write(typeof(ImageManager), LogLevel.Warn, "Not importing image from file \"{0}\" due to size: {1} > {2}", file.Name, picture.Data.Count, source.MaxImageSize.Value * 1024000); source.AddWarning(file.Name, string.Format("Image was not imported due to size: {0} > {1}", picture.Data.Count, source.MaxImageSize.Value * 1024000)); continue; } @@ -128,9 +136,9 @@ private static async Task ReadEmbedded(TagLibMetaDataSource source, IList< } } } - catch + catch (Exception e) { - //Logger.Write(typeof(ImageManager), LogLevel.Warn, "Failed to read pictures: {0} => {1}", file.Name, e.Message); + Logger.Write(typeof(ImageManager), LogLevel.Warn, "Failed to read pictures: {0} => {1}", file.Name, e.Message); } return types != ArtworkType.None; } @@ -167,9 +175,9 @@ private static async Task ReadLoose(TagLibMetaDataSource source, IList {1}", file.Name, e.Message); + Logger.Write(typeof(ImageManager), LogLevel.Warn, "Failed to read pictures: {0} => {1}", file.Name, e.Message); } return types != ArtworkType.None; } diff --git a/FoxTunes.MetaData.TagLib/Mpeg4/File.cs b/FoxTunes.MetaData.TagLib/Mpeg4/File.cs index afdc4c706..f3b180ed0 100644 --- a/FoxTunes.MetaData.TagLib/Mpeg4/File.cs +++ b/FoxTunes.MetaData.TagLib/Mpeg4/File.cs @@ -10,7 +10,15 @@ namespace FoxTunes.Mpeg4 { public class File : global::TagLib.Mpeg4.File, IMetaDataSource { - public File(string path) : base(path) + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public File(string path) : base(path) { } diff --git a/FoxTunes.MetaData.TagLib/TagLibMetaDataSource.cs b/FoxTunes.MetaData.TagLib/TagLibMetaDataSource.cs index 9ad84e786..e6986448c 100644 --- a/FoxTunes.MetaData.TagLib/TagLibMetaDataSource.cs +++ b/FoxTunes.MetaData.TagLib/TagLibMetaDataSource.cs @@ -144,7 +144,7 @@ public async Task> GetMetaData(string fileName, Func(); if (!this.IsSupported(fileName)) { - //Logger.Write(this, LogLevel.Warn, "Unsupported file format: {0}", fileName); + Logger.Write(this, LogLevel.Warn, "Unsupported file format: {0}", fileName); this.AddWarning(fileName, "Unsupported file format."); //Add minimal meta data so library is happy. if (this.FileSystem.Value) @@ -154,7 +154,7 @@ public async Task> GetMetaData(string fileName, Func> GetMetaData(string fileName, Func {1}", fileName, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to read meta data: {0} => {1}", fileName, e.Message); this.AddWarning(fileName, string.Format("Failed to read meta data: {0}", e.Message)); } finally @@ -232,12 +232,12 @@ public async Task SetMetaData(string fileName, IEnumerable metaDat { if (MetaDataBehaviourConfiguration.GetWriteBehaviour(this.Write.Value) == WriteBehaviour.None) { - //Logger.Write(this, LogLevel.Warn, "Writing is disabled: {0}", fileName); + Logger.Write(this, LogLevel.Warn, "Writing is disabled: {0}", fileName); return; } if (!this.IsSupported(fileName)) { - //Logger.Write(this, LogLevel.Warn, "Unsupported file format: {0}", fileName); + Logger.Write(this, LogLevel.Warn, "Unsupported file format: {0}", fileName); return; } var metaDataItems = default(IEnumerable); @@ -575,7 +575,7 @@ private Task SetAdditional(IEnumerable metaData, File file, IMetaD private void ErrorHandler(Exception e) { - //Logger.Write(this, LogLevel.Error, "Failed to read meta data: {0}", e.Message); + Logger.Write(this, LogLevel.Error, "Failed to read meta data: {0}", e.Message); } } diff --git a/FoxTunes.MetaData/Providers/ScriptMetaDataProvider.cs b/FoxTunes.MetaData/Providers/ScriptMetaDataProvider.cs index 8932a4e43..292ebe369 100644 --- a/FoxTunes.MetaData/Providers/ScriptMetaDataProvider.cs +++ b/FoxTunes.MetaData/Providers/ScriptMetaDataProvider.cs @@ -124,7 +124,7 @@ protected virtual void OnDisposing() ~ScriptMetaDataProvider() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Minidisc/MinidiscBehaviour.cs b/FoxTunes.Minidisc/MinidiscBehaviour.cs index ddccc8fc3..1164568ac 100644 --- a/FoxTunes.Minidisc/MinidiscBehaviour.cs +++ b/FoxTunes.Minidisc/MinidiscBehaviour.cs @@ -180,7 +180,7 @@ public async Task WriteDisc(IDevice device, IDisc currentDisc, IDisc updat var percentUsed = updatedDisc.GetCapacity().PercentUsed; if (percentUsed > 100) { - //Logger.Write(this, LogLevel.Warn, "The disc capactiy will be exceeded: {0}", percentUsed); + Logger.Write(this, LogLevel.Warn, "The disc capactiy will be exceeded: {0}", percentUsed); if (!this.UserInterface.Confirm(string.Format(Strings.MinidiscBehaviour_ConfirmWriteDiscWithoutCapacity, percentUsed))) { return false; @@ -191,7 +191,7 @@ public async Task WriteDisc(IDevice device, IDisc currentDisc, IDisc updat var percentUsed = updatedDisc.GetUTOC().PercentUsed; if (percentUsed > 100) { - //Logger.Write(this, LogLevel.Warn, "The disc UTOC will be exceeded: {0}", percentUsed); + Logger.Write(this, LogLevel.Warn, "The disc UTOC will be exceeded: {0}", percentUsed); if (!this.UserInterface.Confirm(string.Format(Strings.MinidiscBehaviour_ConfirmWriteDiscWithoutUTOC, percentUsed))) { return false; @@ -258,16 +258,16 @@ public async Task SendToDisc(Compression compression) if (!string.Equals(updatedDisc.Title, tracks.Title, StringComparison.OrdinalIgnoreCase)) { updatedDisc.Title = tracks.Title; - //Logger.Write(this, LogLevel.Debug, "Setting the disc title: {0}", updatedDisc.Title); + Logger.Write(this, LogLevel.Debug, "Setting the disc title: {0}", updatedDisc.Title); } else { - //Logger.Write(this, LogLevel.Debug, "Keeping existing disc title: {0}", updatedDisc.Title); + Logger.Write(this, LogLevel.Debug, "Keeping existing disc title: {0}", updatedDisc.Title); } } else { - //Logger.Write(this, LogLevel.Debug, "Keeping existing disc title: {0}", updatedDisc.Title); + Logger.Write(this, LogLevel.Debug, "Keeping existing disc title: {0}", updatedDisc.Title); } foreach (var minidiscTrack in tracks.Tracks) { @@ -303,7 +303,7 @@ protected virtual bool TryGetTrack(IDisc disc, MinidiscTrackFactory.MinidiscTrac //Match track name (ignore some characters) and equal (ish) duration. if (MinidiscTrackFactory.StringComparer.Instance.Equals(track.Name, minidiscTrack.TrackName) && Convert.ToInt32(track.Time.TotalSeconds) == Convert.ToInt32(minidiscTrack.TrackTime.TotalSeconds)) { - //Logger.Write(this, LogLevel.Debug, "Found existing track \"{0}\" at position {1}.", minidiscTrack.TrackName, minidiscTrack.TrackNumber); + Logger.Write(this, LogLevel.Debug, "Found existing track \"{0}\" at position {1}.", minidiscTrack.TrackName, minidiscTrack.TrackNumber); return true; } //TODO: I was using this to update missing titles, match track on a missing title and equal (ish) duration. @@ -311,7 +311,7 @@ protected virtual bool TryGetTrack(IDisc disc, MinidiscTrackFactory.MinidiscTrac #if DEBUG else if (string.IsNullOrEmpty(track.Name) && Convert.ToInt32(track.Time.TotalSeconds) == Convert.ToInt32(minidiscTrack.TrackTime.TotalSeconds)) { - //Logger.Write(this, LogLevel.Debug, "Found existing track \"{0}\" at position {1}.", minidiscTrack.TrackName, minidiscTrack.TrackNumber); + Logger.Write(this, LogLevel.Debug, "Found existing track \"{0}\" at position {1}.", minidiscTrack.TrackName, minidiscTrack.TrackNumber); return true; } #endif @@ -327,20 +327,20 @@ protected virtual void AddTrack(IDisc disc, MinidiscTrackFactory.MinidiscTrack m { track = disc.Tracks.Add(minidiscTrack.FileName, compression); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Error, "Error adding track \"{0}\" to disc: {1}", minidiscTrack.FileName, e.Message); + Logger.Write(this, LogLevel.Error, "Error adding track \"{0}\" to disc: {1}", minidiscTrack.FileName, e.Message); throw; } track.Name = minidiscTrack.TrackName; - //Logger.Write(this, LogLevel.Debug, "Adding track \"{0}\": Name: {1}, Compression: {2}", track.Location, track.Name, Enum.GetName(typeof(Compression), compression)); + Logger.Write(this, LogLevel.Debug, "Adding track \"{0}\": Name: {1}, Compression: {2}", track.Location, track.Name, Enum.GetName(typeof(Compression), compression)); } protected virtual void UpdateTrack(IDisc updatedDisc, MinidiscTrackFactory.MinidiscTrack minidiscTrack, ITrack track, Compression compression) { if (!MinidiscTrackFactory.StringComparer.Instance.Equals(minidiscTrack.TrackName, track.Name)) { - //Logger.Write(this, LogLevel.Debug, "Updating track \"{0}\": Name: {1} => {2}", track.Location, track.Name, minidiscTrack.TrackName); + Logger.Write(this, LogLevel.Debug, "Updating track \"{0}\": Name: {1} => {2}", track.Location, track.Name, minidiscTrack.TrackName); track.Name = minidiscTrack.TrackName; } } diff --git a/FoxTunes.Minidisc/MinidiscReport.cs b/FoxTunes.Minidisc/MinidiscReport.cs index 5c8ea8370..7fa2d3cb3 100644 --- a/FoxTunes.Minidisc/MinidiscReport.cs +++ b/FoxTunes.Minidisc/MinidiscReport.cs @@ -340,42 +340,42 @@ public static IDictionary GetActions(IDisc currentDisc, IDi public static IDisc GetUpdatedDisc(IDisc currentDisc, string title, IDictionary tracks) { - //Logger.Write(typeof(MinidiscReport), LogLevel.Debug, "Getting updated disc.."); + Logger.Write(typeof(MinidiscReport), LogLevel.Debug, "Getting updated disc.."); var updatedDisc = currentDisc.Clone(); if (!string.Equals(updatedDisc.Title, title, StringComparison.OrdinalIgnoreCase)) { - //Logger.Write(typeof(MinidiscReport), LogLevel.Debug, "Updating title: {0}", title); + Logger.Write(typeof(MinidiscReport), LogLevel.Debug, "Updating title: {0}", title); updatedDisc.Title = title; } else { - //Logger.Write(typeof(MinidiscReport), LogLevel.Debug, "Keeping title: {0}", title); + Logger.Write(typeof(MinidiscReport), LogLevel.Debug, "Keeping title: {0}", title); } foreach (var pair in tracks.OrderBy(_pair => _pair.Key.Position)) { switch (pair.Value.Action) { case TrackAction.NONE: - //Logger.Write(typeof(MinidiscReport), LogLevel.Debug, "Keeping track ({0}, {1}): {2}", pair.Key.Position, Enum.GetName(typeof(Compression), pair.Key.Compression), pair.Key.Name); + Logger.Write(typeof(MinidiscReport), LogLevel.Debug, "Keeping track ({0}, {1}): {2}", pair.Key.Position, Enum.GetName(typeof(Compression), pair.Key.Compression), pair.Key.Name); break; case TrackAction.ADD: - //Logger.Write(typeof(MinidiscReport), LogLevel.Debug, "Adding track ({0}, {1}): {2}", pair.Key.Position, Enum.GetName(typeof(Compression), pair.Key.Compression), pair.Key.Name); + Logger.Write(typeof(MinidiscReport), LogLevel.Debug, "Adding track ({0}, {1}): {2}", pair.Key.Position, Enum.GetName(typeof(Compression), pair.Key.Compression), pair.Key.Name); updatedDisc.Tracks.Add(pair.Key); break; case TrackAction.UPDATE: var track = updatedDisc.Tracks.GetTrack(pair.Key); if (track == null) { - //Logger.Write(typeof(MinidiscReport), LogLevel.Warn, "Failed to update track ({0}, {1}): {2}", pair.Key.Position, Enum.GetName(typeof(Compression), pair.Key.Compression), pair.Key.Name); + Logger.Write(typeof(MinidiscReport), LogLevel.Warn, "Failed to update track ({0}, {1}): {2}", pair.Key.Position, Enum.GetName(typeof(Compression), pair.Key.Compression), pair.Key.Name); } else if (!string.Equals(track.Name, pair.Value.Name, StringComparison.OrdinalIgnoreCase)) { - //Logger.Write(typeof(MinidiscReport), LogLevel.Debug, "Updating track ({0}, {1}): {2} => {3}", pair.Key.Position, Enum.GetName(typeof(Compression), pair.Key.Compression), pair.Key.Name, pair.Value.Name); + Logger.Write(typeof(MinidiscReport), LogLevel.Debug, "Updating track ({0}, {1}): {2} => {3}", pair.Key.Position, Enum.GetName(typeof(Compression), pair.Key.Compression), pair.Key.Name, pair.Value.Name); track.Name = pair.Value.Name; } break; case TrackAction.REMOVE: - //Logger.Write(typeof(MinidiscReport), LogLevel.Debug, "Removing track ({0}, {1}): {2}", pair.Key.Position, Enum.GetName(typeof(Compression), pair.Key.Compression), pair.Key.Name); + Logger.Write(typeof(MinidiscReport), LogLevel.Debug, "Removing track ({0}, {1}): {2}", pair.Key.Position, Enum.GetName(typeof(Compression), pair.Key.Compression), pair.Key.Name); updatedDisc.Tracks.Remove(pair.Key); break; } diff --git a/FoxTunes.Minidisc/MinidiscTrackFactory.cs b/FoxTunes.Minidisc/MinidiscTrackFactory.cs index 82adca58e..2413639ff 100644 --- a/FoxTunes.Minidisc/MinidiscTrackFactory.cs +++ b/FoxTunes.Minidisc/MinidiscTrackFactory.cs @@ -71,7 +71,7 @@ public async Task GetTracks(PlaylistItem[] playlistItem protected virtual async Task> GetWaveFiles(IFileData[] fileDatas) { - //Logger.Write(this, LogLevel.Debug, "Preparing WAVE files.."); + Logger.Write(this, LogLevel.Debug, "Preparing WAVE files.."); var fileNames = default(IDictionary); using (var task = new ValidateInputFormatsTask(fileDatas)) { @@ -90,23 +90,23 @@ protected virtual async Task> GetWaveFiles(IFileD protected virtual async Task> GetWaveFiles(IFileData[] fileDatas, IDictionary fileNames) { - //Logger.Write(this, LogLevel.Debug, "Encoding {0} items: WAVE 16 bit, 44.1kHz.", fileDatas.Length); + Logger.Write(this, LogLevel.Debug, "Encoding {0} items: WAVE 16 bit, 44.1kHz.", fileDatas.Length); var encoderItems = await this.Encoder.Encode( fileDatas, this.Encoder.GetOutputPath(TempPath), ENCODER_PROFILE, false ).ConfigureAwait(false); - //Logger.Write(this, LogLevel.Debug, "Encoder completed."); + Logger.Write(this, LogLevel.Debug, "Encoder completed."); foreach (var encoderItem in encoderItems) { if (EncoderItem.WasSkipped(encoderItem)) { - //Logger.Write(this, LogLevel.Warn, "Encoder skipped \"{0}\": Re-using existing file: \"{1}\".", encoderItem.InputFileName, encoderItem.OutputFileName); + Logger.Write(this, LogLevel.Warn, "Encoder skipped \"{0}\": Re-using existing file: \"{1}\".", encoderItem.InputFileName, encoderItem.OutputFileName); } else if (encoderItem.Status != EncoderItemStatus.Complete) { - //Logger.Write(this, LogLevel.Warn, "At least one file failed to encode, aborting."); + Logger.Write(this, LogLevel.Warn, "At least one file failed to encode, aborting."); var report = this.Encoder.GetReport(encoderItems); await this.ReportEmitter.Send(report).ConfigureAwait(false); return null; @@ -114,13 +114,13 @@ protected virtual async Task> GetWaveFiles(IFileD var fileData = fileDatas.FirstOrDefault(_fileData => string.Equals(_fileData.FileName, encoderItem.InputFileName, StringComparison.OrdinalIgnoreCase)); if (fileData == null) { - //Logger.Write(this, LogLevel.Warn, "Failed to determine input file for encoder item: {0}", encoderItem.InputFileName); + Logger.Write(this, LogLevel.Warn, "Failed to determine input file for encoder item: {0}", encoderItem.InputFileName); continue; } - //Logger.Write(this, LogLevel.Warn, "Encoded \"{0}\": \"{1}\".", encoderItem.InputFileName, encoderItem.OutputFileName); + Logger.Write(this, LogLevel.Warn, "Encoded \"{0}\": \"{1}\".", encoderItem.InputFileName, encoderItem.OutputFileName); fileNames[fileData] = encoderItem.OutputFileName; } - //Logger.Write(this, LogLevel.Debug, "Encoded {0} items.", fileNames.Count); + Logger.Write(this, LogLevel.Debug, "Encoded {0} items.", fileNames.Count); return fileNames; } @@ -138,7 +138,7 @@ protected virtual string GetTitle(IScriptingContext scriptingContext, IEnumerabl } else { - //Logger.Write(this, LogLevel.Warn, "Disc title is ambiguous, falling back to : {0}", global::MD.Net.Constants.UNTITLED); + Logger.Write(this, LogLevel.Warn, "Disc title is ambiguous, falling back to : {0}", global::MD.Net.Constants.UNTITLED); return global::MD.Net.Constants.UNTITLED; } } @@ -185,14 +185,14 @@ public static void Cleanup() //Nothing to do. return; } - //Logger.Write(typeof(MinidiscBehaviour), LogLevel.Debug, "Cleaning up temp files: {0}", TempPath); + Logger.Write(typeof(MinidiscBehaviour), LogLevel.Debug, "Cleaning up temp files: {0}", TempPath); try { Directory.Delete(TempPath, true); } - catch + catch (Exception e) { - //Logger.Write(typeof(MinidiscBehaviour), LogLevel.Warn, "Failed to cleanup temp files: {0}", e.Message); + Logger.Write(typeof(MinidiscBehaviour), LogLevel.Warn, "Failed to cleanup temp files: {0}", e.Message); } } @@ -235,11 +235,11 @@ protected override Task OnRun() var length = default(TimeSpan); FormatValidator.Default.Validate(fileData.FileName, out length); this.FileNames[fileData] = fileData.FileName; - //Logger.Write(this, LogLevel.Debug, "Input file \"{0}\" is supported.", fileData.FileName); + Logger.Write(this, LogLevel.Debug, "Input file \"{0}\" is supported.", fileData.FileName); } catch { - //Logger.Write(this, LogLevel.Debug, "Input file \"{0}\" is not supported, it requires conversion.", fileData.FileName); + Logger.Write(this, LogLevel.Debug, "Input file \"{0}\" is not supported, it requires conversion.", fileData.FileName); } this.Position++; } diff --git a/FoxTunes.Minidisc/Tasks/EraseMinidiscTask.cs b/FoxTunes.Minidisc/Tasks/EraseMinidiscTask.cs index 97952444d..1be77e81e 100644 --- a/FoxTunes.Minidisc/Tasks/EraseMinidiscTask.cs +++ b/FoxTunes.Minidisc/Tasks/EraseMinidiscTask.cs @@ -22,23 +22,23 @@ protected override Task OnStarted() protected override Task OnRun() { - //Logger.Write(this, LogLevel.Debug, "Reading disc.."); + Logger.Write(this, LogLevel.Debug, "Reading disc.."); var currentDisc = this.DiscManager.GetDisc(this.Device); if (currentDisc != null) { - //Logger.Write(this, LogLevel.Debug, "Current disc \"{0}\" has {1} tracks.", currentDisc.Title, currentDisc.Tracks.Count); + Logger.Write(this, LogLevel.Debug, "Current disc \"{0}\" has {1} tracks.", currentDisc.Title, currentDisc.Tracks.Count); this.Name = string.Format("{0}: {1}", Strings.EraseMinidiscTask_Name, currentDisc.Title); - //Logger.Write(this, LogLevel.Debug, "Erasing.."); + Logger.Write(this, LogLevel.Debug, "Erasing.."); var updatedDisc = currentDisc.Clone(); updatedDisc.Title = string.Empty; updatedDisc.Tracks.Clear(); var actions = this.ActionBuilder.GetActions(this.Device, currentDisc, updatedDisc); this.ApplyActions(this.Device, actions); - //Logger.Write(this, LogLevel.Debug, "Successfully erased disc."); + Logger.Write(this, LogLevel.Debug, "Successfully erased disc."); } else { - //Logger.Write(this, LogLevel.Warn, "Disc could not be read."); + Logger.Write(this, LogLevel.Warn, "Disc could not be read."); throw new Exception(Strings.MinidiscTask_NoDisc); } #if NET40 diff --git a/FoxTunes.Minidisc/Tasks/MinidiscActionTask.cs b/FoxTunes.Minidisc/Tasks/MinidiscActionTask.cs index 76aa9aefe..f44caa165 100644 --- a/FoxTunes.Minidisc/Tasks/MinidiscActionTask.cs +++ b/FoxTunes.Minidisc/Tasks/MinidiscActionTask.cs @@ -27,16 +27,16 @@ protected virtual void OnUpdated(object sender, StatusEventArgs e) protected virtual void ApplyActions(IDevice device, IActions actions) { - //Logger.Write(this, LogLevel.Debug, "Applying actions.."); + Logger.Write(this, LogLevel.Debug, "Applying actions.."); this.Result = this.DiscManager.ApplyActions(device, actions, this.Status, true); if (this.Result.Status != ResultStatus.Success) { - //Logger.Write(this, LogLevel.Warn, "Failed to apply actions: {0}", this.Result.Message); + Logger.Write(this, LogLevel.Warn, "Failed to apply actions: {0}", this.Result.Message); throw new Exception(this.Result.Message); } else { - //Logger.Write(this, LogLevel.Debug, "Successfully applied actions."); + Logger.Write(this, LogLevel.Debug, "Successfully applied actions."); } } diff --git a/FoxTunes.Minidisc/Tasks/MinidiscTask.cs b/FoxTunes.Minidisc/Tasks/MinidiscTask.cs index 189c1a8b6..79d74a55f 100644 --- a/FoxTunes.Minidisc/Tasks/MinidiscTask.cs +++ b/FoxTunes.Minidisc/Tasks/MinidiscTask.cs @@ -34,14 +34,14 @@ public override bool Visible public override void InitializeComponent(ICore core) { - //Logger.Write(this, LogLevel.Debug, "Initializing MD.Net framework.."); + Logger.Write(this, LogLevel.Debug, "Initializing MD.Net framework.."); this.ToolManager = new ToolManager(); this.DeviceManager = new DeviceManager(this.ToolManager); this.FormatValidator = new FormatValidator(); this.DiscManager = new DiscManager(this.ToolManager, this.FormatValidator); this.FormatManager = new FormatManager(this.ToolManager); this.ActionBuilder = new ActionBuilder(this.FormatManager); - //Logger.Write(this, LogLevel.Debug, "Initialized MD.Net framework."); + Logger.Write(this, LogLevel.Debug, "Initialized MD.Net framework."); base.InitializeComponent(core); } } diff --git a/FoxTunes.Minidisc/Tasks/OpenMinidiscTask.cs b/FoxTunes.Minidisc/Tasks/OpenMinidiscTask.cs index 4f50cefab..92e74fba8 100644 --- a/FoxTunes.Minidisc/Tasks/OpenMinidiscTask.cs +++ b/FoxTunes.Minidisc/Tasks/OpenMinidiscTask.cs @@ -19,26 +19,26 @@ protected override Task OnStarted() protected override Task OnRun() { - //Logger.Write(this, LogLevel.Debug, "Checking device.."); + Logger.Write(this, LogLevel.Debug, "Checking device.."); this.Device = this.DeviceManager.GetDevices().FirstOrDefault(); if (this.Device != null) { - //Logger.Write(this, LogLevel.Debug, "Current device: {0}", this.Device.Name); + Logger.Write(this, LogLevel.Debug, "Current device: {0}", this.Device.Name); this.Name = string.Format("{0}: {1}", Strings.OpenMinidiscTask_Name, this.Device.Name); - //Logger.Write(this, LogLevel.Debug, "Reading disc.."); + Logger.Write(this, LogLevel.Debug, "Reading disc.."); this.Disc = this.DiscManager.GetDisc(this.Device); if (this.Disc != null) { - //Logger.Write(this, LogLevel.Debug, "Current disc \"{0}\" has {1} tracks.", this.Disc.Title, this.Disc.Tracks.Count); + Logger.Write(this, LogLevel.Debug, "Current disc \"{0}\" has {1} tracks.", this.Disc.Title, this.Disc.Tracks.Count); } else { - //Logger.Write(this, LogLevel.Warn, "Disc could not be read."); + Logger.Write(this, LogLevel.Warn, "Disc could not be read."); } } else { - //Logger.Write(this, LogLevel.Warn, "Device not found."); + Logger.Write(this, LogLevel.Warn, "Device not found."); } #if NET40 return TaskEx.FromResult(false); diff --git a/FoxTunes.Minidisc/Tasks/SetDiscTitleTask.cs b/FoxTunes.Minidisc/Tasks/SetDiscTitleTask.cs index 01890175e..40b5f7f0f 100644 --- a/FoxTunes.Minidisc/Tasks/SetDiscTitleTask.cs +++ b/FoxTunes.Minidisc/Tasks/SetDiscTitleTask.cs @@ -25,21 +25,21 @@ protected override Task OnStarted() protected override Task OnRun() { - //Logger.Write(this, LogLevel.Debug, "Reading disc.."); + Logger.Write(this, LogLevel.Debug, "Reading disc.."); var currentDisc = this.DiscManager.GetDisc(this.Device); if (currentDisc != null) { - //Logger.Write(this, LogLevel.Debug, "Current disc \"{0}\" has {1} tracks.", currentDisc.Title, currentDisc.Tracks.Count); - //Logger.Write(this, LogLevel.Debug, "Setting title: {0}", this.Title); + Logger.Write(this, LogLevel.Debug, "Current disc \"{0}\" has {1} tracks.", currentDisc.Title, currentDisc.Tracks.Count); + Logger.Write(this, LogLevel.Debug, "Setting title: {0}", this.Title); var updatedDisc = currentDisc.Clone(); updatedDisc.Title = this.Title; var actions = this.ActionBuilder.GetActions(this.Device, currentDisc, updatedDisc); this.ApplyActions(this.Device, actions); - //Logger.Write(this, LogLevel.Debug, "Successfully set title."); + Logger.Write(this, LogLevel.Debug, "Successfully set title."); } else { - //Logger.Write(this, LogLevel.Warn, "Disc could not be read."); + Logger.Write(this, LogLevel.Warn, "Disc could not be read."); throw new Exception(Strings.MinidiscTask_NoDisc); } #if NET40 diff --git a/FoxTunes.Minidisc/Tasks/WriteMinidiscTask.cs b/FoxTunes.Minidisc/Tasks/WriteMinidiscTask.cs index d75a0e8b0..03ddc29c1 100644 --- a/FoxTunes.Minidisc/Tasks/WriteMinidiscTask.cs +++ b/FoxTunes.Minidisc/Tasks/WriteMinidiscTask.cs @@ -24,9 +24,9 @@ protected override Task OnStarted() protected override Task OnRun() { - //Logger.Write(this, LogLevel.Debug, "Writing disc.."); + Logger.Write(this, LogLevel.Debug, "Writing disc.."); this.ApplyActions(this.Device, this.Actions); - //Logger.Write(this, LogLevel.Debug, "Successfully wrote disc."); + Logger.Write(this, LogLevel.Debug, "Successfully wrote disc."); #if NET40 return TaskEx.FromResult(false); #else diff --git a/FoxTunes.Output.Bass.Archive/BassArchiveStreamPasswordBehaviour.cs b/FoxTunes.Output.Bass.Archive/BassArchiveStreamPasswordBehaviour.cs index 9ad022598..cc1124783 100644 --- a/FoxTunes.Output.Bass.Archive/BassArchiveStreamPasswordBehaviour.cs +++ b/FoxTunes.Output.Bass.Archive/BassArchiveStreamPasswordBehaviour.cs @@ -39,12 +39,12 @@ public override void InitializeComponent(ICore core) if (value) { this.Enable(); - //Logger.Write(this, LogLevel.Debug, "Archive password handler enabled."); + Logger.Write(this, LogLevel.Debug, "Archive password handler enabled."); } else { this.Disable(); - //Logger.Write(this, LogLevel.Debug, "Archive password handler disabled."); + Logger.Write(this, LogLevel.Debug, "Archive password handler disabled."); } }); base.InitializeComponent(core); @@ -143,7 +143,7 @@ protected virtual void OnDisposing() ~BassArchiveStreamPasswordBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.Archive/BassArchiveStreamProvider.cs b/FoxTunes.Output.Bass.Archive/BassArchiveStreamProvider.cs index cf36e10f0..2bc08e4b1 100644 --- a/FoxTunes.Output.Bass.Archive/BassArchiveStreamProvider.cs +++ b/FoxTunes.Output.Bass.Archive/BassArchiveStreamProvider.cs @@ -48,7 +48,7 @@ public override IBassStream CreateBasicStream(PlaylistItem playlistItem, IEnumer switch (ArchiveError.GetLastError()) { case ArchiveError.E_PASSWORD_REQUIRED: - //Logger.Write(this, LogLevel.Warn, "Invalid password for \"{0}\".", fileName); + Logger.Write(this, LogLevel.Warn, "Invalid password for \"{0}\".", fileName); if (this.PasswordBehaviour != null) { var cancelled = this.PasswordBehaviour.WasCancelled(fileName); @@ -60,7 +60,7 @@ public override IBassStream CreateBasicStream(PlaylistItem playlistItem, IEnumer } break; } - //Logger.Write(this, LogLevel.Warn, "Failed to create archive stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); + Logger.Write(this, LogLevel.Warn, "Failed to create archive stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); } return this.CreateBasicStream(channelHandle, advice, flags); } @@ -87,7 +87,7 @@ public override IBassStream CreateInteractiveStream(PlaylistItem playlistItem, I switch (ArchiveError.GetLastError()) { case ArchiveError.E_PASSWORD_REQUIRED: - //Logger.Write(this, LogLevel.Warn, "Invalid password for \"{0}\".", fileName); + Logger.Write(this, LogLevel.Warn, "Invalid password for \"{0}\".", fileName); if (this.PasswordBehaviour != null) { var cancelled = this.PasswordBehaviour.WasCancelled(fileName); @@ -99,7 +99,7 @@ public override IBassStream CreateInteractiveStream(PlaylistItem playlistItem, I } break; } - //Logger.Write(this, LogLevel.Warn, "Failed to create archive stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); + Logger.Write(this, LogLevel.Warn, "Failed to create archive stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); } return this.CreateInteractiveStream(channelHandle, advice, flags); } diff --git a/FoxTunes.Output.Bass.Archive/BassArchiveStreamProviderBehaviour.cs b/FoxTunes.Output.Bass.Archive/BassArchiveStreamProviderBehaviour.cs index 616a7b9c1..d79e8e53f 100644 --- a/FoxTunes.Output.Bass.Archive/BassArchiveStreamProviderBehaviour.cs +++ b/FoxTunes.Output.Bass.Archive/BassArchiveStreamProviderBehaviour.cs @@ -59,7 +59,7 @@ public int BufferMin set { BassZipStream.SetConfig(BassZipStreamAttribute.BufferMin, value); - //Logger.Write(this, LogLevel.Debug, "BufferMin = {0}", this.BufferMin); + Logger.Write(this, LogLevel.Debug, "BufferMin = {0}", this.BufferMin); } } @@ -77,7 +77,7 @@ public int BufferTimeout set { BassZipStream.SetConfig(BassZipStreamAttribute.BufferTimeout, value); - //Logger.Write(this, LogLevel.Debug, "BufferTimeout = {0}", this.BufferTimeout); + Logger.Write(this, LogLevel.Debug, "BufferTimeout = {0}", this.BufferTimeout); } } @@ -95,7 +95,7 @@ public bool DoubleBuffer set { BassZipStream.SetConfig(BassZipStreamAttribute.DoubleBuffer, value); - //Logger.Write(this, LogLevel.Debug, "DoubleBuffer = {0}", this.DoubleBuffer); + Logger.Write(this, LogLevel.Debug, "DoubleBuffer = {0}", this.DoubleBuffer); } } @@ -110,7 +110,7 @@ public bool Enabled set { this._Enabled = value; - //Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); + Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); } } @@ -353,7 +353,7 @@ protected override async Task AddPlaylistItems(IEnumerable paths, Cancel var set = this.Database.Set(transaction); foreach (var playlistItem in playlistItems) { - //Logger.Write(this, LogLevel.Debug, "Adding file to playlist: {0}", playlistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Adding file to playlist: {0}", playlistItem.FileName); playlistItem.Playlist_Id = this.Playlist.Id; playlistItem.Sequence = this.Sequence; playlistItem.Status = PlaylistItemStatus.Import; @@ -459,7 +459,7 @@ private async Task RemoveLibraryItems() var libraryItems = set.Where(libraryItem => libraryItem.DirectoryName == root); foreach (var libraryItem in libraryItems) { - //Logger.Write(this, LogLevel.Debug, "Removing file from library: {0}", libraryItem.FileName); + Logger.Write(this, LogLevel.Debug, "Removing file from library: {0}", libraryItem.FileName); libraryItem.Status = LibraryItemStatus.Remove; await set.AddOrUpdateAsync(libraryItem).ConfigureAwait(false); cleanup = true; @@ -483,7 +483,7 @@ private async Task AddLibraryItems(LibraryItem[] libraryItems) var set = this.Database.Set(transaction); foreach (var libraryItem in libraryItems) { - //Logger.Write(this, LogLevel.Debug, "Adding file to library: {0}", libraryItem.FileName); + Logger.Write(this, LogLevel.Debug, "Adding file to library: {0}", libraryItem.FileName); libraryItem.Status = LibraryItemStatus.Import; libraryItem.SetImportDate(DateTime.UtcNow); await set.AddAsync(libraryItem).ConfigureAwait(false); diff --git a/FoxTunes.Output.Bass.Archive/Utilities/ArchiveFileAbstraction.cs b/FoxTunes.Output.Bass.Archive/Utilities/ArchiveFileAbstraction.cs index c6f4073a4..6c15e30c9 100644 --- a/FoxTunes.Output.Bass.Archive/Utilities/ArchiveFileAbstraction.cs +++ b/FoxTunes.Output.Bass.Archive/Utilities/ArchiveFileAbstraction.cs @@ -158,7 +158,7 @@ protected virtual void OnDisposing() ~ArchiveFileAbstraction() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.Archive/Utilities/ArchiveItemFactory.cs b/FoxTunes.Output.Bass.Archive/Utilities/ArchiveItemFactory.cs index 6bc59f7be..3ced4db65 100644 --- a/FoxTunes.Output.Bass.Archive/Utilities/ArchiveItemFactory.cs +++ b/FoxTunes.Output.Bass.Archive/Utilities/ArchiveItemFactory.cs @@ -116,7 +116,7 @@ await metaDataSource.GetMetaData(fileAbstraction).ConfigureAwait(false) switch (fileAbstraction.Result) { case ArchiveEntry.RESULT_PASSWORD_REQUIRED: - //Logger.Write(this, LogLevel.Warn, "Invalid password for \"{0}\".", path); + Logger.Write(this, LogLevel.Warn, "Invalid password for \"{0}\".", path); if (this.PasswordBehaviour != null && !this.PasswordBehaviour.WasCancelled(path)) { this.PasswordBehaviour.Reset(path); @@ -127,9 +127,9 @@ await metaDataSource.GetMetaData(fileAbstraction).ConfigureAwait(false) } } } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Debug, "Failed to read meta data from file \"{0}\": {1}", path, e.Message); + Logger.Write(this, LogLevel.Debug, "Failed to read meta data from file \"{0}\": {1}", path, e.Message); } } this.EnsureMetaData(path, a, entry, item); @@ -137,13 +137,13 @@ await metaDataSource.GetMetaData(fileAbstraction).ConfigureAwait(false) } else { - //Logger.Write(this, LogLevel.Warn, "Failed to read archive entry at position {0}.", a); + Logger.Write(this, LogLevel.Warn, "Failed to read archive entry at position {0}.", a); } } } else { - //Logger.Write(this, LogLevel.Warn, "Failed to read archive entries."); + Logger.Write(this, LogLevel.Warn, "Failed to read archive entries."); } } diff --git a/FoxTunes.Output.Bass.Asio/BassAsioDevice.cs b/FoxTunes.Output.Bass.Asio/BassAsioDevice.cs index 680edb6b8..fe2242df8 100644 --- a/FoxTunes.Output.Bass.Asio/BassAsioDevice.cs +++ b/FoxTunes.Output.Bass.Asio/BassAsioDevice.cs @@ -13,6 +13,14 @@ public static class BassAsioDevice public const int PRIMARY_CHANNEL = 0; + private static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + static BassAsioDevice() { //Perhaps we shouldn't Reset each time the output is started. @@ -39,7 +47,7 @@ public static void Init(int device, int rate, int channels, BassFlags flags) IsInitialized = true; - //Logger.Write(typeof(BassAsioDevice), LogLevel.Debug, "Initializing BASS ASIO."); + Logger.Write(typeof(BassAsioDevice), LogLevel.Debug, "Initializing BASS ASIO."); try { @@ -48,7 +56,7 @@ public static void Init(int device, int rate, int channels, BassFlags flags) BassAsioUtils.OK(BassAsioHandler.ChannelEnable(false, PRIMARY_CHANNEL)); for (var channel = 1; channel < channels; channel++) { - //Logger.Write(typeof(BassAsioDevice), LogLevel.Debug, "Joining channel: {0} => {1}", channel, PRIMARY_CHANNEL); + Logger.Write(typeof(BassAsioDevice), LogLevel.Debug, "Joining channel: {0} => {1}", channel, PRIMARY_CHANNEL); BassAsioUtils.OK(BassAsio.ChannelJoin(false, channel, PRIMARY_CHANNEL)); } @@ -63,7 +71,7 @@ public static void Init(int device, int rate, int channels, BassFlags flags) BassAsio.Rate = rate; - //Logger.Write(typeof(BassAsioDevice), LogLevel.Debug, "Initialized BASS ASIO."); + Logger.Write(typeof(BassAsioDevice), LogLevel.Debug, "Initialized BASS ASIO."); } catch { @@ -117,7 +125,7 @@ public static void Detect(int device) IsInitialized = true; - //Logger.Write(typeof(BassAsioDevice), LogLevel.Debug, "Detecting ASIO device."); + Logger.Write(typeof(BassAsioDevice), LogLevel.Debug, "Detecting ASIO device."); try { @@ -133,8 +141,8 @@ public static void Detect(int device) GetSupportedRates(), info.Format ); - //Logger.Write(typeof(BassAsioDevice), LogLevel.Debug, "Detected ASIO device: {0} => Inputs => {1}, Outputs = {2}, Rate = {3}, Format = {4}", BassAsio.CurrentDevice, Info.Inputs, Info.Outputs, Info.Rate, Enum.GetName(typeof(AsioSampleFormat), Info.Format)); - //Logger.Write(typeof(BassAsioDevice), LogLevel.Debug, "Detected ASIO device: {0} => Rates => {1}", BassAsio.CurrentDevice, string.Join(", ", Info.SupportedRates)); + Logger.Write(typeof(BassAsioDevice), LogLevel.Debug, "Detected ASIO device: {0} => Inputs => {1}, Outputs = {2}, Rate = {3}, Format = {4}", BassAsio.CurrentDevice, Info.Inputs, Info.Outputs, Info.Rate, Enum.GetName(typeof(AsioSampleFormat), Info.Format)); + Logger.Write(typeof(BassAsioDevice), LogLevel.Debug, "Detected ASIO device: {0} => Rates => {1}", BassAsio.CurrentDevice, string.Join(", ", Info.SupportedRates)); } finally { @@ -170,14 +178,14 @@ public static void Free() AsioChannelResetFlags.Join | AsioChannelResetFlags.Format | AsioChannelResetFlags.Rate; - //Logger.Write(typeof(BassAsioDevice), LogLevel.Debug, "Resetting BASS ASIO channel attributes."); + Logger.Write(typeof(BassAsioDevice), LogLevel.Debug, "Resetting BASS ASIO channel attributes."); for (var channel = 0; channel < Info.Outputs; channel++) { BassAsio.ChannelReset(false, channel, flags); } } - //Logger.Write(typeof(BassAsioDevice), LogLevel.Debug, "Releasing BASS ASIO."); + Logger.Write(typeof(BassAsioDevice), LogLevel.Debug, "Releasing BASS ASIO."); BassAsio.Free(); BassAsioHandler.Free(); IsInitialized = false; @@ -219,7 +227,7 @@ public static float Volume { if (!BassAsio.ChannelSetVolume(false, MASTER_CHANNEL, value)) { - //Logger.Write(typeof(BassAsioDevice), LogLevel.Warn, "Cannot set volume, the device or driver probably doesn't support it."); + Logger.Write(typeof(BassAsioDevice), LogLevel.Warn, "Cannot set volume, the device or driver probably doesn't support it."); } } } diff --git a/FoxTunes.Output.Bass.Asio/BassAsioStreamOutput.cs b/FoxTunes.Output.Bass.Asio/BassAsioStreamOutput.cs index 2797a5184..d342e1f96 100644 --- a/FoxTunes.Output.Bass.Asio/BassAsioStreamOutput.cs +++ b/FoxTunes.Output.Bass.Asio/BassAsioStreamOutput.cs @@ -90,20 +90,20 @@ public override void Connect(IBassStreamComponent previous) this.ConfigureASIO(previous, out rate, out channels, out flags); if (this.ShouldCreateMixer(previous, rate, channels, flags)) { - //Logger.Write(this, LogLevel.Debug, "Creating BASS MIX stream with rate {0} and {1} channels.", rate, channels); + Logger.Write(this, LogLevel.Debug, "Creating BASS MIX stream with rate {0} and {1} channels.", rate, channels); this.ChannelHandle = BassMix.CreateMixerStream(rate, channels, flags); if (this.ChannelHandle == 0) { BassUtils.Throw(); } - //Logger.Write(this, LogLevel.Debug, "Adding stream to the mixer: {0}", previous.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Adding stream to the mixer: {0}", previous.ChannelHandle); BassUtils.OK(BassMix.MixerAddChannel(this.ChannelHandle, previous.ChannelHandle, BassFlags.Default | BassFlags.MixerBuffer | BassFlags.MixerDownMix)); BassUtils.OK(BassAsioHandler.StreamSet(this.ChannelHandle)); this.MixerChannelHandles.Add(previous.ChannelHandle); } else { - //Logger.Write(this, LogLevel.Debug, "The stream properties match the device, playing directly."); + Logger.Write(this, LogLevel.Debug, "The stream properties match the device, playing directly."); BassUtils.OK(BassAsioHandler.StreamSet(previous.ChannelHandle)); this.ChannelHandle = previous.ChannelHandle; } @@ -125,7 +125,7 @@ protected virtual void ConfigureASIO(IBassStreamComponent previous, out int rate if (!BassAsioDevice.Info.SupportedRates.Contains(targetRate)) { var nearestRate = BassAsioDevice.Info.GetNearestRate(targetRate); - //Logger.Write(this, LogLevel.Warn, "Enforced rate {0} isn't supposed by the device, falling back to {1}.", targetRate, nearestRate); + Logger.Write(this, LogLevel.Warn, "Enforced rate {0} isn't supposed by the device, falling back to {1}.", targetRate, nearestRate); rate = nearestRate; } else @@ -138,13 +138,13 @@ protected virtual void ConfigureASIO(IBassStreamComponent previous, out int rate if (!BassAsioDevice.Info.SupportedRates.Contains(rate)) { var nearestRate = BassAsioDevice.Info.GetNearestRate(rate); - //Logger.Write(this, LogLevel.Debug, "Stream rate {0} isn't supposed by the device, falling back to {1}.", rate, nearestRate); + Logger.Write(this, LogLevel.Debug, "Stream rate {0} isn't supposed by the device, falling back to {1}.", rate, nearestRate); rate = nearestRate; } } if (BassAsioDevice.Info.Outputs < channels) { - //Logger.Write(this, LogLevel.Debug, "Stream channel count {0} isn't supported by the device, falling back to {1} channels.", channels, BassAsioDevice.Info.Outputs); + Logger.Write(this, LogLevel.Debug, "Stream channel count {0} isn't supported by the device, falling back to {1} channels.", channels, BassAsioDevice.Info.Outputs); channels = BassAsioDevice.Info.Outputs; } } @@ -160,10 +160,10 @@ protected virtual bool StartASIO() { if (BassAsio.IsStarted) { - //Logger.Write(this, LogLevel.Debug, "ASIO has already been started."); + Logger.Write(this, LogLevel.Debug, "ASIO has already been started."); return false; } - //Logger.Write(this, LogLevel.Debug, "Starting ASIO."); + Logger.Write(this, LogLevel.Debug, "Starting ASIO."); BassUtils.OK(BassAsio.Start(BassAsio.Info.PreferredBufferLength)); return true; } @@ -172,10 +172,10 @@ protected virtual bool StopASIO() { if (!BassAsio.IsStarted) { - //Logger.Write(this, LogLevel.Debug, "ASIO has not been started."); + Logger.Write(this, LogLevel.Debug, "ASIO has not been started."); return false; } - //Logger.Write(this, LogLevel.Debug, "Stopping ASIO."); + Logger.Write(this, LogLevel.Debug, "Stopping ASIO."); BassAsioUtils.OK(BassAsio.Stop()); return true; } @@ -208,7 +208,7 @@ public override void ClearBuffer() { foreach (var channelHandle in this.MixerChannelHandles) { - //Logger.Write(this, LogLevel.Debug, "Clearing mixer buffer."); + Logger.Write(this, LogLevel.Debug, "Clearing mixer buffer."); Bass.ChannelSetPosition(channelHandle, 0); } base.ClearBuffer(); @@ -244,7 +244,7 @@ public override void Play() { return; } - //Logger.Write(this, LogLevel.Debug, "Starting ASIO."); + Logger.Write(this, LogLevel.Debug, "Starting ASIO."); try { BassAsioUtils.OK(this.StartASIO()); @@ -262,7 +262,7 @@ public override void Pause() { return; } - //Logger.Write(this, LogLevel.Debug, "Pausing ASIO."); + Logger.Write(this, LogLevel.Debug, "Pausing ASIO."); try { BassAsioUtils.OK(BassAsio.ChannelPause(false, BassAsioDevice.PRIMARY_CHANNEL)); @@ -280,7 +280,7 @@ public override void Resume() { return; } - //Logger.Write(this, LogLevel.Debug, "Resuming ASIO."); + Logger.Write(this, LogLevel.Debug, "Resuming ASIO."); try { BassAsioUtils.OK(BassAsio.ChannelReset(false, BassAsioDevice.PRIMARY_CHANNEL, AsioChannelResetFlags.Pause)); @@ -298,7 +298,7 @@ public override void Stop() { return; } - //Logger.Write(this, LogLevel.Debug, "Stopping ASIO."); + Logger.Write(this, LogLevel.Debug, "Stopping ASIO."); try { BassAsioUtils.OK(this.StopASIO()); @@ -336,7 +336,7 @@ protected override void OnDisposing() { foreach (var channelHandle in this.MixerChannelHandles) { - //Logger.Write(this, LogLevel.Debug, "Freeing BASS stream: {0}", channelHandle); + Logger.Write(this, LogLevel.Debug, "Freeing BASS stream: {0}", channelHandle); Bass.StreamFree(channelHandle); //Not checking result code as it contains an error if the application is shutting down. } this.Stop(); diff --git a/FoxTunes.Output.Bass.Asio/BassAsioStreamOutputBehaviour.cs b/FoxTunes.Output.Bass.Asio/BassAsioStreamOutputBehaviour.cs index 0046b65ca..8b8aefbae 100644 --- a/FoxTunes.Output.Bass.Asio/BassAsioStreamOutputBehaviour.cs +++ b/FoxTunes.Output.Bass.Asio/BassAsioStreamOutputBehaviour.cs @@ -50,7 +50,7 @@ public bool Enabled set { this._Enabled = value; - //Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); + Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); this.OutputDeviceManager.Restart(); } } @@ -66,7 +66,7 @@ public int AsioDevice set { this._AsioDevice = value; - //Logger.Write(this, LogLevel.Debug, "ASIO Device = {0}", this.AsioDevice); + Logger.Write(this, LogLevel.Debug, "ASIO Device = {0}", this.AsioDevice); this.OutputDeviceManager.Restart(); } } @@ -82,7 +82,7 @@ public bool DsdDirect private set { this._DsdDirect = value; - //Logger.Write(this, LogLevel.Debug, "DSD = {0}", this.DsdDirect); + Logger.Write(this, LogLevel.Debug, "DSD = {0}", this.DsdDirect); this.OutputDeviceManager.Restart(); } } @@ -98,7 +98,7 @@ public bool Mixer private set { this._Mixer = value; - //Logger.Write(this, LogLevel.Debug, "Mixer = {0}", this.Mixer); + Logger.Write(this, LogLevel.Debug, "Mixer = {0}", this.Mixer); this.OutputDeviceManager.Restart(); } } @@ -151,7 +151,7 @@ protected virtual void OnInit(object sender, EventArgs e) { BassAsioDevice.Detect(this.AsioDevice); } - //Logger.Write(this, LogLevel.Debug, "BASS (No Sound) Initialized."); + Logger.Write(this, LogLevel.Debug, "BASS (No Sound) Initialized."); } protected virtual void OnFree(object sender, EventArgs e) @@ -161,7 +161,7 @@ protected virtual void OnFree(object sender, EventArgs e) return; } this.OnFreeDevice(); - //Logger.Write(this, LogLevel.Debug, "Releasing BASS."); + LogManager.Logger.Write(this, LogLevel.Debug, "Releasing BASS."); Bass.Free(); this.IsInitialized = false; } @@ -276,7 +276,7 @@ protected virtual void OnDisposing() ~BassAsioStreamOutputBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.Asio/BassAsioStreamOutputConfiguration.cs b/FoxTunes.Output.Bass.Asio/BassAsioStreamOutputConfiguration.cs index 2cccf9496..bf0e3b70d 100644 --- a/FoxTunes.Output.Bass.Asio/BassAsioStreamOutputConfiguration.cs +++ b/FoxTunes.Output.Bass.Asio/BassAsioStreamOutputConfiguration.cs @@ -70,7 +70,7 @@ public static IEnumerable GetASIODevices() { var deviceInfo = default(AsioDeviceInfo); BassAsioUtils.OK(BassAsio.GetDeviceInfo(a, out deviceInfo)); - //Logger.Write(typeof(BassAsioStreamOutputConfiguration), LogLevel.Debug, "ASIO Device: {0} => {1} => {2}", a, deviceInfo.Name, deviceInfo.Driver); + LogManager.Logger.Write(typeof(BassAsioStreamOutputConfiguration), LogLevel.Debug, "ASIO Device: {0} => {1} => {2}", a, deviceInfo.Name, deviceInfo.Driver); yield return new SelectionConfigurationOption(deviceInfo.Name, deviceInfo.Name, deviceInfo.Driver); } } diff --git a/FoxTunes.Output.Bass.Cd/BassCdBehaviour.cs b/FoxTunes.Output.Bass.Cd/BassCdBehaviour.cs index 02231fd36..040637b27 100644 --- a/FoxTunes.Output.Bass.Cd/BassCdBehaviour.cs +++ b/FoxTunes.Output.Bass.Cd/BassCdBehaviour.cs @@ -53,7 +53,7 @@ public bool Enabled set { this._Enabled = value; - //Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); + Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); } } @@ -68,7 +68,7 @@ public bool CdLookup private set { this._CdLookup = value; - //Logger.Write(this, LogLevel.Debug, "CD Lookup = {0}", this.CdLookup); + Logger.Write(this, LogLevel.Debug, "CD Lookup = {0}", this.CdLookup); } } @@ -87,7 +87,7 @@ private set { foreach (var cdLookupHost in value) { - //Logger.Write(this, LogLevel.Debug, "CD Lookup Host = {0}", cdLookupHost); + Logger.Write(this, LogLevel.Debug, "CD Lookup Host = {0}", cdLookupHost); } } } @@ -150,7 +150,7 @@ protected virtual void OnCreatingPipeline(object sender, CreatingPipelineEventAr } if (e.Input != null) { - //Logger.Write(this, LogLevel.Debug, "Overriding the default pipeline input: {0}", e.Input.GetType().Name); + Logger.Write(this, LogLevel.Debug, "Overriding the default pipeline input: {0}", e.Input.GetType().Name); e.Input.Dispose(); } e.Input = new BassCdStreamInput(this, drive, e.Pipeline, e.Stream.Flags); @@ -161,7 +161,7 @@ protected virtual void OnStateChanged(object sender, EventArgs e) { if (this.Output.IsStarted && this.DoorMonitor.State == CdDoorState.Open) { - //Logger.Write(this, LogLevel.Debug, "CD door was opened, shutting down the output."); + Logger.Write(this, LogLevel.Debug, "CD door was opened, shutting down the output."); this.Output.Shutdown(); } } @@ -255,7 +255,7 @@ protected virtual void OnDisposing() ~BassCdBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); @@ -344,7 +344,7 @@ private async Task AddPlaylistItems(Playlist playlist, IEnumerable var position = 0; foreach (var playlistItem in playlistItems) { - //Logger.Write(this, LogLevel.Debug, "Adding file to playlist: {0}", playlistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Adding file to playlist: {0}", playlistItem.FileName); playlistItem.Playlist_Id = playlist.Id; playlistItem.Sequence = this.Sequence + position; playlistItem.Status = PlaylistItemStatus.Import; diff --git a/FoxTunes.Output.Bass.Cd/BassCdStreamInput.cs b/FoxTunes.Output.Bass.Cd/BassCdStreamInput.cs index c81f9ba29..317d80674 100644 --- a/FoxTunes.Output.Bass.Cd/BassCdStreamInput.cs +++ b/FoxTunes.Output.Bass.Cd/BassCdStreamInput.cs @@ -82,7 +82,7 @@ public bool SetTrack(int track, out int channelHandle) } if (BassCd.StreamGetTrack(channelHandle) != track) { - //Logger.Write(this, LogLevel.Debug, "Switching CD track: {0}", track); + Logger.Write(this, LogLevel.Debug, "Switching CD track: {0}", track); BassUtils.OK(BassCd.StreamSetTrack(channelHandle, track)); } return true; @@ -94,7 +94,7 @@ public override void Connect(BassOutputStream stream) BassUtils.OK(BassGapless.SetConfig(BassGaplessAttriubute.RecycleStream, true)); BassUtils.OK(BassGapless.ChannelEnqueue(stream.ChannelHandle)); BassUtils.OK(BassGapless.Cd.Enable(this.Drive, stream.Flags)); - //Logger.Write(this, LogLevel.Debug, "Creating BASS GAPLESS stream with rate {0} and {1} channels.", stream.Rate, stream.Channels); + Logger.Write(this, LogLevel.Debug, "Creating BASS GAPLESS stream with rate {0} and {1} channels.", stream.Rate, stream.Channels); this.ChannelHandle = BassGapless.StreamCreate(stream.Rate, stream.Channels, stream.Flags); if (this.ChannelHandle == 0) { @@ -129,10 +129,10 @@ public override bool Remove(BassOutputStream stream, Action ca public override void Reset() { - //Logger.Write(this, LogLevel.Debug, "Resetting the queue."); + Logger.Write(this, LogLevel.Debug, "Resetting the queue."); foreach (var channelHandle in this.Queue) { - //Logger.Write(this, LogLevel.Debug, "Removing stream from the queue: {0}", channelHandle); + Logger.Write(this, LogLevel.Debug, "Removing stream from the queue: {0}", channelHandle); BassGapless.ChannelRemove(channelHandle); Bass.StreamFree(channelHandle); } @@ -143,7 +143,7 @@ protected override void OnDisposing() if (this.ChannelHandle != 0) { this.Reset(); - //Logger.Write(this, LogLevel.Debug, "Freeing BASS GAPLESS stream: {0}", this.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Freeing BASS GAPLESS stream: {0}", this.ChannelHandle); Bass.StreamFree(this.ChannelHandle); //Not checking result code as it contains an error if the application is shutting down. } BassGapless.Cd.Disable(); diff --git a/FoxTunes.Output.Bass.Cd/BassCdStreamProvider.cs b/FoxTunes.Output.Bass.Cd/BassCdStreamProvider.cs index 92fc8fc17..4710d7d81 100644 --- a/FoxTunes.Output.Bass.Cd/BassCdStreamProvider.cs +++ b/FoxTunes.Output.Bass.Cd/BassCdStreamProvider.cs @@ -65,7 +65,7 @@ public override IBassStream CreateBasicStream(PlaylistItem playlistItem, IEnumer } if (channelHandle == 0) { - //Logger.Write(this, LogLevel.Warn, "Failed to create CD stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); + Logger.Write(this, LogLevel.Warn, "Failed to create CD stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); } return this.CreateBasicStream(channelHandle, advice, flags); } @@ -118,7 +118,7 @@ public override IBassStream CreateInteractiveStream(PlaylistItem playlistItem, I } if (channelHandle == 0) { - //Logger.Write(this, LogLevel.Warn, "Failed to create CD stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); + Logger.Write(this, LogLevel.Warn, "Failed to create CD stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); } return this.CreateInteractiveStream(channelHandle, advice, flags); } diff --git a/FoxTunes.Output.Bass.Cd/Strategies/BassCdMetaDataSourceCdTextStrategy.cs b/FoxTunes.Output.Bass.Cd/Strategies/BassCdMetaDataSourceCdTextStrategy.cs index 6239bb57e..774ea3e5c 100644 --- a/FoxTunes.Output.Bass.Cd/Strategies/BassCdMetaDataSourceCdTextStrategy.cs +++ b/FoxTunes.Output.Bass.Cd/Strategies/BassCdMetaDataSourceCdTextStrategy.cs @@ -27,17 +27,17 @@ public BassCdMetaDataSourceCdTextStrategy(int drive) public override bool Fetch() { - //Logger.Write(this, LogLevel.Debug, "Querying CD-TEXT for drive {0}...", this.Drive); + Logger.Write(this, LogLevel.Debug, "Querying CD-TEXT for drive {0}...", this.Drive); lock (SyncRoot) { this.Parser = new CdTextParser(BassCd.GetIDText(this.Drive)); } if (this.Parser.Count > 0) { - //Logger.Write(this, LogLevel.Debug, "CD-TEXT contains {0} records for drive {1}.", this.Parser.Count, this.Drive); + Logger.Write(this, LogLevel.Debug, "CD-TEXT contains {0} records for drive {1}.", this.Parser.Count, this.Drive); return true; } - //Logger.Write(this, LogLevel.Debug, "CD-TEXT was empty for drive {0}.", this.Drive); + Logger.Write(this, LogLevel.Debug, "CD-TEXT was empty for drive {0}.", this.Drive); return base.Fetch(); } diff --git a/FoxTunes.Output.Bass.Cd/Strategies/BassCdMetaDataSourceCddaStrategy.cs b/FoxTunes.Output.Bass.Cd/Strategies/BassCdMetaDataSourceCddaStrategy.cs index bf2d2b551..8859770f0 100644 --- a/FoxTunes.Output.Bass.Cd/Strategies/BassCdMetaDataSourceCddaStrategy.cs +++ b/FoxTunes.Output.Bass.Cd/Strategies/BassCdMetaDataSourceCddaStrategy.cs @@ -30,35 +30,35 @@ public BassCdMetaDataSourceCddaStrategy(int drive, IEnumerable hosts) public override bool Fetch() { - //Logger.Write(this, LogLevel.Debug, "Querying CDDB for drive {0}...", this.Drive); + Logger.Write(this, LogLevel.Debug, "Querying CDDB for drive {0}...", this.Drive); foreach (var host in this.Hosts) { try { lock (SyncRoot) { - //Logger.Write(this, LogLevel.Debug, "Using CDDB host: {0}", host); + Logger.Write(this, LogLevel.Debug, "Using CDDB host: {0}", host); if (!string.Equals(BassCd.CDDBServer, host, StringComparison.OrdinalIgnoreCase)) { BassCd.CDDBServer = host; } var id = BassCd.GetID(this.Drive, CDID.CDDB); - //Logger.Write(this, LogLevel.Debug, "CDDB identifier is \"{0}\" for drive {1}.", id, this.Drive); + Logger.Write(this, LogLevel.Debug, "CDDB identifier is \"{0}\" for drive {1}.", id, this.Drive); var sequence = BassCd.GetID(this.Drive, CDID.Read); this.Parser = new CddbTextParser(id, sequence); if (this.Parser.Count > 0) { - //Logger.Write(this, LogLevel.Debug, "CDDB returned {0} records for drive {1}.", this.Parser.Count, this.Drive); + Logger.Write(this, LogLevel.Debug, "CDDB returned {0} records for drive {1}.", this.Parser.Count, this.Drive); return true; } } } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to query CDDB for drive {0}: {1}", this.Drive, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to query CDDB for drive {0}: {1}", this.Drive, e.Message); } } - //Logger.Write(this, LogLevel.Debug, "CDDB was empty for drive {0}.", this.Drive); + Logger.Write(this, LogLevel.Debug, "CDDB was empty for drive {0}.", this.Drive); return base.Fetch(); } diff --git a/FoxTunes.Output.Bass.Cd/Utilities/CdDoorMonitor.cs b/FoxTunes.Output.Bass.Cd/Utilities/CdDoorMonitor.cs index daf068fef..03af03bb4 100644 --- a/FoxTunes.Output.Bass.Cd/Utilities/CdDoorMonitor.cs +++ b/FoxTunes.Output.Bass.Cd/Utilities/CdDoorMonitor.cs @@ -45,7 +45,7 @@ public CdDoorState State protected virtual void OnStateChanged() { - //Logger.Write(this, LogLevel.Debug, "CD door state changed to {0}.", Enum.GetName(typeof(CdDoorState), this.State)); + Logger.Write(this, LogLevel.Debug, "CD door state changed to {0}.", Enum.GetName(typeof(CdDoorState), this.State)); if (this.StateChanged == null) { return; @@ -94,7 +94,7 @@ public void Enable() this.Timer.Elapsed += this.OnElapsed; this.Timer.Start(); } - //Logger.Write(this, LogLevel.Debug, "Started monitoring CD door state."); + Logger.Write(this, LogLevel.Debug, "Started monitoring CD door state."); this.UpdateState(false); } @@ -114,7 +114,7 @@ public void Disable() this.Timer = null; } } - //Logger.Write(this, LogLevel.Debug, "Stopped monitoring CD door state."); + Logger.Write(this, LogLevel.Debug, "Stopped monitoring CD door state."); } protected virtual void OnElapsed(object sender, ElapsedEventArgs e) @@ -205,7 +205,7 @@ protected virtual void OnDisposing() ~CdDoorMonitor() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.Cd/Utilities/CdPlaylistItemFactory.cs b/FoxTunes.Output.Bass.Cd/Utilities/CdPlaylistItemFactory.cs index 4ea5fcaf8..678a542ed 100644 --- a/FoxTunes.Output.Bass.Cd/Utilities/CdPlaylistItemFactory.cs +++ b/FoxTunes.Output.Bass.Cd/Utilities/CdPlaylistItemFactory.cs @@ -68,12 +68,12 @@ public async Task Create(CancellationToken cancellationToken) await this.MetaDataSource.GetMetaData(fileName).ConfigureAwait(false) ).ToArray(); } - catch + catch (Exception e) { metaData = new MetaDataItem[] { }; - //Logger.Write(this, LogLevel.Debug, "Failed to read meta data from file \"{0}\": {1}", fileName, e.Message); + Logger.Write(this, LogLevel.Debug, "Failed to read meta data from file \"{0}\": {1}", fileName, e.Message); } - //Logger.Write(this, LogLevel.Debug, "Adding file to playlist: {0}", fileName); + Logger.Write(this, LogLevel.Debug, "Adding file to playlist: {0}", fileName); var playlistItem = new PlaylistItem() { DirectoryName = directoryName, diff --git a/FoxTunes.Output.Bass.Cd/Utilities/CdTextParser.cs b/FoxTunes.Output.Bass.Cd/Utilities/CdTextParser.cs index 4950a11ff..3ea2d805e 100644 --- a/FoxTunes.Output.Bass.Cd/Utilities/CdTextParser.cs +++ b/FoxTunes.Output.Bass.Cd/Utilities/CdTextParser.cs @@ -78,7 +78,7 @@ private static void AddValue(IDictionary> value { values[track] = new Dictionary(); } - //Logger.Write(typeof(CdTextParser), LogLevel.Trace, "Got CD-TEXT tag for track {0} => {1} => {2}", track, name, value); + LogManager.Logger.Write(typeof(CdTextParser), LogLevel.Trace, "Got CD-TEXT tag for track {0} => {1} => {2}", track, name, value); values[track][name] = value; } } diff --git a/FoxTunes.Output.Bass.Cd/Utilities/CddbTextParser.cs b/FoxTunes.Output.Bass.Cd/Utilities/CddbTextParser.cs index 786827258..3786f477e 100644 --- a/FoxTunes.Output.Bass.Cd/Utilities/CddbTextParser.cs +++ b/FoxTunes.Output.Bass.Cd/Utilities/CddbTextParser.cs @@ -87,7 +87,7 @@ private static void AddValue(IDictionary> value return; } } - //Logger.Write(typeof(CddbTextParser), LogLevel.Trace, "Got CDDB tag for track {0} => {1} => {2}", track, name, value); + LogManager.Logger.Write(typeof(CddbTextParser), LogLevel.Trace, "Got CDDB tag for track {0} => {1} => {2}", track, name, value); values[track][name] = value; } } diff --git a/FoxTunes.Output.Bass.Crossfade/BassCrossfadeStreamInput.cs b/FoxTunes.Output.Bass.Crossfade/BassCrossfadeStreamInput.cs index a90846f0c..6d58a4151 100644 --- a/FoxTunes.Output.Bass.Crossfade/BassCrossfadeStreamInput.cs +++ b/FoxTunes.Output.Bass.Crossfade/BassCrossfadeStreamInput.cs @@ -80,7 +80,7 @@ public override bool PreserveBuffer public override void Connect(BassOutputStream stream) { - //Logger.Write(this, LogLevel.Debug, "Creating BASS CROSSFADE stream with rate {0} and {1} channels.", stream.Rate, stream.Channels); + Logger.Write(this, LogLevel.Debug, "Creating BASS CROSSFADE stream with rate {0} and {1} channels.", stream.Rate, stream.Channels); this.ChannelHandle = BassCrossfade.StreamCreate(stream.Rate, stream.Channels, stream.Flags | BassFlags.MixerNonStop); if (this.ChannelHandle == 0) { @@ -113,14 +113,14 @@ public override bool Add(BassOutputStream stream, Action callB { if (this.Queue.Contains(stream.ChannelHandle)) { - //Logger.Write(this, LogLevel.Debug, "Stream is already enqueued: {0}", stream.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Stream is already enqueued: {0}", stream.ChannelHandle); return false; } - //Logger.Write(this, LogLevel.Debug, "Adding stream to the queue: {0}", stream.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Adding stream to the queue: {0}", stream.ChannelHandle); var flags = BassCrossfadeFlags.Default; if (this.IsStarting && this.Behaviour.Start) { - //Logger.Write(this, LogLevel.Debug, "Fading in..."); + Logger.Write(this, LogLevel.Debug, "Fading in..."); flags = BassCrossfadeFlags.FadeIn; } this.Dispatch(() => @@ -138,16 +138,16 @@ public override bool Remove(BassOutputStream stream, Action ca { if (!this.Queue.Contains(stream.ChannelHandle)) { - //Logger.Write(this, LogLevel.Debug, "Stream is not enqueued: {0}", stream.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Stream is not enqueued: {0}", stream.ChannelHandle); return false; } - //Logger.Write(this, LogLevel.Debug, "Removing stream from the queue: {0}", stream.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Removing stream from the queue: {0}", stream.ChannelHandle); var flags = BassCrossfadeFlags.Default; if (this.Pipeline.Output.IsPlaying) { if (this.IsStopping && this.Behaviour.Stop) { - //Logger.Write(this, LogLevel.Debug, "Fading out..."); + Logger.Write(this, LogLevel.Debug, "Fading out..."); flags = BassCrossfadeFlags.FadeOut; } } @@ -168,7 +168,7 @@ public override bool Remove(BassOutputStream stream, Action ca public override void ClearBuffer() { - //Logger.Write(this, LogLevel.Debug, "Clearing mixer buffer."); + Logger.Write(this, LogLevel.Debug, "Clearing mixer buffer."); Bass.ChannelSetPosition(this.ChannelHandle, 0); base.ClearBuffer(); } @@ -178,23 +178,23 @@ protected virtual void WaitForBuffer() var bufferLength = this.Pipeline.BufferLength; if (bufferLength > 0) { - //Logger.Write(this, LogLevel.Debug, "Buffer length is {0}ms, waiting..", bufferLength); + Logger.Write(this, LogLevel.Debug, "Buffer length is {0}ms, waiting..", bufferLength); Thread.Sleep(bufferLength); } } public override void Reset() { - //Logger.Write(this, LogLevel.Debug, "Resetting the queue."); + Logger.Write(this, LogLevel.Debug, "Resetting the queue."); foreach (var channelHandle in this.Queue) { - //Logger.Write(this, LogLevel.Debug, "Removing stream from the queue: {0}", channelHandle); + Logger.Write(this, LogLevel.Debug, "Removing stream from the queue: {0}", channelHandle); var flags = BassCrossfadeFlags.Default; if (this.Pipeline.Output.IsPlaying) { if (this.IsStopping && this.Behaviour.Stop) { - //Logger.Write(this, LogLevel.Debug, "Fading out..."); + Logger.Write(this, LogLevel.Debug, "Fading out..."); flags = BassCrossfadeFlags.FadeOut; } } @@ -215,7 +215,7 @@ protected override void OnDisposing() if (this.ChannelHandle != 0) { this.Reset(); - //Logger.Write(this, LogLevel.Debug, "Freeing BASS CROSSFADE stream: {0}", this.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Freeing BASS CROSSFADE stream: {0}", this.ChannelHandle); Bass.StreamFree(this.ChannelHandle); //Not checking result code as it contains an error if the application is shutting down. } } @@ -233,7 +233,7 @@ public void PreviewPause() { if (this.Behaviour.PauseResume) { - //Logger.Write(this, LogLevel.Debug, "Fading out..."); + Logger.Write(this, LogLevel.Debug, "Fading out..."); this.Fading = true; BassCrossfade.StreamFadeOut(); this.WaitForBuffer(); @@ -244,7 +244,7 @@ public void PreviewResume() { if (this.Fading || this.Behaviour.PauseResume) { - //Logger.Write(this, LogLevel.Debug, "Fading in..."); + Logger.Write(this, LogLevel.Debug, "Fading in..."); this.Fading = false; BassCrossfade.StreamFadeIn(); } diff --git a/FoxTunes.Output.Bass.Crossfade/BassCrossfadeStreamInputBehaviour.cs b/FoxTunes.Output.Bass.Crossfade/BassCrossfadeStreamInputBehaviour.cs index fe917aafc..ea07abf60 100644 --- a/FoxTunes.Output.Bass.Crossfade/BassCrossfadeStreamInputBehaviour.cs +++ b/FoxTunes.Output.Bass.Crossfade/BassCrossfadeStreamInputBehaviour.cs @@ -42,7 +42,7 @@ public bool Enabled set { this._Enabled = value; - //Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); + Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); var task = this.Output.Shutdown(); } } @@ -56,7 +56,7 @@ public BassCrossfadeMode Mode set { BassCrossfade.Mode = value; - //Logger.Write(this, LogLevel.Debug, "Mode = {0}", Enum.GetName(typeof(BassCrossfadeMode), this.Mode)); + Logger.Write(this, LogLevel.Debug, "Mode = {0}", Enum.GetName(typeof(BassCrossfadeMode), this.Mode)); } } @@ -69,7 +69,7 @@ public int InPeriod set { BassCrossfade.InPeriod = value; - //Logger.Write(this, LogLevel.Debug, "InPeriod = {0}", this.InPeriod); + Logger.Write(this, LogLevel.Debug, "InPeriod = {0}", this.InPeriod); } } @@ -82,7 +82,7 @@ public int OutPeriod set { BassCrossfade.OutPeriod = value; - //Logger.Write(this, LogLevel.Debug, "OutPeriod = {0}", this.OutPeriod); + Logger.Write(this, LogLevel.Debug, "OutPeriod = {0}", this.OutPeriod); } } @@ -95,7 +95,7 @@ public BassCrossfadeType InType set { BassCrossfade.InType = value; - //Logger.Write(this, LogLevel.Debug, "InType = {0}", Enum.GetName(typeof(BassCrossfadeType), this.InType)); + Logger.Write(this, LogLevel.Debug, "InType = {0}", Enum.GetName(typeof(BassCrossfadeType), this.InType)); } } @@ -108,7 +108,7 @@ public BassCrossfadeType OutType set { BassCrossfade.OutType = value; - //Logger.Write(this, LogLevel.Debug, "OutType = {0}", Enum.GetName(typeof(BassCrossfadeType), this.OutType)); + Logger.Write(this, LogLevel.Debug, "OutType = {0}", Enum.GetName(typeof(BassCrossfadeType), this.OutType)); } } @@ -121,7 +121,7 @@ public bool Mix set { BassCrossfade.Mix = value; - //Logger.Write(this, LogLevel.Debug, "Mix = {0}", this.Mix); + Logger.Write(this, LogLevel.Debug, "Mix = {0}", this.Mix); } } @@ -136,7 +136,7 @@ public bool Start set { this._Start = value; - //Logger.Write(this, LogLevel.Debug, "Start = {0}", this.Start); + Logger.Write(this, LogLevel.Debug, "Start = {0}", this.Start); } } @@ -151,7 +151,7 @@ public bool PauseResume set { this._PauseResume = value; - //Logger.Write(this, LogLevel.Debug, "Pause/Resume = {0}", this.PauseResume); + Logger.Write(this, LogLevel.Debug, "Pause/Resume = {0}", this.PauseResume); } } @@ -166,7 +166,7 @@ public bool Stop set { this._Stop = value; - //Logger.Write(this, LogLevel.Debug, "Stop = {0}", this.Stop); + Logger.Write(this, LogLevel.Debug, "Stop = {0}", this.Stop); } } @@ -179,7 +179,7 @@ public bool Buffer set { BassCrossfade.Buffer = value; - //Logger.Write(this, LogLevel.Debug, "Buffer = {0}", this.Mix); + Logger.Write(this, LogLevel.Debug, "Buffer = {0}", this.Mix); } } @@ -245,7 +245,7 @@ protected virtual void OnCreatingPipeline(object sender, CreatingPipelineEventAr } if (!BassCrossfadeStreamInput.CanCreate(this, e.Stream, e.Query)) { - //Logger.Write(this, LogLevel.Warn, "Cannot create input, the stream is not supported."); + Logger.Write(this, LogLevel.Warn, "Cannot create input, the stream is not supported."); throw new InvalidOperationException(Strings.BassCrossfadeStreamInputBehaviour_Unsupported); } e.Input = new BassCrossfadeStreamInput(this, e.Pipeline, e.Stream.Flags); @@ -285,7 +285,7 @@ protected virtual void OnDisposing() ~BassCrossfadeStreamInputBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.Cue/BassCueStreamAdvisor.cs b/FoxTunes.Output.Bass.Cue/BassCueStreamAdvisor.cs index e67f4470d..5062f1892 100644 --- a/FoxTunes.Output.Bass.Cue/BassCueStreamAdvisor.cs +++ b/FoxTunes.Output.Bass.Cue/BassCueStreamAdvisor.cs @@ -35,9 +35,9 @@ public override void Advise(IBassStreamProvider provider, PlaylistItem playlistI } advice.Add(new BassCueStreamAdvice(fileName, offset, length)); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to create stream advice for file \"{0}\": {1}", playlistItem.FileName, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to create stream advice for file \"{0}\": {1}", playlistItem.FileName, e.Message); } } diff --git a/FoxTunes.Output.Bass.Cue/BassCueStreamAdvisorBehaviour.cs b/FoxTunes.Output.Bass.Cue/BassCueStreamAdvisorBehaviour.cs index 47d0e48d0..7a63c9108 100644 --- a/FoxTunes.Output.Bass.Cue/BassCueStreamAdvisorBehaviour.cs +++ b/FoxTunes.Output.Bass.Cue/BassCueStreamAdvisorBehaviour.cs @@ -60,7 +60,7 @@ public bool Enabled set { this._Enabled = value; - //Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); + Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); } } @@ -246,7 +246,7 @@ protected virtual void OnDisposing() ~BassCueStreamAdvisorBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); @@ -312,7 +312,7 @@ protected override async Task AddPlaylistItems(IEnumerable playlis var position = 0; foreach (var playlistItem in playlistItems) { - //Logger.Write(this, LogLevel.Debug, "Adding file to playlist: {0}", playlistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Adding file to playlist: {0}", playlistItem.FileName); playlistItem.Playlist_Id = this.Playlist.Id; playlistItem.Sequence = this.Sequence + position; playlistItem.Status = PlaylistItemStatus.Import; @@ -397,7 +397,7 @@ private async Task RemoveLibraryItems() var libraryItems = set.Where(libraryItem => libraryItem.DirectoryName == this.FileName); foreach (var libraryItem in libraryItems) { - //Logger.Write(this, LogLevel.Debug, "Removing file from library: {0}", libraryItem.FileName); + Logger.Write(this, LogLevel.Debug, "Removing file from library: {0}", libraryItem.FileName); libraryItem.Status = LibraryItemStatus.Remove; await set.AddOrUpdateAsync(libraryItem).ConfigureAwait(false); cleanup = true; @@ -420,7 +420,7 @@ private async Task AddLibraryItems(LibraryItem[] libraryItems) var set = this.Database.Set(transaction); foreach (var libraryItem in libraryItems) { - //Logger.Write(this, LogLevel.Debug, "Adding file to library: {0}", libraryItem.FileName); + Logger.Write(this, LogLevel.Debug, "Adding file to library: {0}", libraryItem.FileName); libraryItem.Status = LibraryItemStatus.Import; libraryItem.SetImportDate(DateTime.UtcNow); await set.AddAsync(libraryItem).ConfigureAwait(false); diff --git a/FoxTunes.Output.Bass.Cue/BassSkipSilenceStreamAdvisor.cs b/FoxTunes.Output.Bass.Cue/BassSkipSilenceStreamAdvisor.cs index 0d118d760..cd5f999b3 100644 --- a/FoxTunes.Output.Bass.Cue/BassSkipSilenceStreamAdvisor.cs +++ b/FoxTunes.Output.Bass.Cue/BassSkipSilenceStreamAdvisor.cs @@ -45,9 +45,9 @@ public override void Advise(IBassStreamProvider provider, PlaylistItem playlistI } advice.Add(new BassSkipSilenceStreamAdvice(playlistItem.FileName, leadIn, leadOut)); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to create stream advice for file \"{0}\": {1}", playlistItem.FileName, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to create stream advice for file \"{0}\": {1}", playlistItem.FileName, e.Message); } } @@ -70,7 +70,7 @@ protected virtual bool TryGetSilence(IBassStreamProvider provider, PlaylistItem protected virtual Task UpdateMetaData(PlaylistItem playlistItem, TimeSpan leadIn, TimeSpan leadOut) { - //Logger.Write(this, LogLevel.Debug, "Updating lead in/out meta data for file \"{0}\".", playlistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Updating lead in/out meta data for file \"{0}\".", playlistItem.FileName); var leadInMetaDataItem = default(MetaDataItem); var leadOutMetaDataItem = default(MetaDataItem); @@ -111,19 +111,19 @@ protected virtual bool TryCalculateSilence(IBassStreamProvider provider, Playlis { if (provider.Flags.HasFlag(BassStreamProviderFlags.Serial)) { - //Logger.Write(this, LogLevel.Debug, "Cannot calculate lead in/out for file \"{0}\": The provider does not support this action.", playlistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Cannot calculate lead in/out for file \"{0}\": The provider does not support this action.", playlistItem.FileName); leadIn = default(TimeSpan); leadOut = default(TimeSpan); return false; } - //Logger.Write(this, LogLevel.Debug, "Attempting to calculate lead in/out for file \"{0}\".", playlistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Attempting to calculate lead in/out for file \"{0}\".", playlistItem.FileName); var stream = provider.CreateBasicStream(playlistItem, advice, BassFlags.Decode | BassFlags.Byte); if (stream.IsEmpty) { - //Logger.Write(this, LogLevel.Warn, "Failed to create stream for file \"{0}\": {1}", playlistItem.FileName, Enum.GetName(typeof(Errors), Bass.LastError)); + Logger.Write(this, LogLevel.Warn, "Failed to create stream for file \"{0}\": {1}", playlistItem.FileName, Enum.GetName(typeof(Errors), Bass.LastError)); leadIn = default(TimeSpan); leadOut = default(TimeSpan); @@ -134,7 +134,7 @@ protected virtual bool TryCalculateSilence(IBassStreamProvider provider, Playlis var leadInBytes = this.GetLeadIn(stream, this.Behaviour.Threshold); if (leadInBytes == -1) { - //Logger.Write(this, LogLevel.Warn, "Failed to calculate lead in for file \"{0}\": Track was considered silent.", playlistItem.FileName); + Logger.Write(this, LogLevel.Warn, "Failed to calculate lead in for file \"{0}\": Track was considered silent.", playlistItem.FileName); leadIn = default(TimeSpan); leadOut = default(TimeSpan); @@ -143,7 +143,7 @@ protected virtual bool TryCalculateSilence(IBassStreamProvider provider, Playlis var leadOutBytes = this.GetLeadOut(stream, this.Behaviour.Threshold); if (leadOutBytes == -1) { - //Logger.Write(this, LogLevel.Warn, "Failed to calculate lead out for file \"{0}\": Track was considered silent.", playlistItem.FileName); + Logger.Write(this, LogLevel.Warn, "Failed to calculate lead out for file \"{0}\": Track was considered silent.", playlistItem.FileName); leadIn = default(TimeSpan); leadOut = default(TimeSpan); @@ -162,7 +162,7 @@ protected virtual bool TryCalculateSilence(IBassStreamProvider provider, Playlis ) ); - //Logger.Write(this, LogLevel.Debug, "Successfully calculated lead in/out for file \"{0}\": {1}/{2}", playlistItem.FileName, leadIn, leadOut); + Logger.Write(this, LogLevel.Debug, "Successfully calculated lead in/out for file \"{0}\": {1}/{2}", playlistItem.FileName, leadIn, leadOut); return true; } @@ -174,7 +174,7 @@ protected virtual bool TryCalculateSilence(IBassStreamProvider provider, Playlis protected virtual long GetLeadIn(IBassStream stream, int threshold) { - //Logger.Write(this, LogLevel.Debug, "Attempting to calculate lead in for channel {0} with window of {1} seconds and threshold of {2}dB.", stream.ChannelHandle, WINDOW, threshold); + Logger.Write(this, LogLevel.Debug, "Attempting to calculate lead in for channel {0} with window of {1} seconds and threshold of {2}dB.", stream.ChannelHandle, WINDOW, threshold); var length = Bass.ChannelSeconds2Bytes( stream.ChannelHandle, @@ -183,7 +183,7 @@ protected virtual long GetLeadIn(IBassStream stream, int threshold) var position = 0; if (!this.TrySetPosition(stream, position)) { - //Logger.Write(this, LogLevel.Warn, "Failed to synchronize channel {0}, bad plugin? This is very expensive!", stream.ChannelHandle); + Logger.Write(this, LogLevel.Warn, "Failed to synchronize channel {0}, bad plugin? This is very expensive!", stream.ChannelHandle); //Track won't synchronize. MOD files seem to have this problem. return -1; @@ -193,7 +193,7 @@ protected virtual long GetLeadIn(IBassStream stream, int threshold) var levels = new float[1]; if (!Bass.ChannelGetLevel(stream.ChannelHandle, levels, WINDOW, LevelRetrievalFlags.Mono | LevelRetrievalFlags.RMS)) { - //Logger.Write(this, LogLevel.Warn, "Failed to get levels for channel {0}: {1}", stream.ChannelHandle, Enum.GetName(typeof(Errors), Bass.LastError)); + Logger.Write(this, LogLevel.Warn, "Failed to get levels for channel {0}: {1}", stream.ChannelHandle, Enum.GetName(typeof(Errors), Bass.LastError)); break; } @@ -207,11 +207,11 @@ protected virtual long GetLeadIn(IBassStream stream, int threshold) if (leadIn > 0) { - //Logger.Write(this, LogLevel.Debug, "Successfully calculated lead in for channel {0}: {1} bytes.", stream.ChannelHandle, leadIn); + Logger.Write(this, LogLevel.Debug, "Successfully calculated lead in for channel {0}: {1} bytes.", stream.ChannelHandle, leadIn); } else { - //Logger.Write(this, LogLevel.Debug, "Successfully calculated lead in for channel {0}: None.", stream.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Successfully calculated lead in for channel {0}: None.", stream.ChannelHandle); } return leadIn; @@ -223,7 +223,7 @@ protected virtual long GetLeadIn(IBassStream stream, int threshold) protected virtual long GetLeadOut(IBassStream stream, int threshold) { - //Logger.Write(this, LogLevel.Debug, "Attempting to calculate lead out for channel {0} with window of {1} seconds and threshold of {2}dB.", stream.ChannelHandle, WINDOW, threshold); + Logger.Write(this, LogLevel.Debug, "Attempting to calculate lead out for channel {0} with window of {1} seconds and threshold of {2}dB.", stream.ChannelHandle, WINDOW, threshold); var length = Bass.ChannelSeconds2Bytes( stream.ChannelHandle, @@ -231,7 +231,7 @@ protected virtual long GetLeadOut(IBassStream stream, int threshold) ); if (!this.TrySetPosition(stream, stream.Length - (length * 2))) { - //Logger.Write(this, LogLevel.Warn, "Failed to synchronize channel {0}, bad plugin? This is very expensive!", stream.ChannelHandle); + Logger.Write(this, LogLevel.Warn, "Failed to synchronize channel {0}, bad plugin? This is very expensive!", stream.ChannelHandle); //Track won't synchronize. MOD files seem to have this problem. return -1; @@ -241,7 +241,7 @@ protected virtual long GetLeadOut(IBassStream stream, int threshold) var levels = new float[1]; if (!Bass.ChannelGetLevel(stream.ChannelHandle, levels, WINDOW, LevelRetrievalFlags.Mono | LevelRetrievalFlags.RMS)) { - //Logger.Write(this, LogLevel.Warn, "Failed to get levels for channel {0}: {1}", stream.ChannelHandle, Enum.GetName(typeof(Errors), Bass.LastError)); + Logger.Write(this, LogLevel.Warn, "Failed to get levels for channel {0}: {1}", stream.ChannelHandle, Enum.GetName(typeof(Errors), Bass.LastError)); break; } @@ -255,11 +255,11 @@ protected virtual long GetLeadOut(IBassStream stream, int threshold) if (leadOut > 0) { - //Logger.Write(this, LogLevel.Debug, "Successfully calculated lead out for channel {0}: {1} bytes.", stream.ChannelHandle, leadOut); + Logger.Write(this, LogLevel.Debug, "Successfully calculated lead out for channel {0}: {1} bytes.", stream.ChannelHandle, leadOut); } else { - //Logger.Write(this, LogLevel.Debug, "Successfully calculated lead out for channel {0}: None.", stream.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Successfully calculated lead out for channel {0}: None.", stream.ChannelHandle); } return leadOut; @@ -288,7 +288,7 @@ protected virtual bool TryGetMetaData(BassSkipSilenceStreamAdvisorBehaviour beha return false; } - //Logger.Write(typeof(BassSkipSilenceStreamAdvisor), LogLevel.Debug, "Attempting to fetch lead in/out for file \"{0}\" from meta data.", playlistItem.FileName); + Logger.Write(typeof(BassSkipSilenceStreamAdvisor), LogLevel.Debug, "Attempting to fetch lead in/out for file \"{0}\" from meta data.", playlistItem.FileName); var leadInMetaDataItem = default(MetaDataItem); var leadOutMetaDataItem = default(MetaDataItem); @@ -302,7 +302,7 @@ protected virtual bool TryGetMetaData(BassSkipSilenceStreamAdvisorBehaviour beha metaDatas.TryGetValue(CustomMetaData.LeadOut, out leadOutMetaDataItem); if (leadInMetaDataItem == null && leadOutMetaDataItem == null) { - //Logger.Write(typeof(BassSkipSilenceStreamAdvisor), LogLevel.Debug, "Lead in/out meta data does not exist for file \"{0}\".", playlistItem.FileName); + Logger.Write(typeof(BassSkipSilenceStreamAdvisor), LogLevel.Debug, "Lead in/out meta data does not exist for file \"{0}\".", playlistItem.FileName); leadIn = default(TimeSpan); leadOut = default(TimeSpan); @@ -316,7 +316,7 @@ protected virtual bool TryGetMetaData(BassSkipSilenceStreamAdvisorBehaviour beha } else if (!this.TryParseDuration(behaviour, leadInMetaDataItem.Value, out leadIn)) { - //Logger.Write(typeof(BassSkipSilenceStreamAdvisor), LogLevel.Debug, "Lead in meta data value \"{0}\" for file \"{1}\" is not valid.", leadInMetaDataItem.Value, playlistItem.FileName); + Logger.Write(typeof(BassSkipSilenceStreamAdvisor), LogLevel.Debug, "Lead in meta data value \"{0}\" for file \"{1}\" is not valid.", leadInMetaDataItem.Value, playlistItem.FileName); leadIn = default(TimeSpan); leadOut = default(TimeSpan); @@ -329,14 +329,14 @@ protected virtual bool TryGetMetaData(BassSkipSilenceStreamAdvisorBehaviour beha } else if (!this.TryParseDuration(behaviour, leadOutMetaDataItem.Value, out leadOut)) { - //Logger.Write(typeof(BassSkipSilenceStreamAdvisor), LogLevel.Debug, "Lead out meta data value \"{0}\" for file \"{1}\" is not valid.", leadOutMetaDataItem.Value, playlistItem.FileName); + Logger.Write(typeof(BassSkipSilenceStreamAdvisor), LogLevel.Debug, "Lead out meta data value \"{0}\" for file \"{1}\" is not valid.", leadOutMetaDataItem.Value, playlistItem.FileName); leadIn = default(TimeSpan); leadOut = default(TimeSpan); return false; } - //Logger.Write(typeof(BassSkipSilenceStreamAdvisor), LogLevel.Debug, "Successfully fetched lead in/out from meta data for file \"{0}\": {1}/{2}", playlistItem.FileName, leadIn, leadOut); + Logger.Write(typeof(BassSkipSilenceStreamAdvisor), LogLevel.Debug, "Successfully fetched lead in/out from meta data for file \"{0}\": {1}/{2}", playlistItem.FileName, leadIn, leadOut); return true; } @@ -357,14 +357,14 @@ protected virtual bool TryParseDuration(BassSkipSilenceStreamAdvisorBehaviour be var threshold = default(int); if (!int.TryParse(parts[0], out threshold) || behaviour.Threshold != threshold) { - //Logger.Write(typeof(BassSkipSilenceStreamAdvisor), LogLevel.Warn, "Ignoring lead in/out value \"{0}\": Invalid threshold.", parts[0]); + Logger.Write(typeof(BassSkipSilenceStreamAdvisor), LogLevel.Warn, "Ignoring lead in/out value \"{0}\": Invalid threshold.", parts[0]); duration = TimeSpan.Zero; return false; } if (!TimeSpan.TryParse(parts[1], out duration)) { - //Logger.Write(typeof(BassSkipSilenceStreamAdvisor), LogLevel.Warn, "Ignoring lead in/out value \"{0}\": Invalid duration.", parts[1]); + Logger.Write(typeof(BassSkipSilenceStreamAdvisor), LogLevel.Warn, "Ignoring lead in/out value \"{0}\": Invalid duration.", parts[1]); duration = TimeSpan.Zero; return false; diff --git a/FoxTunes.Output.Bass.Cue/BassSkipSilenceStreamAdvisorBehaviour.cs b/FoxTunes.Output.Bass.Cue/BassSkipSilenceStreamAdvisorBehaviour.cs index debbdec5a..be2863cd7 100644 --- a/FoxTunes.Output.Bass.Cue/BassSkipSilenceStreamAdvisorBehaviour.cs +++ b/FoxTunes.Output.Bass.Cue/BassSkipSilenceStreamAdvisorBehaviour.cs @@ -27,7 +27,7 @@ public bool Enabled set { this._Enabled = value; - //Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); + Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); } } @@ -42,7 +42,7 @@ public int Threshold set { this._Threshold = value; - //Logger.Write(this, LogLevel.Debug, "Threshold = {0}", this.Threshold); + Logger.Write(this, LogLevel.Debug, "Threshold = {0}", this.Threshold); } } @@ -104,7 +104,7 @@ protected virtual void OnDisposing() ~BassSkipSilenceStreamAdvisorBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.Cue/Utility/CueSheetFileAbstraction.cs b/FoxTunes.Output.Bass.Cue/Utility/CueSheetFileAbstraction.cs index d1f5a0910..be6a9f471 100644 --- a/FoxTunes.Output.Bass.Cue/Utility/CueSheetFileAbstraction.cs +++ b/FoxTunes.Output.Bass.Cue/Utility/CueSheetFileAbstraction.cs @@ -120,7 +120,7 @@ protected virtual void OnDisposing() ~CueSheetFileAbstraction() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.Cue/Utility/CueSheetItemFactory.cs b/FoxTunes.Output.Bass.Cue/Utility/CueSheetItemFactory.cs index 5472a1bf4..fd1f75cb8 100644 --- a/FoxTunes.Output.Bass.Cue/Utility/CueSheetItemFactory.cs +++ b/FoxTunes.Output.Bass.Cue/Utility/CueSheetItemFactory.cs @@ -70,15 +70,15 @@ await metaDataSource.GetMetaData(fileAbstraction).ConfigureAwait(false) file.Duration = TimeSpan.FromMilliseconds(this.GetDuration(metaData)); if (TimeSpan.Zero.Equals(file.Duration)) { - //Logger.Write(this, LogLevel.Debug, "Failed to get duration for file \"{0}\".", target); + Logger.Write(this, LogLevel.Debug, "Failed to get duration for file \"{0}\".", target); } } } } - catch + catch (Exception e) { metaData = Enumerable.Empty(); - //Logger.Write(this, LogLevel.Warn, "Failed to read meta data from file \"{0}\": {1}", target, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to read meta data from file \"{0}\": {1}", target, e.Message); } for (var b = 0; b < file.Tracks.Length; b++) { @@ -184,7 +184,7 @@ protected virtual string Resolve(string directoryName, string name) { return fileName; } - //Logger.Write(this, LogLevel.Warn, "Cue sheet references non existant file \"{0}\", attempting to resolve it...", fileName); + Logger.Write(this, LogLevel.Warn, "Cue sheet references non existant file \"{0}\", attempting to resolve it...", fileName); return this.Resolve(directoryName, Directory.GetFiles(directoryName), Path.GetFileNameWithoutExtension(name)); } ); @@ -202,14 +202,14 @@ protected virtual string Resolve(string directoryName, string[] fileNames, strin { continue; } - //Logger.Write(this, LogLevel.Warn, "Located a suitable file \"{0}\".", fileName); + Logger.Write(this, LogLevel.Warn, "Located a suitable file \"{0}\".", fileName); return fileName; } fileNames = fileNames.Where(fileName => this.Output.IsSupported(fileName)).ToArray(); if (fileNames.Length == 1) { var fileName = fileNames[0]; - //Logger.Write(this, LogLevel.Warn, "Only \"{0}\" is supported for playback.", fileName); + Logger.Write(this, LogLevel.Warn, "Only \"{0}\" is supported for playback.", fileName); return fileName; } if (this.FileSystemBrowser != null) diff --git a/FoxTunes.Output.Bass.DirectSound/BassDirectSoundDevice.cs b/FoxTunes.Output.Bass.DirectSound/BassDirectSoundDevice.cs index 47a0206b1..d56beb2ae 100644 --- a/FoxTunes.Output.Bass.DirectSound/BassDirectSoundDevice.cs +++ b/FoxTunes.Output.Bass.DirectSound/BassDirectSoundDevice.cs @@ -27,8 +27,8 @@ public static void Init(int device) OutputRate.GetRates(Bass.Info.SampleRate, Bass.Info.MinSampleRate, Bass.Info.MaxSampleRate), device == Bass.DefaultDevice ); - //Logger.Write(typeof(BassDirectSoundDevice), LogLevel.Debug, "Detected DS device: {0} => Inputs => {1}, Outputs = {2}, Rate = {3}", Bass.CurrentDevice, Info.Inputs, Info.Outputs, Info.Rate); - //Logger.Write(typeof(BassDirectSoundDevice), LogLevel.Debug, "Detected DS device: {0} => Rates => {1}", Bass.CurrentDevice, string.Join(", ", Info.SupportedRates)); + LogManager.Logger.Write(typeof(BassDirectSoundDevice), LogLevel.Debug, "Detected DS device: {0} => Inputs => {1}, Outputs = {2}, Rate = {3}", Bass.CurrentDevice, Info.Inputs, Info.Outputs, Info.Rate); + LogManager.Logger.Write(typeof(BassDirectSoundDevice), LogLevel.Debug, "Detected DS device: {0} => Rates => {1}", Bass.CurrentDevice, string.Join(", ", Info.SupportedRates)); } public static void Free() diff --git a/FoxTunes.Output.Bass.DirectSound/BassDirectSoundStreamOutput.cs b/FoxTunes.Output.Bass.DirectSound/BassDirectSoundStreamOutput.cs index 7c480b5a7..1ea644298 100644 --- a/FoxTunes.Output.Bass.DirectSound/BassDirectSoundStreamOutput.cs +++ b/FoxTunes.Output.Bass.DirectSound/BassDirectSoundStreamOutput.cs @@ -80,13 +80,13 @@ public override void Connect(IBassStreamComponent previous) var channels = default(int); var flags = default(BassFlags); this.ConfigureDirectSound(previous, out rate, out channels, out flags); - //Logger.Write(this, LogLevel.Debug, "Creating BASS MIX stream with rate {0} and {1} channels.", rate, channels); + Logger.Write(this, LogLevel.Debug, "Creating BASS MIX stream with rate {0} and {1} channels.", rate, channels); this.ChannelHandle = BassMix.CreateMixerStream(rate, channels, flags); if (this.ChannelHandle == 0) { BassUtils.Throw(); } - //Logger.Write(this, LogLevel.Debug, "Adding stream to the mixer: {0}", previous.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Adding stream to the mixer: {0}", previous.ChannelHandle); BassUtils.OK(BassMix.MixerAddChannel(this.ChannelHandle, previous.ChannelHandle, BassFlags.Default | BassFlags.MixerBuffer | BassFlags.MixerDownMix)); this.MixerChannelHandles.Add(previous.ChannelHandle); this.UpdateVolume(); @@ -107,7 +107,7 @@ protected virtual void ConfigureDirectSound(IBassStreamComponent previous, out i if (!BassDirectSoundDevice.Info.SupportedRates.Contains(targetRate)) { var nearestRate = BassDirectSoundDevice.Info.GetNearestRate(targetRate); - //Logger.Write(this, LogLevel.Warn, "Enforced rate {0} isn't supposed by the device, falling back to {1}.", targetRate, nearestRate); + Logger.Write(this, LogLevel.Warn, "Enforced rate {0} isn't supposed by the device, falling back to {1}.", targetRate, nearestRate); rate = nearestRate; } else @@ -120,13 +120,13 @@ protected virtual void ConfigureDirectSound(IBassStreamComponent previous, out i if (!BassDirectSoundDevice.Info.SupportedRates.Contains(rate)) { var nearestRate = BassDirectSoundDevice.Info.GetNearestRate(rate); - //Logger.Write(this, LogLevel.Debug, "Stream rate {0} isn't supposed by the device, falling back to {1}.", rate, nearestRate); + Logger.Write(this, LogLevel.Debug, "Stream rate {0} isn't supposed by the device, falling back to {1}.", rate, nearestRate); rate = nearestRate; } } if (BassDirectSoundDevice.Info.Outputs < channels) { - //Logger.Write(this, LogLevel.Debug, "Stream channel count {0} isn't supported by the device, falling back to {1} channels.", channels, BassDirectSoundDevice.Info.Outputs); + Logger.Write(this, LogLevel.Debug, "Stream channel count {0} isn't supported by the device, falling back to {1} channels.", channels, BassDirectSoundDevice.Info.Outputs); channels = BassDirectSoundDevice.Info.Outputs; } } @@ -135,7 +135,7 @@ protected virtual void ConfigureDirectSound(IBassStreamComponent previous, out i public override void ClearBuffer() { - //Logger.Write(this, LogLevel.Debug, "Clearing mixer buffer."); + Logger.Write(this, LogLevel.Debug, "Clearing mixer buffer."); Bass.ChannelSetPosition(this.ChannelHandle, 0); base.ClearBuffer(); } @@ -171,7 +171,7 @@ public override void Play() { return; } - //Logger.Write(this, LogLevel.Debug, "Playing channel: {0}", this.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Playing channel: {0}", this.ChannelHandle); try { BassUtils.OK(Bass.ChannelPlay(this.ChannelHandle, true)); @@ -189,7 +189,7 @@ public override void Pause() { return; } - //Logger.Write(this, LogLevel.Debug, "Pausing channel: {0}", this.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Pausing channel: {0}", this.ChannelHandle); try { BassUtils.OK(Bass.ChannelPause(this.ChannelHandle)); @@ -207,7 +207,7 @@ public override void Resume() { return; } - //Logger.Write(this, LogLevel.Debug, "Resuming channel: {0}", this.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Resuming channel: {0}", this.ChannelHandle); try { BassUtils.OK(Bass.ChannelPlay(this.ChannelHandle, false)); @@ -225,7 +225,7 @@ public override void Stop() { return; } - //Logger.Write(this, LogLevel.Debug, "Stopping channel: {0}", this.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Stopping channel: {0}", this.ChannelHandle); try { BassUtils.OK(Bass.ChannelStop(this.ChannelHandle)); @@ -268,7 +268,7 @@ protected override void OnDisposing() { if (this.ChannelHandle != 0) { - //Logger.Write(this, LogLevel.Debug, "Freeing BASS stream: {0}", this.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Freeing BASS stream: {0}", this.ChannelHandle); Bass.StreamFree(this.ChannelHandle); //Not checking result code as it contains an error if the application is shutting down. } base.OnDisposing(); diff --git a/FoxTunes.Output.Bass.DirectSound/BassDirectSoundStreamOutputBehaviour.cs b/FoxTunes.Output.Bass.DirectSound/BassDirectSoundStreamOutputBehaviour.cs index 230fef93a..31a18b99e 100644 --- a/FoxTunes.Output.Bass.DirectSound/BassDirectSoundStreamOutputBehaviour.cs +++ b/FoxTunes.Output.Bass.DirectSound/BassDirectSoundStreamOutputBehaviour.cs @@ -32,7 +32,7 @@ public bool Enabled set { this._Enabled = value; - //Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); + Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); this.OutputDeviceManager.Restart(); } } @@ -48,7 +48,7 @@ public int DirectSoundDevice set { this._DirectSoundDevice = value; - //Logger.Write(this, LogLevel.Debug, "Direct Sound Device = {0}", this.DirectSoundDevice); + Logger.Write(this, LogLevel.Debug, "Direct Sound Device = {0}", this.DirectSoundDevice); this.OutputDeviceManager.Restart(); } } @@ -88,7 +88,7 @@ protected virtual void OnInit(object sender, EventArgs e) BassUtils.OK(Bass.Configure(global::ManagedBass.Configuration.MixerBufferLength, this.Output.MixerBufferLength)); BassUtils.OK(Bass.Configure(global::ManagedBass.Configuration.SRCQuality, this.Output.ResamplingQuality)); BassUtils.OK(Bass.Init(this.DirectSoundDevice, this.Output.Rate)); - //Logger.Write(this, LogLevel.Debug, "BASS Initialized."); + Logger.Write(this, LogLevel.Debug, "BASS Initialized."); } protected virtual void OnInitDevice() @@ -107,7 +107,7 @@ protected virtual void OnFree(object sender, EventArgs e) return; } this.OnFreeDevice(); - //Logger.Write(this, LogLevel.Debug, "Releasing BASS."); + LogManager.Logger.Write(this, LogLevel.Debug, "Releasing BASS."); Bass.Free(); this.IsInitialized = false; } @@ -182,7 +182,7 @@ protected virtual void OnDisposing() ~BassDirectSoundStreamOutputBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.DirectSound/BassDirectSoundStreamOutputConfiguration.cs b/FoxTunes.Output.Bass.DirectSound/BassDirectSoundStreamOutputConfiguration.cs index bafbace66..7a1d613f4 100644 --- a/FoxTunes.Output.Bass.DirectSound/BassDirectSoundStreamOutputConfiguration.cs +++ b/FoxTunes.Output.Bass.DirectSound/BassDirectSoundStreamOutputConfiguration.cs @@ -64,7 +64,7 @@ public static IEnumerable GetDSDevices() { var deviceInfo = default(DeviceInfo); BassUtils.OK(Bass.GetDeviceInfo(a, out deviceInfo)); - //Logger.Write(typeof(BassDirectSoundStreamOutputConfiguration), LogLevel.Debug, "DS Device: {0} => {1} => {2}", a, deviceInfo.Name, deviceInfo.Driver); + LogManager.Logger.Write(typeof(BassDirectSoundStreamOutputConfiguration), LogLevel.Debug, "DS Device: {0} => {1} => {2}", a, deviceInfo.Name, deviceInfo.Driver); if (!deviceInfo.IsEnabled) { continue; diff --git a/FoxTunes.Output.Bass.Dsd/BassDsdBehaviour.cs b/FoxTunes.Output.Bass.Dsd/BassDsdBehaviour.cs index 1b82c4cad..cbec1dc4d 100644 --- a/FoxTunes.Output.Bass.Dsd/BassDsdBehaviour.cs +++ b/FoxTunes.Output.Bass.Dsd/BassDsdBehaviour.cs @@ -47,7 +47,7 @@ public int Rate set { BassDsd.DefaultFrequency = value; - //Logger.Write(this, LogLevel.Debug, "DSD to PCM sample rate: {0}", MetaDataInfo.SampleRateDescription(BassDsd.DefaultFrequency)); + Logger.Write(this, LogLevel.Debug, "DSD to PCM sample rate: {0}", MetaDataInfo.SampleRateDescription(BassDsd.DefaultFrequency)); } } @@ -60,7 +60,7 @@ public int Gain set { BassDsd.DefaultGain = value; - //Logger.Write(this, LogLevel.Debug, "DSD to PCM gain: {0}{1}dB", BassDsd.DefaultGain > 0 ? "+" : string.Empty, BassDsd.DefaultGain); + Logger.Write(this, LogLevel.Debug, "DSD to PCM gain: {0}{1}dB", BassDsd.DefaultGain > 0 ? "+" : string.Empty, BassDsd.DefaultGain); } } @@ -75,7 +75,7 @@ public bool Memory set { this._Memory = value; - //Logger.Write(this, LogLevel.Debug, "Play DSD from memory: {0}", value ? bool.TrueString : bool.FalseString); + Logger.Write(this, LogLevel.Debug, "Play DSD from memory: {0}", value ? bool.TrueString : bool.FalseString); } } diff --git a/FoxTunes.Output.Bass.Dsd/BassDsdMemoryLoadingBehaviour.cs b/FoxTunes.Output.Bass.Dsd/BassDsdMemoryLoadingBehaviour.cs index cfa4c4811..bc454771b 100644 --- a/FoxTunes.Output.Bass.Dsd/BassDsdMemoryLoadingBehaviour.cs +++ b/FoxTunes.Output.Bass.Dsd/BassDsdMemoryLoadingBehaviour.cs @@ -49,11 +49,11 @@ protected virtual void OnIsLoadedChanged(object sender, EventArgs e) try { BassMemory.Dsd.Progress(this.Handler); - //Logger.Write(this, LogLevel.Debug, "Registered progress handler."); + Logger.Write(this, LogLevel.Debug, "Registered progress handler."); } - catch + catch (Exception ex) { - //Logger.Write(this, LogLevel.Warn, "Failed to register progress handler: {0}", ex.Message); + Logger.Write(this, LogLevel.Warn, "Failed to register progress handler: {0}", ex.Message); } } } @@ -147,7 +147,7 @@ protected virtual void OnDisposing() ~BassDsdMemoryLoadingBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.Dsd/BassDsdStreamProvider.cs b/FoxTunes.Output.Bass.Dsd/BassDsdStreamProvider.cs index 72e5228c0..b535f8552 100644 --- a/FoxTunes.Output.Bass.Dsd/BassDsdStreamProvider.cs +++ b/FoxTunes.Output.Bass.Dsd/BassDsdStreamProvider.cs @@ -40,7 +40,7 @@ public override IBassStream CreateInteractiveStream(PlaylistItem playlistItem, I channelHandle = this.CreateDsdRawStream(playlistItem, advice, flags); if (channelHandle == 0) { - //Logger.Write(this, LogLevel.Warn, "Failed to create DSD RAW stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); + Logger.Write(this, LogLevel.Warn, "Failed to create DSD RAW stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); } return this.CreateInteractiveStream(channelHandle, advice, flags | BassFlags.DSDRaw); } @@ -49,7 +49,7 @@ public override IBassStream CreateInteractiveStream(PlaylistItem playlistItem, I channelHandle = this.CreateDsdStream(playlistItem, advice, flags); if (channelHandle == 0) { - //Logger.Write(this, LogLevel.Warn, "Failed to create DSD stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); + Logger.Write(this, LogLevel.Warn, "Failed to create DSD stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); } return this.CreateInteractiveStream(channelHandle, advice, flags); } @@ -61,15 +61,15 @@ protected virtual int CreateDsdStream(PlaylistItem playlistItem, IEnumerable paths, Cancel var set = this.Database.Set(transaction); foreach (var playlistItem in playlistItems) { - //Logger.Write(this, LogLevel.Debug, "Adding file to playlist: {0}", playlistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Adding file to playlist: {0}", playlistItem.FileName); playlistItem.Playlist_Id = this.Playlist.Id; playlistItem.Sequence = this.Sequence; playlistItem.Status = PlaylistItemStatus.Import; diff --git a/FoxTunes.Output.Bass.Dts/BassDtsStreamProvider.cs b/FoxTunes.Output.Bass.Dts/BassDtsStreamProvider.cs index 9ceaf34bb..ba06c8e2c 100644 --- a/FoxTunes.Output.Bass.Dts/BassDtsStreamProvider.cs +++ b/FoxTunes.Output.Bass.Dts/BassDtsStreamProvider.cs @@ -54,18 +54,18 @@ public override bool CanCreateStream(PlaylistItem playlistItem) { if (this.ProbeWavFiles.Value) { - //Logger.Write(this, LogLevel.Debug, "Probing file \"{0}\" for DTS stream..", playlistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Probing file \"{0}\" for DTS stream..", playlistItem.FileName); var channelHandle = BassDts.CreateStream(playlistItem.FileName); if (channelHandle != 0) { - //Logger.Write(this, LogLevel.Debug, "Found DTS stream in file \"{0}\".", playlistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Found DTS stream in file \"{0}\".", playlistItem.FileName); Bass.StreamFree(channelHandle); return true; } } else { - //Logger.Write(this, LogLevel.Debug, "Probing for DTS streams is disabled."); + Logger.Write(this, LogLevel.Debug, "Probing for DTS streams is disabled."); } } return false; @@ -77,7 +77,7 @@ public override IBassStream CreateBasicStream(PlaylistItem playlistItem, IEnumer var channelHandle = BassDts.CreateStream(fileName, 0, 0, flags); if (channelHandle == 0) { - //Logger.Write(this, LogLevel.Warn, "Failed to create DTS stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); + Logger.Write(this, LogLevel.Warn, "Failed to create DTS stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); } return this.CreateBasicStream(channelHandle, advice, flags); } @@ -88,7 +88,7 @@ public override IBassStream CreateInteractiveStream(PlaylistItem playlistItem, I var channelHandle = BassDts.CreateStream(fileName, 0, 0, flags); if (channelHandle == 0) { - //Logger.Write(this, LogLevel.Warn, "Failed to create DTS stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); + Logger.Write(this, LogLevel.Warn, "Failed to create DTS stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); } return this.CreateInteractiveStream(channelHandle, advice, flags); } diff --git a/FoxTunes.Output.Bass.Gapless/BassGaplessStreamInput.cs b/FoxTunes.Output.Bass.Gapless/BassGaplessStreamInput.cs index 076ebd2e5..5b2b34aca 100644 --- a/FoxTunes.Output.Bass.Gapless/BassGaplessStreamInput.cs +++ b/FoxTunes.Output.Bass.Gapless/BassGaplessStreamInput.cs @@ -62,7 +62,7 @@ public override void Connect(BassOutputStream stream) { BassUtils.OK(BassGapless.SetConfig(BassGaplessAttriubute.KeepAlive, true)); BassUtils.OK(BassGapless.SetConfig(BassGaplessAttriubute.RecycleStream, true)); - //Logger.Write(this, LogLevel.Debug, "Creating BASS GAPLESS stream with rate {0} and {1} channels.", stream.Rate, stream.Channels); + Logger.Write(this, LogLevel.Debug, "Creating BASS GAPLESS stream with rate {0} and {1} channels.", stream.Rate, stream.Channels); this.ChannelHandle = BassGapless.StreamCreate(stream.Rate, stream.Channels, stream.Flags | BassFlags.MixerNonStop); if (this.ChannelHandle == 0) { @@ -86,10 +86,10 @@ public override bool Add(BassOutputStream stream, Action callB { if (this.Queue.Contains(stream.ChannelHandle)) { - //Logger.Write(this, LogLevel.Debug, "Stream is already enqueued: {0}", stream.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Stream is already enqueued: {0}", stream.ChannelHandle); return false; } - //Logger.Write(this, LogLevel.Debug, "Adding stream to the queue: {0}", stream.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Adding stream to the queue: {0}", stream.ChannelHandle); BassUtils.OK(BassGapless.ChannelEnqueue(stream.ChannelHandle)); if (callBack != null) { @@ -102,10 +102,10 @@ public override bool Remove(BassOutputStream stream, Action ca { if (!this.Queue.Contains(stream.ChannelHandle)) { - //Logger.Write(this, LogLevel.Debug, "Stream is not enqueued: {0}", stream.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Stream is not enqueued: {0}", stream.ChannelHandle); return false; } - //Logger.Write(this, LogLevel.Debug, "Removing stream from the queue: {0}", stream.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Removing stream from the queue: {0}", stream.ChannelHandle); BassUtils.OK(BassGapless.ChannelRemove(stream.ChannelHandle)); if (callBack != null) { @@ -116,10 +116,10 @@ public override bool Remove(BassOutputStream stream, Action ca public override void Reset() { - //Logger.Write(this, LogLevel.Debug, "Resetting the queue."); + Logger.Write(this, LogLevel.Debug, "Resetting the queue."); foreach (var channelHandle in this.Queue) { - //Logger.Write(this, LogLevel.Debug, "Removing stream from the queue: {0}", channelHandle); + Logger.Write(this, LogLevel.Debug, "Removing stream from the queue: {0}", channelHandle); BassGapless.ChannelRemove(channelHandle); } } @@ -129,7 +129,7 @@ protected override void OnDisposing() if (this.ChannelHandle != 0) { this.Reset(); - //Logger.Write(this, LogLevel.Debug, "Freeing BASS GAPLESS stream: {0}", this.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Freeing BASS GAPLESS stream: {0}", this.ChannelHandle); Bass.StreamFree(this.ChannelHandle); //Not checking result code as it contains an error if the application is shutting down. } } diff --git a/FoxTunes.Output.Bass.Gapless/BassGaplessStreamInputBehaviour.cs b/FoxTunes.Output.Bass.Gapless/BassGaplessStreamInputBehaviour.cs index 0e64432b3..0a9cb2132 100644 --- a/FoxTunes.Output.Bass.Gapless/BassGaplessStreamInputBehaviour.cs +++ b/FoxTunes.Output.Bass.Gapless/BassGaplessStreamInputBehaviour.cs @@ -45,7 +45,7 @@ public bool Enabled set { this._Enabled = value; - //Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); + Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); var task = this.Output.Shutdown(); } } @@ -107,7 +107,7 @@ protected virtual void OnDisposing() ~BassGaplessStreamInputBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.Memory/BassMemoryBehaviour.cs b/FoxTunes.Output.Bass.Memory/BassMemoryBehaviour.cs index 16bd58930..0fcd577a9 100644 --- a/FoxTunes.Output.Bass.Memory/BassMemoryBehaviour.cs +++ b/FoxTunes.Output.Bass.Memory/BassMemoryBehaviour.cs @@ -44,7 +44,7 @@ public bool Enabled set { this._Enabled = value; - //Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); + Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); var task = this.Output.Shutdown(); } } @@ -111,7 +111,7 @@ protected virtual void OnDisposing() ~BassMemoryBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.Memory/BassMemoryLoadingBehaviour.cs b/FoxTunes.Output.Bass.Memory/BassMemoryLoadingBehaviour.cs index bdf732e7f..b1cde65fe 100644 --- a/FoxTunes.Output.Bass.Memory/BassMemoryLoadingBehaviour.cs +++ b/FoxTunes.Output.Bass.Memory/BassMemoryLoadingBehaviour.cs @@ -49,11 +49,11 @@ protected virtual void OnIsLoadedChanged(object sender, EventArgs e) try { BassMemory.Progress(this.Handler); - //Logger.Write(this, LogLevel.Debug, "Registered progress handler."); + Logger.Write(this, LogLevel.Debug, "Registered progress handler."); } - catch + catch (Exception ex) { - //Logger.Write(this, LogLevel.Warn, "Failed to register progress handler: {0}", ex.Message); + Logger.Write(this, LogLevel.Warn, "Failed to register progress handler: {0}", ex.Message); } } } @@ -147,7 +147,7 @@ protected virtual void OnDisposing() ~BassMemoryLoadingBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.Memory/BassMemoryStreamAdvise.cs b/FoxTunes.Output.Bass.Memory/BassMemoryStreamAdvise.cs index 6cdb80572..3e0913438 100644 --- a/FoxTunes.Output.Bass.Memory/BassMemoryStreamAdvise.cs +++ b/FoxTunes.Output.Bass.Memory/BassMemoryStreamAdvise.cs @@ -21,15 +21,15 @@ public override bool Wrap(IBassStreamProvider provider, int channelHandle, IEnum stream = null; return false; } - //Logger.Write(this, LogLevel.Debug, "Creating memory stream for channel: {0}", channelHandle); + Logger.Write(this, LogLevel.Debug, "Creating memory stream for channel: {0}", channelHandle); var memoryChannelHandle = BassMemory.CreateStream(channelHandle, 0, 0, flags); if (memoryChannelHandle == 0) { - //Logger.Write(this, LogLevel.Warn, "Failed to create memory stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); + Logger.Write(this, LogLevel.Warn, "Failed to create memory stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); stream = null; return false; } - //Logger.Write(this, LogLevel.Debug, "Created memory stream: {0}", channelHandle); + Logger.Write(this, LogLevel.Debug, "Created memory stream: {0}", channelHandle); stream = new BassStream( provider, memoryChannelHandle, diff --git a/FoxTunes.Output.Bass.Memory/BassMemoryStreamProvider.cs b/FoxTunes.Output.Bass.Memory/BassMemoryStreamProvider.cs index b03245754..8a24c5e60 100644 --- a/FoxTunes.Output.Bass.Memory/BassMemoryStreamProvider.cs +++ b/FoxTunes.Output.Bass.Memory/BassMemoryStreamProvider.cs @@ -29,15 +29,15 @@ public override bool CanCreateStream(PlaylistItem playlistItem) public override IBassStream CreateInteractiveStream(PlaylistItem playlistItem, IEnumerable advice, bool immidiate, BassFlags flags) { var fileName = this.GetFileName(playlistItem, advice); - //Logger.Write(this, LogLevel.Debug, "Creating memory stream for file: {0}", fileName); + Logger.Write(this, LogLevel.Debug, "Creating memory stream for file: {0}", fileName); var channelHandle = BassMemory.CreateStream(fileName, 0, 0, flags); if (channelHandle != 0) { - //Logger.Write(this, LogLevel.Debug, "Created memory stream: {0}", channelHandle); + Logger.Write(this, LogLevel.Debug, "Created memory stream: {0}", channelHandle); } else { - //Logger.Write(this, LogLevel.Warn, "Failed to create memory stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); + Logger.Write(this, LogLevel.Warn, "Failed to create memory stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); } return this.CreateInteractiveStream(channelHandle, advice, flags); } diff --git a/FoxTunes.Output.Bass.Mod/BassModStreamProvider.cs b/FoxTunes.Output.Bass.Mod/BassModStreamProvider.cs index 7e1cce677..68c920e90 100644 --- a/FoxTunes.Output.Bass.Mod/BassModStreamProvider.cs +++ b/FoxTunes.Output.Bass.Mod/BassModStreamProvider.cs @@ -131,7 +131,7 @@ public override IBassStream CreateBasicStream(PlaylistItem playlistItem, IEnumer var channelHandle = Bass.MusicLoad(fileName, 0, 0, flags | BassFlags.Prescan); if (channelHandle == 0) { - //Logger.Write(this, LogLevel.Warn, "Failed to create MOD stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); + Logger.Write(this, LogLevel.Warn, "Failed to create MOD stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); } return this.CreateBasicStream(channelHandle, advice, flags); } @@ -142,14 +142,14 @@ public override IBassStream CreateInteractiveStream(PlaylistItem playlistItem, I var channelHandle = Bass.MusicLoad(fileName, 0, 0, flags | BassFlags.Prescan); if (channelHandle == 0) { - //Logger.Write(this, LogLevel.Warn, "Failed to create MOD stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); + Logger.Write(this, LogLevel.Warn, "Failed to create MOD stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError)); } return this.CreateInteractiveStream(channelHandle, advice, flags); } public override void FreeStream(int channelHandle) { - //Logger.Write(this, LogLevel.Debug, "Freeing stream: {0}", channelHandle); + Logger.Write(this, LogLevel.Debug, "Freeing stream: {0}", channelHandle); Bass.MusicFree(channelHandle); //Not checking result code as it contains an error if the application is shutting down. } } diff --git a/FoxTunes.Output.Bass.ParametricEqualizer/BassOutputEqualizer.cs b/FoxTunes.Output.Bass.ParametricEqualizer/BassOutputEqualizer.cs index e5d3ce746..4a6de17cd 100644 --- a/FoxTunes.Output.Bass.ParametricEqualizer/BassOutputEqualizer.cs +++ b/FoxTunes.Output.Bass.ParametricEqualizer/BassOutputEqualizer.cs @@ -227,7 +227,7 @@ protected virtual void OnDisposing() ~BassOutputEqualizer() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.ParametricEqualizer/BassOutputEqualizerBand.cs b/FoxTunes.Output.Bass.ParametricEqualizer/BassOutputEqualizerBand.cs index 7802df953..4e22b2464 100644 --- a/FoxTunes.Output.Bass.ParametricEqualizer/BassOutputEqualizerBand.cs +++ b/FoxTunes.Output.Bass.ParametricEqualizer/BassOutputEqualizerBand.cs @@ -200,7 +200,7 @@ protected virtual void OnDisposing() ~BassOutputEqualizerBand() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.ParametricEqualizer/BassParametricEqualizerPreset.cs b/FoxTunes.Output.Bass.ParametricEqualizer/BassParametricEqualizerPreset.cs index cecf8a471..30693e564 100644 --- a/FoxTunes.Output.Bass.ParametricEqualizer/BassParametricEqualizerPreset.cs +++ b/FoxTunes.Output.Bass.ParametricEqualizer/BassParametricEqualizerPreset.cs @@ -20,6 +20,14 @@ public static class BassParametricEqualizerPreset const string BAND_8000 = "BAND_8000"; const string BAND_16000 = "BAND_16000"; + public static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + public static string Location { get @@ -78,14 +86,14 @@ private static IDictionary> LoadPresets() }; if (Directory.Exists(SystemPresetsFolder)) { - //Logger.Write(typeof(BassParametricEqualizerPreset), LogLevel.Debug, "Loading system presets.."); + Logger.Write(typeof(BassParametricEqualizerPreset), LogLevel.Debug, "Loading system presets.."); LoadPresets(presets, SystemPresetsFolder); } if (!string.Equals(SystemPresetsFolder, UserPresetsFolder, StringComparison.OrdinalIgnoreCase)) { if (Directory.Exists(UserPresetsFolder)) { - //Logger.Write(typeof(BassParametricEqualizerPreset), LogLevel.Debug, "Loading user presets.."); + Logger.Write(typeof(BassParametricEqualizerPreset), LogLevel.Debug, "Loading user presets.."); LoadPresets(presets, UserPresetsFolder); } } @@ -100,9 +108,9 @@ private static void LoadPresets(IDictionary> pr { LoadPreset(presets, fileName); } - catch + catch (Exception e) { - //Logger.Write(typeof(BassParametricEqualizerPreset), LogLevel.Warn, "Failed to load preset from file \"{0}\": {1}", fileName, e.Message); + Logger.Write(typeof(BassParametricEqualizerPreset), LogLevel.Warn, "Failed to load preset from file \"{0}\": {1}", fileName, e.Message); } } } @@ -170,11 +178,11 @@ private static void LoadPreset(IDictionary> pre } else { - //Logger.Write(typeof(BassParametricEqualizerPreset), LogLevel.Warn, "Warning while loading preset from file \"{0}\": Unrecognized expression: {1} = {2}", fileName, key, value); + Logger.Write(typeof(BassParametricEqualizerPreset), LogLevel.Warn, "Warning while loading preset from file \"{0}\": Unrecognized expression: {1} = {2}", fileName, key, value); } } presets[name] = bands; - //Logger.Write(typeof(BassParametricEqualizerPreset), LogLevel.Debug, "Loaded preset from file \"{0}\".", fileName); + Logger.Write(typeof(BassParametricEqualizerPreset), LogLevel.Debug, "Loaded preset from file \"{0}\".", fileName); } public static void SavePreset(string name) @@ -223,9 +231,9 @@ public static void SavePreset(string name) { LoadPreset(PRESETS, fileName); } - catch + catch (Exception e) { - //Logger.Write(typeof(BassParametricEqualizerPreset), LogLevel.Warn, "Failed to load preset from file \"{0}\": {1}", fileName, e.Message); + Logger.Write(typeof(BassParametricEqualizerPreset), LogLevel.Warn, "Failed to load preset from file \"{0}\": {1}", fileName, e.Message); } } diff --git a/FoxTunes.Output.Bass.ParametricEqualizer/BassParametricEqualizerStreamComponentBehaviour.cs b/FoxTunes.Output.Bass.ParametricEqualizer/BassParametricEqualizerStreamComponentBehaviour.cs index e80f757e0..be2d5fe94 100644 --- a/FoxTunes.Output.Bass.ParametricEqualizer/BassParametricEqualizerStreamComponentBehaviour.cs +++ b/FoxTunes.Output.Bass.ParametricEqualizer/BassParametricEqualizerStreamComponentBehaviour.cs @@ -30,7 +30,7 @@ public bool Enabled set { this._Enabled = value; - //Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); + Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); } } @@ -69,7 +69,7 @@ protected virtual void OnCreatingPipeline(object sender, CreatingPipelineEventAr { if (!BassParametricEqualizerStreamComponent.ShouldCreate(this, e.Stream, e.Query)) { - //Logger.Write(this, LogLevel.Debug, "Cannot create component, the stream is not supported."); + Logger.Write(this, LogLevel.Debug, "Cannot create component, the stream is not supported."); return; } var component = new BassParametricEqualizerStreamComponent(this, e.Pipeline, e.Stream.Flags); @@ -115,7 +115,7 @@ protected virtual void OnDisposing() ~BassParametricEqualizerStreamComponentBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.ParametricEqualizer/PeakEQ.cs b/FoxTunes.Output.Bass.ParametricEqualizer/PeakEQ.cs index 11141dccb..ace9e28b0 100644 --- a/FoxTunes.Output.Bass.ParametricEqualizer/PeakEQ.cs +++ b/FoxTunes.Output.Bass.ParametricEqualizer/PeakEQ.cs @@ -58,7 +58,7 @@ protected virtual void OnDisposing() ~PeakEQ() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.ParametricEqualizer/PeakEQEffect.cs b/FoxTunes.Output.Bass.ParametricEqualizer/PeakEQEffect.cs index 92f921f28..620fa5f96 100644 --- a/FoxTunes.Output.Bass.ParametricEqualizer/PeakEQEffect.cs +++ b/FoxTunes.Output.Bass.ParametricEqualizer/PeakEQEffect.cs @@ -156,7 +156,7 @@ protected virtual void OnDisposing() ~PeakEQEffect() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.ReplayGain/BassReplayGainBehaviour.cs b/FoxTunes.Output.Bass.ReplayGain/BassReplayGainBehaviour.cs index 47edc8e4b..59158e4df 100644 --- a/FoxTunes.Output.Bass.ReplayGain/BassReplayGainBehaviour.cs +++ b/FoxTunes.Output.Bass.ReplayGain/BassReplayGainBehaviour.cs @@ -59,7 +59,7 @@ public bool Enabled set { this._Enabled = value; - //Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); + Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); var task = this.Output.Shutdown(); } } @@ -147,7 +147,7 @@ protected virtual void Add(BassOutputStream stream) { if (duplicated == null) { - //Logger.Write(this, LogLevel.Warn, "Failed to duplicate stream for file \"{0}\", cannot calculate.", stream.FileName); + Logger.Write(this, LogLevel.Warn, "Failed to duplicate stream for file \"{0}\", cannot calculate.", stream.FileName); return; } if (!this.TryCalculateReplayGain(duplicated, out gain, out peak, out mode)) @@ -195,7 +195,7 @@ protected virtual bool TryGetReplayGain(BassOutputStream stream, out float repla } if (this.Mode == ReplayGainMode.Album) { - //Logger.Write(this, LogLevel.Debug, "Found preferred replay gain data for album: \"{0}\" => {1}", stream.FileName, albumGain); + Logger.Write(this, LogLevel.Debug, "Found preferred replay gain data for album: \"{0}\" => {1}", stream.FileName, albumGain); mode = ReplayGainMode.Album; replayGain = albumGain; return true; @@ -213,7 +213,7 @@ protected virtual bool TryGetReplayGain(BassOutputStream stream, out float repla } if (this.Mode == ReplayGainMode.Track) { - //Logger.Write(this, LogLevel.Debug, "Found preferred replay gain data for track: \"{0}\" => {1}", stream.FileName, trackGain); + Logger.Write(this, LogLevel.Debug, "Found preferred replay gain data for track: \"{0}\" => {1}", stream.FileName, trackGain); mode = ReplayGainMode.Track; replayGain = trackGain; return true; @@ -224,19 +224,19 @@ protected virtual bool TryGetReplayGain(BassOutputStream stream, out float repla } if (this.IsValidReplayGain(albumGain)) { - //Logger.Write(this, LogLevel.Debug, "Using album replay gain data: \"{0}\" => {1}", stream.FileName, albumGain); + Logger.Write(this, LogLevel.Debug, "Using album replay gain data: \"{0}\" => {1}", stream.FileName, albumGain); mode = ReplayGainMode.Album; replayGain = albumGain; return true; } if (this.IsValidReplayGain(trackGain)) { - //Logger.Write(this, LogLevel.Debug, "Using track replay gain data: \"{0}\" => {1}", stream.FileName, trackGain); + Logger.Write(this, LogLevel.Debug, "Using track replay gain data: \"{0}\" => {1}", stream.FileName, trackGain); mode = ReplayGainMode.Track; replayGain = trackGain; return true; } - //Logger.Write(this, LogLevel.Debug, "No replay gain data: \"{0}\".", stream.FileName); + Logger.Write(this, LogLevel.Debug, "No replay gain data: \"{0}\".", stream.FileName); mode = ReplayGainMode.None; replayGain = 0; return false; @@ -250,13 +250,13 @@ protected virtual bool IsValidReplayGain(float replayGain) protected virtual bool TryCalculateReplayGain(BassOutputStream stream, out float gain, out float peak, out ReplayGainMode mode) { - //Logger.Write(this, LogLevel.Debug, "Attempting to calculate track replay gain for file \"{0}\".", stream.FileName); + Logger.Write(this, LogLevel.Debug, "Attempting to calculate track replay gain for file \"{0}\".", stream.FileName); try { var info = default(ReplayGainInfo); if (BassReplayGain.Process(stream.ChannelHandle, out info)) { - //Logger.Write(this, LogLevel.Debug, "Calculated track replay gain for file \"{0}\": {1}dB", stream.FileName, ReplayGainEffect.GetVolume(info.gain)); + Logger.Write(this, LogLevel.Debug, "Calculated track replay gain for file \"{0}\": {1}dB", stream.FileName, ReplayGainEffect.GetVolume(info.gain)); gain = info.gain; peak = info.peak; mode = ReplayGainMode.Track; @@ -264,12 +264,12 @@ protected virtual bool TryCalculateReplayGain(BassOutputStream stream, out float } else { - //Logger.Write(this, LogLevel.Warn, "Failed to calculate track replay gain for file \"{0}\".", stream.FileName); + Logger.Write(this, LogLevel.Warn, "Failed to calculate track replay gain for file \"{0}\".", stream.FileName); } } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to calculate track replay gain for file \"{0}\": {1}", stream.FileName, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to calculate track replay gain for file \"{0}\": {1}", stream.FileName, e.Message); } gain = 0; peak = 0; @@ -379,7 +379,7 @@ protected virtual void OnDisposing() ~BassReplayGainBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScanner.cs b/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScanner.cs index 1eedc4b9a..e2ad11f44 100644 --- a/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScanner.cs +++ b/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScanner.cs @@ -32,18 +32,18 @@ public void Scan() { if (this.Threads > 1) { - //Logger.Write(this, LogLevel.Debug, "Beginning parallel scanning with {0} threads.", this.Threads); + Logger.Write(this, LogLevel.Debug, "Beginning parallel scanning with {0} threads.", this.Threads); } else { - //Logger.Write(this, LogLevel.Debug, "Beginning single threaded scanning."); + Logger.Write(this, LogLevel.Debug, "Beginning single threaded scanning."); } var scannerItems = default(IEnumerable); var scannerGroups = default(IEnumerable>); this.GetGroups(out scannerItems, out scannerGroups); this.ScanTracks(scannerItems); this.ScanGroups(scannerGroups); - //Logger.Write(this, LogLevel.Debug, "Scanning completed successfully."); + Logger.Write(this, LogLevel.Debug, "Scanning completed successfully."); } protected virtual void ScanTracks(IEnumerable scannerItems) @@ -58,39 +58,39 @@ protected virtual void ScanTracks(IEnumerable scannerItems) { if (this.CancellationToken.IsCancellationRequested) { - //Logger.Write(this, LogLevel.Warn, "Skipping file \"{0}\" due to cancellation.", scannerItem.FileName); + Logger.Write(this, LogLevel.Warn, "Skipping file \"{0}\" due to cancellation.", scannerItem.FileName); scannerItem.Status = ScannerItemStatus.Cancelled; return; } if (!this.CheckInput(scannerItem.FileName)) { - //Logger.Write(this, LogLevel.Warn, "Skipping file \"{0}\" due to file \"{1}\" does not exist.", scannerItem.FileName); + Logger.Write(this, LogLevel.Warn, "Skipping file \"{0}\" due to file \"{1}\" does not exist.", scannerItem.FileName); scannerItem.Status = ScannerItemStatus.Failed; scannerItem.AddError(string.Format("File \"{0}\" does not exist.", scannerItem.FileName)); return; } - //Logger.Write(this, LogLevel.Debug, "Beginning scanning file \"{0}\".", scannerItem.FileName); + Logger.Write(this, LogLevel.Debug, "Beginning scanning file \"{0}\".", scannerItem.FileName); scannerItem.Progress = ScannerItem.PROGRESS_NONE; scannerItem.Status = ScannerItemStatus.Processing; this.ScanTrack(scannerItem); if (scannerItem.Status == ScannerItemStatus.Complete) { - //Logger.Write(this, LogLevel.Debug, "Scanning file \"{0}\" completed successfully.", scannerItem.FileName); + Logger.Write(this, LogLevel.Debug, "Scanning file \"{0}\" completed successfully.", scannerItem.FileName); } else { - //Logger.Write(this, LogLevel.Warn, "Scanning file \"{0}\" failed: Unknown error.", scannerItem.FileName); + Logger.Write(this, LogLevel.Warn, "Scanning file \"{0}\" failed: Unknown error.", scannerItem.FileName); } } catch (OperationCanceledException) { - //Logger.Write(this, LogLevel.Warn, "Skipping file \"{0}\" due to cancellation.", scannerItem.FileName); + Logger.Write(this, LogLevel.Warn, "Skipping file \"{0}\" due to cancellation.", scannerItem.FileName); scannerItem.Status = ScannerItemStatus.Cancelled; return; } catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Scanning file \"{0}\" failed: {1}", scannerItem.FileName, e.Message); + Logger.Write(this, LogLevel.Warn, "Scanning file \"{0}\" failed: {1}", scannerItem.FileName, e.Message); scannerItem.Status = ScannerItemStatus.Failed; scannerItem.AddError(e.Message); } @@ -109,10 +109,10 @@ protected virtual void ScanTrack(ScannerItem scannerItem) { if (stream.IsEmpty) { - //Logger.Write(this, LogLevel.Warn, "Failed to create stream for file \"{0}\": Unknown error.", scannerItem.FileName); + Logger.Write(this, LogLevel.Warn, "Failed to create stream for file \"{0}\": Unknown error.", scannerItem.FileName); return; } - //Logger.Write(this, LogLevel.Debug, "Created stream for file \"{0}\": {1}", scannerItem.FileName, stream.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Created stream for file \"{0}\": {1}", scannerItem.FileName, stream.ChannelHandle); using (var monitor = new ChannelMonitor(scannerItem, stream)) { monitor.Start(); @@ -129,7 +129,7 @@ protected virtual void ScanTrack(ScannerItem scannerItem) } else { - //Logger.Write(this, LogLevel.Warn, "Scanning file \"{0}\" failed: The format is likely not supported.", scannerItem.FileName); + Logger.Write(this, LogLevel.Warn, "Scanning file \"{0}\" failed: The format is likely not supported.", scannerItem.FileName); scannerItem.AddError("The format is likely not supported."); scannerItem.AddError("Only stereo files of common sample rates are supported."); scannerItem.Status = ScannerItemStatus.Failed; @@ -163,13 +163,13 @@ protected virtual void ScanGroups(IEnumerable> groups) { if (this.CancellationToken.IsCancellationRequested) { - //Logger.Write(this, LogLevel.Warn, "Skipping file \"{0}\" due to cancellation.", scannerItem.FileName); + Logger.Write(this, LogLevel.Warn, "Skipping file \"{0}\" due to cancellation.", scannerItem.FileName); scannerItem.Status = ScannerItemStatus.Cancelled; continue; } if (!this.CheckInput(scannerItem.FileName)) { - //Logger.Write(this, LogLevel.Warn, "Skipping file \"{0}\" due to file \"{1}\" does not exist.", scannerItem.FileName); + Logger.Write(this, LogLevel.Warn, "Skipping file \"{0}\" due to file \"{1}\" does not exist.", scannerItem.FileName); scannerItem.Status = ScannerItemStatus.Failed; scannerItem.AddError(string.Format("File \"{0}\" does not exist.", scannerItem.FileName)); continue; @@ -178,23 +178,23 @@ protected virtual void ScanGroups(IEnumerable> groups) var stream = this.CreateStream(scannerItem.FileName, flags); if (stream.IsEmpty) { - //Logger.Write(this, LogLevel.Warn, "Failed to create stream for file \"{0}\": Unknown error.", scannerItem.FileName); + Logger.Write(this, LogLevel.Warn, "Failed to create stream for file \"{0}\": Unknown error.", scannerItem.FileName); continue; } - //Logger.Write(this, LogLevel.Debug, "Created stream for file \"{0}\": {1}", scannerItem.FileName, stream.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Created stream for file \"{0}\": {1}", scannerItem.FileName, stream.ChannelHandle); streams.Add(scannerItem, stream); - //Logger.Write(this, LogLevel.Debug, "Beginning scanning file \"{0}\".", scannerItem.FileName); + Logger.Write(this, LogLevel.Debug, "Beginning scanning file \"{0}\".", scannerItem.FileName); scannerItem.Progress = ScannerItem.PROGRESS_NONE; scannerItem.Status = ScannerItemStatus.Processing; } catch (OperationCanceledException) { - //Logger.Write(this, LogLevel.Warn, "Skipping file \"{0}\" due to cancellation.", scannerItem.FileName); + Logger.Write(this, LogLevel.Warn, "Skipping file \"{0}\" due to cancellation.", scannerItem.FileName); scannerItem.Status = ScannerItemStatus.Cancelled; } catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Scanning file \"{0}\" failed: {1}", scannerItem.FileName, e.Message); + Logger.Write(this, LogLevel.Warn, "Scanning file \"{0}\" failed: {1}", scannerItem.FileName, e.Message); scannerItem.Status = ScannerItemStatus.Failed; scannerItem.AddError(e.Message); } @@ -230,12 +230,12 @@ protected virtual void ScanGroups(IEnumerable> groups) } else if (success) { - //Logger.Write(this, LogLevel.Debug, "Scanning file \"{0}\" completed successfully.", scannerItem.FileName); + Logger.Write(this, LogLevel.Debug, "Scanning file \"{0}\" completed successfully.", scannerItem.FileName); scannerItem.Status = ScannerItemStatus.Complete; } else { - //Logger.Write(this, LogLevel.Warn, "Scanning file \"{0}\" failed: The format is likely not supported.", scannerItem.FileName); + Logger.Write(this, LogLevel.Warn, "Scanning file \"{0}\" failed: The format is likely not supported.", scannerItem.FileName); scannerItem.AddError("The format is likely not supported."); scannerItem.Status = ScannerItemStatus.Failed; } diff --git a/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScannerBehaviour.cs b/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScannerBehaviour.cs index e8065c514..ac5e0ee29 100644 --- a/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScannerBehaviour.cs +++ b/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScannerBehaviour.cs @@ -338,10 +338,10 @@ public override void InitializeComponent(ICore core) protected override async Task OnRun() { - //Logger.Write(this, LogLevel.Debug, "Creating scanner."); + Logger.Write(this, LogLevel.Debug, "Creating scanner."); using (var scanner = ScannerFactory.CreateScanner(this.ScannerItems)) { - //Logger.Write(this, LogLevel.Debug, "Starting scanner."); + Logger.Write(this, LogLevel.Debug, "Starting scanner."); using (var monitor = new BassReplayGainScannerMonitor(scanner, this.Visible, this.CancellationToken)) { await this.WithSubTask(monitor, @@ -350,7 +350,7 @@ await this.WithSubTask(monitor, this.ScannerItems = monitor.ScannerItems.Values.ToArray(); } } - //Logger.Write(this, LogLevel.Debug, "Scanner completed successfully."); + Logger.Write(this, LogLevel.Debug, "Scanner completed successfully."); } protected override async Task OnCompleted() diff --git a/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScannerFactory.cs b/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScannerFactory.cs index 36ae0f363..61c919359 100644 --- a/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScannerFactory.cs +++ b/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScannerFactory.cs @@ -24,7 +24,7 @@ public IBassReplayGainScanner CreateScanner(IEnumerable scannerItem protected virtual Process CreateProcess() { - //Logger.Write(this, LogLevel.Debug, "Creating scanner container process: {0}", this.Location); + Logger.Write(this, LogLevel.Debug, "Creating scanner container process: {0}", this.Location); var processStartInfo = new ProcessStartInfo() { FileName = this.Location, @@ -41,7 +41,7 @@ protected virtual Process CreateProcess() { return; } - //Logger.Write(this, LogLevel.Trace, "{0}: {1}", this.Location, e.Data); + Logger.Write(this, LogLevel.Trace, "{0}: {1}", this.Location, e.Data); }; process.BeginErrorReadLine(); return process; diff --git a/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScannerHost.cs b/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScannerHost.cs index f6a9f3a88..02d4e6963 100644 --- a/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScannerHost.cs +++ b/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScannerHost.cs @@ -9,6 +9,14 @@ namespace FoxTunes { public static class BassReplayGainScannerHost { + private static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + public static string Location { get @@ -66,25 +74,25 @@ private static void Scan(Stream input, Stream output, Stream error) }); core.Initialize(); } - catch + catch (Exception e) { - //Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Error, "Failed to initialize core: {0}", e.Message); + Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Error, "Failed to initialize core: {0}", e.Message); throw; } try { - //Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Begin reading items."); + Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Begin reading items."); var scannerItems = ReadInput(input); - //Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Read {0} items.", scannerItems.Length); + Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Read {0} items.", scannerItems.Length); using (var scanner = new BassReplayGainScanner(scannerItems)) { scanner.InitializeComponent(core); Scan(scanner, input, output, error); } } - catch + catch (Exception e) { - //Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Error, "Failed to scan items: {0}", e.Message); + Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Error, "Failed to scan items: {0}", e.Message); throw; } } @@ -96,15 +104,15 @@ private static void Scan(IBassReplayGainScanner scanner, Stream input, Stream ou { try { - //Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Starting scanner main thread."); + Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Starting scanner main thread."); scanner.Scan(); - //Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Finished scanner main thread."); + Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Finished scanner main thread."); WriteOutput(output, new ScannerStatus(ScannerStatusType.Complete)); error.Flush(); } catch (Exception e) { - //Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Error, "Error on scanner main thread: {0}", e.Message); + Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Error, "Error on scanner main thread: {0}", e.Message); WriteOutput(output, new ScannerStatus(ScannerStatusType.Error)); new StreamWriter(error).Write(e.Message); error.Flush(); @@ -117,18 +125,18 @@ private static void Scan(IBassReplayGainScanner scanner, Stream input, Stream ou { try { - //Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Starting scanner output thread."); + Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Starting scanner output thread."); while (thread1.IsAlive) { ProcessOutput(scanner, output); Thread.Sleep(INTERVAL); } ProcessOutput(scanner, output); - //Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Finished scanner output thread."); + Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Finished scanner output thread."); } - catch + catch (Exception e) { - //Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Error, "Error on scanner output thread: {0}", e.Message); + Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Error, "Error on scanner output thread: {0}", e.Message); } }) { @@ -139,7 +147,7 @@ private static void Scan(IBassReplayGainScanner scanner, Stream input, Stream ou var exit = default(bool); try { - //Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Starting scanner input thread."); + Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Starting scanner input thread."); while (thread1.IsAlive) { ProcessInput(scanner, input, output, out exit); @@ -153,11 +161,11 @@ private static void Scan(IBassReplayGainScanner scanner, Stream input, Stream ou { ProcessInput(scanner, input, output, out exit); } - //Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Finished scanner input thread."); + Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Finished scanner input thread."); } - catch + catch (Exception e) { - //Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Error, "Error on scanner input thread: {0}", e.Message); + Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Error, "Error on scanner input thread: {0}", e.Message); } }) { @@ -169,32 +177,32 @@ private static void Scan(IBassReplayGainScanner scanner, Stream input, Stream ou thread1.Join(); if (!thread2.Join(TIMEOUT)) { - //Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Warn, "Scanner output thread did not complete gracefully, aborting."); + Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Warn, "Scanner output thread did not complete gracefully, aborting."); thread2.Abort(); } if (!thread3.Join(TIMEOUT)) { - //Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Warn, "Scanner input thread did not complete gracefully, aborting."); + Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Warn, "Scanner input thread did not complete gracefully, aborting."); thread3.Abort(); } } private static void ProcessInput(IBassReplayGainScanner scanner, Stream input, Stream output, out bool exit) { - //Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Begin reading command."); + Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Begin reading command."); var command = ReadInput(input); - //Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Read command: {0}", Enum.GetName(typeof(ScannerCommandType), command.Type)); + Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Read command: {0}", Enum.GetName(typeof(ScannerCommandType), command.Type)); switch (command.Type) { case ScannerCommandType.Cancel: - //Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Sending cancellation signal to scanner."); + Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Sending cancellation signal to scanner."); scanner.Cancel(); - //Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Closing stdin."); + Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Closing stdin."); input.Close(); exit = true; break; case ScannerCommandType.Quit: - //Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Closing stdin/stdout."); + Logger.Write(typeof(BassReplayGainScannerHost), LogLevel.Debug, "Closing stdin/stdout."); input.Close(); output.Close(); exit = true; diff --git a/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScannerMonitor.cs b/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScannerMonitor.cs index 043fffce5..ce9387336 100644 --- a/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScannerMonitor.cs +++ b/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScannerMonitor.cs @@ -48,7 +48,7 @@ protected virtual async Task Monitor(Task task) { if (this.CancellationToken.IsCancellationRequested) { - //Logger.Write(this, LogLevel.Debug, "Requesting cancellation from scanner."); + Logger.Write(this, LogLevel.Debug, "Requesting cancellation from scanner."); this.Scanner.Cancel(); this.Name = "Cancelling"; break; @@ -89,7 +89,7 @@ protected virtual async Task Monitor(Task task) } while (!task.IsCompleted) { - //Logger.Write(this, LogLevel.Debug, "Waiting for scanner to complete."); + Logger.Write(this, LogLevel.Debug, "Waiting for scanner to complete."); this.Scanner.Update(); #if NET40 await TaskEx.Delay(INTERVAL).ConfigureAwait(false); diff --git a/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScannerProxy.cs b/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScannerProxy.cs index be610a4ce..96ac6aa09 100644 --- a/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScannerProxy.cs +++ b/FoxTunes.Output.Bass.ReplayGain/BassReplayGainScannerProxy.cs @@ -37,9 +37,9 @@ public BassScannerProxy(Process process, IEnumerable scannerItems) public void Scan() { - //Logger.Write(this, LogLevel.Debug, "Sending {0} items to scanner container process.", this.ScannerItems.Count()); + Logger.Write(this, LogLevel.Debug, "Sending {0} items to scanner container process.", this.ScannerItems.Count()); this.Send(this.ScannerItems.ToArray()); - //Logger.Write(this, LogLevel.Debug, "Waiting for scanner container process to complete."); + Logger.Write(this, LogLevel.Debug, "Waiting for scanner container process to complete."); this.Process.WaitForExit(); this.TerminateCallback.Disable(); if (this.Process.ExitCode != 0) @@ -78,7 +78,7 @@ public void Update() public void Cancel() { - //Logger.Write(this, LogLevel.Debug, "Sending cancel command to scanner container process."); + Logger.Write(this, LogLevel.Debug, "Sending cancel command to scanner container process."); this.Send(new ScannerCommand(ScannerCommandType.Cancel)); this.Process.StandardInput.Close(); this.TerminateCallback.Enable(); @@ -86,7 +86,7 @@ public void Cancel() public void Quit() { - //Logger.Write(this, LogLevel.Debug, "Sending quit command to scanner container process."); + Logger.Write(this, LogLevel.Debug, "Sending quit command to scanner container process."); this.Send(new ScannerCommand(ScannerCommandType.Quit)); this.Process.StandardInput.Close(); this.TerminateCallback.Enable(); @@ -100,12 +100,12 @@ protected virtual void Terminate() { return; } - //Logger.Write(this, LogLevel.Warn, "Scanner container process did not exit after {0}ms, terminating it.", TIMEOUT); + Logger.Write(this, LogLevel.Warn, "Scanner container process did not exit after {0}ms, terminating it.", TIMEOUT); this.Process.Kill(); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Error, "Failed to terminate scanner container process: {0}", e.Message); + Logger.Write(this, LogLevel.Error, "Failed to terminate scanner container process: {0}", e.Message); } } @@ -150,12 +150,12 @@ protected virtual object Recieve() protected virtual void UpdateStatus(ScannerStatus status) { - //Logger.Write(this, LogLevel.Debug, "Recieved status from scanner container process: {0}", Enum.GetName(typeof(ScannerStatusType), status.Type)); + Logger.Write(this, LogLevel.Debug, "Recieved status from scanner container process: {0}", Enum.GetName(typeof(ScannerStatusType), status.Type)); switch (status.Type) { case ScannerStatusType.Complete: case ScannerStatusType.Error: - //Logger.Write(this, LogLevel.Debug, "Fetching final status and shutting down scanner container process."); + Logger.Write(this, LogLevel.Debug, "Fetching final status and shutting down scanner container process."); this.Update(); this.Quit(); this.Process.StandardInput.Close(); @@ -193,7 +193,7 @@ protected virtual void OnDisposing() { if (!this.Process.HasExited) { - //Logger.Write(this, LogLevel.Warn, "Process is incomplete."); + Logger.Write(this, LogLevel.Warn, "Process is incomplete."); this.Process.Kill(); } this.Process.Dispose(); @@ -202,7 +202,7 @@ protected virtual void OnDisposing() ~BassScannerProxy() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.ReplayGain/ChannelMonitor.cs b/FoxTunes.Output.Bass.ReplayGain/ChannelMonitor.cs index e39400897..fb47b1255 100644 --- a/FoxTunes.Output.Bass.ReplayGain/ChannelMonitor.cs +++ b/FoxTunes.Output.Bass.ReplayGain/ChannelMonitor.cs @@ -113,7 +113,7 @@ protected virtual void OnDisposing() ~ChannelMonitor() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.ReplayGain/VolumeEffect.cs b/FoxTunes.Output.Bass.ReplayGain/VolumeEffect.cs index fcb1b2242..f0611e111 100644 --- a/FoxTunes.Output.Bass.ReplayGain/VolumeEffect.cs +++ b/FoxTunes.Output.Bass.ReplayGain/VolumeEffect.cs @@ -105,7 +105,7 @@ protected virtual void OnDisposing() ~VolumeEffect() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.Resampler/BassResamplerStreamComponent.cs b/FoxTunes.Output.Bass.Resampler/BassResamplerStreamComponent.cs index c5b0c8191..cff7e84d3 100644 --- a/FoxTunes.Output.Bass.Resampler/BassResamplerStreamComponent.cs +++ b/FoxTunes.Output.Bass.Resampler/BassResamplerStreamComponent.cs @@ -93,7 +93,7 @@ public override void Connect(IBassStreamComponent previous) //We already established that the output does not support the stream rate so use the closest one. rate = this.Query.GetNearestRate(rate); } - //Logger.Write(this, LogLevel.Debug, "Creating BASS SOX stream with rate {0} => {1} and {2} channels.", this.InputRate, rate, channels); + Logger.Write(this, LogLevel.Debug, "Creating BASS SOX stream with rate {0} => {1} and {2} channels.", this.InputRate, rate, channels); this.ChannelHandle = BassSox.StreamCreate(rate, flags, previous.ChannelHandle); if (this.ChannelHandle == 0) { @@ -105,7 +105,7 @@ public override void Connect(IBassStreamComponent previous) public override void ClearBuffer() { - //Logger.Write(this, LogLevel.Debug, "Clearing BASS SOX buffer: {0}", this.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Clearing BASS SOX buffer: {0}", this.ChannelHandle); BassUtils.OK(BassSox.StreamBufferClear(this.ChannelHandle)); base.ClearBuffer(); } @@ -124,7 +124,7 @@ public bool IsBackground { return; } - //Logger.Write(this, LogLevel.Debug, "Setting BASS SOX attribute \"{0}\" = \"{1}\"", Enum.GetName(typeof(SoxChannelAttribute), SoxChannelAttribute.Background), value); + Logger.Write(this, LogLevel.Debug, "Setting BASS SOX attribute \"{0}\" = \"{1}\"", Enum.GetName(typeof(SoxChannelAttribute), SoxChannelAttribute.Background), value); BassUtils.OK(BassSox.ChannelSetAttribute(this.ChannelHandle, SoxChannelAttribute.Background, value)); } } @@ -186,7 +186,7 @@ protected override void OnDisposing() { if (this.ChannelHandle != 0) { - //Logger.Write(this, LogLevel.Debug, "Freeing BASS SOX stream: {0}", this.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Freeing BASS SOX stream: {0}", this.ChannelHandle); BassUtils.OK(Bass.StreamFree(this.ChannelHandle)); } } @@ -385,17 +385,17 @@ public void Configure() { return; } - //Logger.Write(this, LogLevel.Debug, "Setting BASS SOX attribute \"{0}\" = \"{1}\"", Enum.GetName(typeof(SoxChannelAttribute), SoxChannelAttribute.Quality), Enum.GetName(typeof(SoxChannelQuality), this.Quality)); + Logger.Write(this, LogLevel.Debug, "Setting BASS SOX attribute \"{0}\" = \"{1}\"", Enum.GetName(typeof(SoxChannelAttribute), SoxChannelAttribute.Quality), Enum.GetName(typeof(SoxChannelQuality), this.Quality)); BassUtils.OK(BassSox.ChannelSetAttribute(this.ChannelHandle, SoxChannelAttribute.Quality, this.Quality)); - //Logger.Write(this, LogLevel.Debug, "Setting BASS SOX attribute \"{0}\" = \"{1}\"", Enum.GetName(typeof(SoxChannelAttribute), SoxChannelAttribute.Phase), Enum.GetName(typeof(SoxChannelPhase), this.Phase)); + Logger.Write(this, LogLevel.Debug, "Setting BASS SOX attribute \"{0}\" = \"{1}\"", Enum.GetName(typeof(SoxChannelAttribute), SoxChannelAttribute.Phase), Enum.GetName(typeof(SoxChannelPhase), this.Phase)); BassUtils.OK(BassSox.ChannelSetAttribute(this.ChannelHandle, SoxChannelAttribute.Phase, this.Phase)); - //Logger.Write(this, LogLevel.Debug, "Setting BASS SOX attribute \"{0}\" = \"{1}\"", Enum.GetName(typeof(SoxChannelAttribute), SoxChannelAttribute.SteepFilter), this.SteepFilter); + Logger.Write(this, LogLevel.Debug, "Setting BASS SOX attribute \"{0}\" = \"{1}\"", Enum.GetName(typeof(SoxChannelAttribute), SoxChannelAttribute.SteepFilter), this.SteepFilter); BassUtils.OK(BassSox.ChannelSetAttribute(this.ChannelHandle, SoxChannelAttribute.SteepFilter, this.SteepFilter)); - //Logger.Write(this, LogLevel.Debug, "Setting BASS SOX attribute \"{0}\" = \"{1}\"", Enum.GetName(typeof(SoxChannelAttribute), SoxChannelAttribute.InputBufferLength), this.InputBufferLength); + Logger.Write(this, LogLevel.Debug, "Setting BASS SOX attribute \"{0}\" = \"{1}\"", Enum.GetName(typeof(SoxChannelAttribute), SoxChannelAttribute.InputBufferLength), this.InputBufferLength); BassUtils.OK(BassSox.ChannelSetAttribute(this.ChannelHandle, SoxChannelAttribute.InputBufferLength, this.InputBufferLength)); - //Logger.Write(this, LogLevel.Debug, "Setting BASS SOX attribute \"{0}\" = \"{1}\"", Enum.GetName(typeof(SoxChannelAttribute), SoxChannelAttribute.PlaybackBufferLength), this.PlaybackBufferLength); + Logger.Write(this, LogLevel.Debug, "Setting BASS SOX attribute \"{0}\" = \"{1}\"", Enum.GetName(typeof(SoxChannelAttribute), SoxChannelAttribute.PlaybackBufferLength), this.PlaybackBufferLength); BassUtils.OK(BassSox.ChannelSetAttribute(this.ChannelHandle, SoxChannelAttribute.PlaybackBufferLength, this.PlaybackBufferLength)); - //Logger.Write(this, LogLevel.Debug, "Setting BASS SOX attribute \"{0}\" = \"{1}\"", Enum.GetName(typeof(SoxChannelAttribute), SoxChannelAttribute.KeepAlive), true); + Logger.Write(this, LogLevel.Debug, "Setting BASS SOX attribute \"{0}\" = \"{1}\"", Enum.GetName(typeof(SoxChannelAttribute), SoxChannelAttribute.KeepAlive), true); BassUtils.OK(BassSox.ChannelSetAttribute(this.ChannelHandle, SoxChannelAttribute.KeepAlive, true)); } } diff --git a/FoxTunes.Output.Bass.Resampler/BassResamplerStreamComponentBehaviour.cs b/FoxTunes.Output.Bass.Resampler/BassResamplerStreamComponentBehaviour.cs index 0e6e8b567..dcf404ab1 100644 --- a/FoxTunes.Output.Bass.Resampler/BassResamplerStreamComponentBehaviour.cs +++ b/FoxTunes.Output.Bass.Resampler/BassResamplerStreamComponentBehaviour.cs @@ -43,7 +43,7 @@ public bool Enabled set { this._Enabled = value; - //Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); + Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); var task = this.Output.Shutdown(); } } @@ -110,7 +110,7 @@ protected virtual void OnDisposing() ~BassResamplerStreamComponentBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.Tempo/BassOutputTempo.cs b/FoxTunes.Output.Bass.Tempo/BassOutputTempo.cs index cd4dad776..e87f410ad 100644 --- a/FoxTunes.Output.Bass.Tempo/BassOutputTempo.cs +++ b/FoxTunes.Output.Bass.Tempo/BassOutputTempo.cs @@ -232,7 +232,7 @@ protected virtual void OnDisposing() ~BassOutputTempo() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.Tempo/BassOutputTempoStreamComponent.cs b/FoxTunes.Output.Bass.Tempo/BassOutputTempoStreamComponent.cs index c311fe764..4d0ba557f 100644 --- a/FoxTunes.Output.Bass.Tempo/BassOutputTempoStreamComponent.cs +++ b/FoxTunes.Output.Bass.Tempo/BassOutputTempoStreamComponent.cs @@ -127,15 +127,15 @@ protected virtual void OnValueChanged(object sender, EventArgs e) protected virtual void Update() { var rate = GetTempoFrequency(BassUtils.GetChannelPcmRate(this.ChannelHandle), this.OutputEffects.Tempo.Rate); - //Logger.Write( - // this, - // LogLevel.Debug, - // "Tempo effect enabled: Tempo {0}%, Pitch {1} semitones, Rate {2}{3}", - // this.OutputEffects.Tempo.Value, - // this.OutputEffects.Tempo.Pitch, - // MetaDataInfo.SampleRateDescription(rate), - // this.AAFilter.Value ? string.Format(", aa filter {0} taps", this.AAFilterLength) : string.Empty - //); + Logger.Write( + this, + LogLevel.Debug, + "Tempo effect enabled: Tempo {0}%, Pitch {1} semitones, Rate {2}{3}", + this.OutputEffects.Tempo.Value, + this.OutputEffects.Tempo.Pitch, + MetaDataInfo.SampleRateDescription(rate), + this.AAFilter.Value ? string.Format(", aa filter {0} taps", this.AAFilterLength) : string.Empty + ); BassUtils.OK(Bass.ChannelSetAttribute(this.ChannelHandle, ChannelAttribute.Tempo, this.OutputEffects.Tempo.Value)); BassUtils.OK(Bass.ChannelSetAttribute(this.ChannelHandle, ChannelAttribute.Pitch, this.OutputEffects.Tempo.Pitch)); BassUtils.OK(Bass.ChannelSetAttribute(this.ChannelHandle, ChannelAttribute.TempoFrequency, rate)); @@ -147,7 +147,7 @@ protected virtual void Update() protected virtual void Stop() { var rate = BassUtils.GetChannelPcmRate(this.ChannelHandle); - //Logger.Write(this, LogLevel.Debug, "Tempo effect disabled."); + Logger.Write(this, LogLevel.Debug, "Tempo effect disabled."); BassUtils.OK(Bass.ChannelSetAttribute(this.ChannelHandle, ChannelAttribute.Tempo, 0)); BassUtils.OK(Bass.ChannelSetAttribute(this.ChannelHandle, ChannelAttribute.Pitch, 0)); BassUtils.OK(Bass.ChannelSetAttribute(this.ChannelHandle, ChannelAttribute.TempoFrequency, rate)); diff --git a/FoxTunes.Output.Bass.Tempo/BassOutputTempoStreamComponentBehaviour.cs b/FoxTunes.Output.Bass.Tempo/BassOutputTempoStreamComponentBehaviour.cs index 72f2f561e..315a9371f 100644 --- a/FoxTunes.Output.Bass.Tempo/BassOutputTempoStreamComponentBehaviour.cs +++ b/FoxTunes.Output.Bass.Tempo/BassOutputTempoStreamComponentBehaviour.cs @@ -30,7 +30,7 @@ public bool Enabled set { this._Enabled = value; - //Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); + Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); } } @@ -69,7 +69,7 @@ protected virtual void OnCreatingPipeline(object sender, CreatingPipelineEventAr { if (!BassOutputTempoStreamComponent.ShouldCreate(this, e.Stream, e.Query)) { - //Logger.Write(this, LogLevel.Debug, "Cannot create component, the stream is not supported."); + Logger.Write(this, LogLevel.Debug, "Cannot create component, the stream is not supported."); return; } var component = new BassOutputTempoStreamComponent(this, e.Pipeline, e.Stream.Flags); @@ -115,7 +115,7 @@ protected virtual void OnDisposing() ~BassOutputTempoStreamComponentBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.Wasapi/BassWasapiDevice.cs b/FoxTunes.Output.Bass.Wasapi/BassWasapiDevice.cs index f3cafbd05..fdaa0c3ad 100644 --- a/FoxTunes.Output.Bass.Wasapi/BassWasapiDevice.cs +++ b/FoxTunes.Output.Bass.Wasapi/BassWasapiDevice.cs @@ -9,6 +9,14 @@ namespace FoxTunes { public static class BassWasapiDevice { + private static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + public const float MIN_BUFFER_LENGTH = 0.1f; public const float MAX_BUFFER_LENGTH = 1.0f; @@ -49,7 +57,7 @@ public static void Init(int device, bool exclusive, bool autoFormat, float buffe IsInitialized = true; - //Logger.Write(typeof(BassWasapiDevice), LogLevel.Debug, "Initializing BASS WASAPI."); + Logger.Write(typeof(BassWasapiDevice), LogLevel.Debug, "Initializing BASS WASAPI."); try { @@ -64,11 +72,11 @@ public static void Init(int device, bool exclusive, bool autoFormat, float buffe ) ); Update(device, flags); - //Logger.Write(typeof(BassWasapiDevice), LogLevel.Debug, "Initialized WASAPI device: {0} => Inputs => {1}, Outputs = {2}, Rate = {3}, Format = {4}", BassWasapi.CurrentDevice, Info.Inputs, Info.Outputs, Info.Rate, Enum.GetName(typeof(WasapiFormat), Info.Format)); - //Logger.Write(typeof(BassWasapiDevice), LogLevel.Debug, "Initialized WASAPI device: {0} => Rates => {1}", BassWasapi.CurrentDevice, string.Join(", ", Info.SupportedRates)); + Logger.Write(typeof(BassWasapiDevice), LogLevel.Debug, "Initialized WASAPI device: {0} => Inputs => {1}, Outputs = {2}, Rate = {3}, Format = {4}", BassWasapi.CurrentDevice, Info.Inputs, Info.Outputs, Info.Rate, Enum.GetName(typeof(WasapiFormat), Info.Format)); + Logger.Write(typeof(BassWasapiDevice), LogLevel.Debug, "Initialized WASAPI device: {0} => Rates => {1}", BassWasapi.CurrentDevice, string.Join(", ", Info.SupportedRates)); foreach (var pair in Info.SupportedFormats) { - //Logger.Write(typeof(BassWasapiDevice), LogLevel.Debug, "Initialized WASAPI device: {0} => Format => {1} => {2}", BassWasapi.CurrentDevice, pair.Key, Enum.GetName(typeof(WasapiFormat), pair.Value)); + Logger.Write(typeof(BassWasapiDevice), LogLevel.Debug, "Initialized WASAPI device: {0} => Format => {1} => {2}", BassWasapi.CurrentDevice, pair.Key, Enum.GetName(typeof(WasapiFormat), pair.Value)); } } catch @@ -87,7 +95,7 @@ public static void Detect(int device, bool exclusive, bool autoFormat, float buf IsInitialized = true; - //Logger.Write(typeof(BassWasapiDevice), LogLevel.Debug, "Detecting WASAPI device."); + Logger.Write(typeof(BassWasapiDevice), LogLevel.Debug, "Detecting WASAPI device."); try { @@ -102,11 +110,11 @@ public static void Detect(int device, bool exclusive, bool autoFormat, float buf ) ); Update(device, flags); - //Logger.Write(typeof(BassWasapiDevice), LogLevel.Debug, "Detected WASAPI device: {0} => Inputs => {1}, Outputs = {2}, Rate = {3}, Format = {4}", BassWasapi.CurrentDevice, Info.Inputs, Info.Outputs, Info.Rate, Enum.GetName(typeof(WasapiFormat), Info.Format)); - //Logger.Write(typeof(BassWasapiDevice), LogLevel.Debug, "Detected WASAPI device: {0} => Rates => {1}", BassWasapi.CurrentDevice, string.Join(", ", Info.SupportedRates)); + Logger.Write(typeof(BassWasapiDevice), LogLevel.Debug, "Detected WASAPI device: {0} => Inputs => {1}, Outputs = {2}, Rate = {3}, Format = {4}", BassWasapi.CurrentDevice, Info.Inputs, Info.Outputs, Info.Rate, Enum.GetName(typeof(WasapiFormat), Info.Format)); + Logger.Write(typeof(BassWasapiDevice), LogLevel.Debug, "Detected WASAPI device: {0} => Rates => {1}", BassWasapi.CurrentDevice, string.Join(", ", Info.SupportedRates)); foreach (var pair in Info.SupportedFormats) { - //Logger.Write(typeof(BassWasapiDevice), LogLevel.Debug, "Detected WASAPI device: {0} => Format => {1} => {2}", BassWasapi.CurrentDevice, pair.Key, Enum.GetName(typeof(WasapiFormat), pair.Value)); + Logger.Write(typeof(BassWasapiDevice), LogLevel.Debug, "Detected WASAPI device: {0} => Format => {1} => {2}", BassWasapi.CurrentDevice, pair.Key, Enum.GetName(typeof(WasapiFormat), pair.Value)); } } finally @@ -201,7 +209,7 @@ public static void Free() { return; } - //Logger.Write(typeof(BassWasapiDevice), LogLevel.Debug, "Releasing BASS WASAPI."); + Logger.Write(typeof(BassWasapiDevice), LogLevel.Debug, "Releasing BASS WASAPI."); BassWasapi.Free(); BassWasapiHandler.Free(); IsInitialized = false; diff --git a/FoxTunes.Output.Bass.Wasapi/BassWasapiStreamOutput.cs b/FoxTunes.Output.Bass.Wasapi/BassWasapiStreamOutput.cs index 284d9f044..c2735b4e7 100644 --- a/FoxTunes.Output.Bass.Wasapi/BassWasapiStreamOutput.cs +++ b/FoxTunes.Output.Bass.Wasapi/BassWasapiStreamOutput.cs @@ -88,20 +88,20 @@ public override void Connect(IBassStreamComponent previous) this.ConfigureWASAPI(previous, out rate, out channels, out flags); if (this.ShouldCreateMixer(previous, rate, channels, flags)) { - //Logger.Write(this, LogLevel.Debug, "Creating BASS MIX stream with rate {0} and {1} channels.", rate, channels); + Logger.Write(this, LogLevel.Debug, "Creating BASS MIX stream with rate {0} and {1} channels.", rate, channels); this.ChannelHandle = BassMix.CreateMixerStream(rate, channels, flags); if (this.ChannelHandle == 0) { BassUtils.Throw(); } - //Logger.Write(this, LogLevel.Debug, "Adding stream to the mixer: {0}", previous.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Adding stream to the mixer: {0}", previous.ChannelHandle); BassUtils.OK(BassMix.MixerAddChannel(this.ChannelHandle, previous.ChannelHandle, BassFlags.Default | BassFlags.MixerBuffer | BassFlags.MixerDownMix)); BassUtils.OK(BassWasapiHandler.StreamSet(this.ChannelHandle)); this.MixerChannelHandles.Add(previous.ChannelHandle); } else { - //Logger.Write(this, LogLevel.Debug, "The stream properties match the device, playing directly."); + Logger.Write(this, LogLevel.Debug, "The stream properties match the device, playing directly."); BassUtils.OK(BassWasapiHandler.StreamSet(previous.ChannelHandle)); this.ChannelHandle = previous.ChannelHandle; } @@ -123,7 +123,7 @@ protected virtual void ConfigureWASAPI(IBassStreamComponent previous, out int ra if (!BassWasapiDevice.Info.SupportedRates.Contains(targetRate)) { var nearestRate = BassWasapiDevice.Info.GetNearestRate(targetRate); - //Logger.Write(this, LogLevel.Warn, "Enforced rate {0} isn't supposed by the device, falling back to {1}.", targetRate, nearestRate); + Logger.Write(this, LogLevel.Warn, "Enforced rate {0} isn't supposed by the device, falling back to {1}.", targetRate, nearestRate); rate = nearestRate; } else @@ -136,13 +136,13 @@ protected virtual void ConfigureWASAPI(IBassStreamComponent previous, out int ra if (!BassWasapiDevice.Info.SupportedRates.Contains(rate)) { var nearestRate = BassWasapiDevice.Info.GetNearestRate(rate); - //Logger.Write(this, LogLevel.Debug, "Stream rate {0} isn't supposed by the device, falling back to {1}.", rate, nearestRate); + Logger.Write(this, LogLevel.Debug, "Stream rate {0} isn't supposed by the device, falling back to {1}.", rate, nearestRate); rate = nearestRate; } } if (BassWasapiDevice.Info.Outputs < channels) { - //Logger.Write(this, LogLevel.Debug, "Stream channel count {0} isn't supported by the device, falling back to {1} channels.", channels, BassWasapiDevice.Info.Outputs); + Logger.Write(this, LogLevel.Debug, "Stream channel count {0} isn't supported by the device, falling back to {1} channels.", channels, BassWasapiDevice.Info.Outputs); channels = BassWasapiDevice.Info.Outputs; } } @@ -165,10 +165,10 @@ protected virtual bool StartWASAPI() { if (BassWasapi.IsStarted) { - //Logger.Write(this, LogLevel.Debug, "WASAPI has already been started."); + Logger.Write(this, LogLevel.Debug, "WASAPI has already been started."); return false; } - //Logger.Write(this, LogLevel.Debug, "Starting WASAPI."); + Logger.Write(this, LogLevel.Debug, "Starting WASAPI."); BassUtils.OK(BassWasapi.Start()); return true; } @@ -177,10 +177,10 @@ protected virtual bool StopWASAPI(bool reset) { if (!BassWasapi.IsStarted) { - //Logger.Write(this, LogLevel.Debug, "WASAPI has not been started."); + Logger.Write(this, LogLevel.Debug, "WASAPI has not been started."); return false; } - //Logger.Write(this, LogLevel.Debug, "Stopping WASAPI."); + Logger.Write(this, LogLevel.Debug, "Stopping WASAPI."); BassUtils.OK(BassWasapi.Stop(reset)); return true; } @@ -213,7 +213,7 @@ public override void ClearBuffer() { foreach (var channelHandle in this.MixerChannelHandles) { - //Logger.Write(this, LogLevel.Debug, "Clearing mixer buffer."); + Logger.Write(this, LogLevel.Debug, "Clearing mixer buffer."); Bass.ChannelSetPosition(channelHandle, 0); } base.ClearBuffer(); @@ -251,7 +251,7 @@ public override void Play() { return; } - //Logger.Write(this, LogLevel.Debug, "Starting WASAPI."); + Logger.Write(this, LogLevel.Debug, "Starting WASAPI."); try { BassUtils.OK(this.StartWASAPI()); @@ -270,7 +270,7 @@ public override void Pause() { return; } - //Logger.Write(this, LogLevel.Debug, "Pausing WASAPI."); + Logger.Write(this, LogLevel.Debug, "Pausing WASAPI."); try { BassUtils.OK(this.StopWASAPI(false)); @@ -335,7 +335,7 @@ protected override void OnDisposing() { foreach (var channelHandle in this.MixerChannelHandles) { - //Logger.Write(this, LogLevel.Debug, "Freeing BASS stream: {0}", channelHandle); + Logger.Write(this, LogLevel.Debug, "Freeing BASS stream: {0}", channelHandle); Bass.StreamFree(channelHandle); //Not checking result code as it contains an error if the application is shutting down. } this.Stop(); diff --git a/FoxTunes.Output.Bass.Wasapi/BassWasapiStreamOutputBehaviour.cs b/FoxTunes.Output.Bass.Wasapi/BassWasapiStreamOutputBehaviour.cs index 85a5ada18..2e1b93008 100644 --- a/FoxTunes.Output.Bass.Wasapi/BassWasapiStreamOutputBehaviour.cs +++ b/FoxTunes.Output.Bass.Wasapi/BassWasapiStreamOutputBehaviour.cs @@ -47,7 +47,7 @@ public bool Enabled set { this._Enabled = value; - //Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); + Logger.Write(this, LogLevel.Debug, "Enabled = {0}", this.Enabled); this.OutputDeviceManager.Restart(); } } @@ -63,7 +63,7 @@ public int WasapiDevice set { this._WasapiDevice = value; - //Logger.Write(this, LogLevel.Debug, "WASAPI Device = {0}", this.WasapiDevice); + Logger.Write(this, LogLevel.Debug, "WASAPI Device = {0}", this.WasapiDevice); this.OutputDeviceManager.Restart(); } } @@ -79,7 +79,7 @@ public bool Exclusive private set { this._Exclusive = value; - //Logger.Write(this, LogLevel.Debug, "Exclusive = {0}", this.Exclusive); + Logger.Write(this, LogLevel.Debug, "Exclusive = {0}", this.Exclusive); this.OutputDeviceManager.Restart(); } } @@ -103,7 +103,7 @@ public bool DoubleBuffer private set { this._DoubleBuffer = value; - //Logger.Write(this, LogLevel.Debug, "DoubleBuffer = {0}", this.DoubleBuffer); + Logger.Write(this, LogLevel.Debug, "DoubleBuffer = {0}", this.DoubleBuffer); this.OutputDeviceManager.Restart(); } } @@ -119,7 +119,7 @@ public bool EventDriven private set { this._EventDriven = value; - //Logger.Write(this, LogLevel.Debug, "EventDriven = {0}", this.EventDriven); + Logger.Write(this, LogLevel.Debug, "EventDriven = {0}", this.EventDriven); this.OutputDeviceManager.Restart(); } } @@ -135,7 +135,7 @@ public bool Async private set { this._Async = value; - //Logger.Write(this, LogLevel.Debug, "Async = {0}", this.Async); + Logger.Write(this, LogLevel.Debug, "Async = {0}", this.Async); this.OutputDeviceManager.Restart(); } } @@ -151,7 +151,7 @@ public bool Dither private set { this._Dither = value; - //Logger.Write(this, LogLevel.Debug, "Dither = {0}", this.Dither); + Logger.Write(this, LogLevel.Debug, "Dither = {0}", this.Dither); this.OutputDeviceManager.Restart(); } } @@ -167,7 +167,7 @@ public bool Mixer private set { this._Mixer = value; - //Logger.Write(this, LogLevel.Debug, "Mixer = {0}", this.Mixer); + Logger.Write(this, LogLevel.Debug, "Mixer = {0}", this.Mixer); this.OutputDeviceManager.Restart(); } } @@ -183,7 +183,7 @@ public float BufferLength private set { this._BufferLength = value; - //Logger.Write(this, LogLevel.Debug, "BufferLength = {0}", this.BufferLength); + Logger.Write(this, LogLevel.Debug, "BufferLength = {0}", this.BufferLength); this.OutputDeviceManager.Restart(); } } @@ -199,7 +199,7 @@ public bool Raw private set { this._Raw = value; - //Logger.Write(this, LogLevel.Debug, "Raw = {0}", this.Raw); + Logger.Write(this, LogLevel.Debug, "Raw = {0}", this.Raw); this.OutputDeviceManager.Restart(); } } @@ -276,7 +276,7 @@ protected virtual void OnInit(object sender, EventArgs e) { BassWasapiDevice.Detect(this.WasapiDevice, this.Exclusive, this.AutoFormat, this.BufferLength, this.DoubleBuffer, this.EventDriven, this.Async, this.Dither, this.Raw); } - //Logger.Write(this, LogLevel.Debug, "BASS (No Sound) Initialized."); + Logger.Write(this, LogLevel.Debug, "BASS (No Sound) Initialized."); } protected virtual void OnFree(object sender, EventArgs e) @@ -286,7 +286,7 @@ protected virtual void OnFree(object sender, EventArgs e) return; } this.OnFreeDevice(); - //Logger.Write(this, LogLevel.Debug, "Releasing BASS."); + LogManager.Logger.Write(this, LogLevel.Debug, "Releasing BASS."); Bass.Free(); this.IsInitialized = false; } @@ -360,7 +360,7 @@ protected virtual void OnDisposing() ~BassWasapiStreamOutputBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass.Wasapi/BassWasapiStreamOutputConfiguration.cs b/FoxTunes.Output.Bass.Wasapi/BassWasapiStreamOutputConfiguration.cs index ea6584123..7d957f16d 100644 --- a/FoxTunes.Output.Bass.Wasapi/BassWasapiStreamOutputConfiguration.cs +++ b/FoxTunes.Output.Bass.Wasapi/BassWasapiStreamOutputConfiguration.cs @@ -106,7 +106,7 @@ public static IEnumerable GetWASAPIDevices() { continue; } - //Logger.Write(typeof(BassWasapiStreamOutputConfiguration), LogLevel.Debug, "WASAPI Device: {0} => {1} => {2} => {3} => {4}", a, deviceInfo.ID, deviceInfo.Name, Enum.GetName(typeof(WasapiDeviceType), deviceInfo.Type), deviceInfo.MixFrequency); + LogManager.Logger.Write(typeof(BassWasapiStreamOutputConfiguration), LogLevel.Debug, "WASAPI Device: {0} => {1} => {2} => {3} => {4}", a, deviceInfo.ID, deviceInfo.Name, Enum.GetName(typeof(WasapiDeviceType), deviceInfo.Type), deviceInfo.MixFrequency); yield return new SelectionConfigurationOption(deviceInfo.ID, deviceInfo.Name, string.Format("{0} ({1})", deviceInfo.Name, Enum.GetName(typeof(WasapiDeviceType), deviceInfo.Type))); } } diff --git a/FoxTunes.Output.Bass/BassDeviceMonitorBehaviour.cs b/FoxTunes.Output.Bass/BassDeviceMonitorBehaviour.cs index b9b1340a0..6fe078cff 100644 --- a/FoxTunes.Output.Bass/BassDeviceMonitorBehaviour.cs +++ b/FoxTunes.Output.Bass/BassDeviceMonitorBehaviour.cs @@ -79,7 +79,7 @@ protected virtual void OnInit(object sender, EventArgs e) this.NotificationClient.DefaultDeviceChanged += this.OnDefaultDeviceChanged; this.NotificationClient.PropertyValueChanged += this.OnPropertyValueChanged; this.IsInitialized = true; - //Logger.Write(this, LogLevel.Debug, "BASS Device Monitor Initialized."); + Logger.Write(this, LogLevel.Debug, "BASS Device Monitor Initialized."); } protected virtual void OnFree(object sender, EventArgs e) @@ -122,8 +122,8 @@ protected virtual void OnDefaultDeviceChanged(object sender, NotificationClientE { return; } - //Logger.Write(this, LogLevel.Debug, "The default playback device was changed: {0} => {1} => {2}", e.Flow.Value, e.Role.Value, e.Device); - //Logger.Write(this, LogLevel.Debug, "Restarting the output."); + Logger.Write(this, LogLevel.Debug, "The default playback device was changed: {0} => {1} => {2}", e.Flow.Value, e.Role.Value, e.Device); + Logger.Write(this, LogLevel.Debug, "Restarting the output."); this.OutputDeviceManager.Restart(); } @@ -179,7 +179,7 @@ protected virtual void OnDisposing() ~BassDeviceMonitorBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); this.Dispose(true); } } diff --git a/FoxTunes.Output.Bass/BassLoader.cs b/FoxTunes.Output.Bass/BassLoader.cs index 7c5b1bbd4..d5fa9c786 100644 --- a/FoxTunes.Output.Bass/BassLoader.cs +++ b/FoxTunes.Output.Bass/BassLoader.cs @@ -163,7 +163,7 @@ public void Load() } catch { - //Logger.Write(this, LogLevel.Warn, "Failed to load plugin \"{0}\": {1}", path, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to load plugin \"{0}\": {1}", path, e.Message); } failures.Add(path); } @@ -180,7 +180,7 @@ public void Load() } catch { - //Logger.Write(this, LogLevel.Warn, "Failed to load plugin \"{0}\": {1}", fileName, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to load plugin \"{0}\": {1}", fileName, e.Message); } failures.Add(fileName); } @@ -189,16 +189,16 @@ public void Load() //We don't have anything to handle plugin inter-dependency, hopefully the second attempt will work. if (failures.Any()) { - //Logger.Write(this, LogLevel.Warn, "At least one plugin failed to load, retrying.."); + Logger.Write(this, LogLevel.Warn, "At least one plugin failed to load, retrying.."); foreach (var fileName in failures) { try { this.Load(fileName); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to load plugin \"{0}\": {1}", fileName, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to load plugin \"{0}\": {1}", fileName, e.Message); } } } @@ -210,11 +210,11 @@ public bool Load(string fileName) var handle = Bass.PluginLoad(fileName); if (handle == 0) { - //Logger.Write(this, LogLevel.Warn, "Failed to load plugin: {0}", fileName); + Logger.Write(this, LogLevel.Warn, "Failed to load plugin: {0}", fileName); return false; } var info = Bass.PluginGetInfo(handle); - //Logger.Write(this, LogLevel.Debug, "Plugin loaded \"{0}\": {1}", fileName, info.Version); + Logger.Write(this, LogLevel.Debug, "Plugin loaded \"{0}\": {1}", fileName, info.Version); this.Plugins.Add(new BassPlugin( fileName, info, @@ -261,7 +261,7 @@ protected virtual void OnDisposing() ~BassLoader() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass/BassOutput.cs b/FoxTunes.Output.Bass/BassOutput.cs index 35c167729..5a592bd4d 100644 --- a/FoxTunes.Output.Bass/BassOutput.cs +++ b/FoxTunes.Output.Bass/BassOutput.cs @@ -89,7 +89,7 @@ public int Rate set { this._Rate = value; - //Logger.Write(this, LogLevel.Debug, "Rate = {0}", this.Rate); + Logger.Write(this, LogLevel.Debug, "Rate = {0}", this.Rate); var task = this.Shutdown(); } } @@ -105,7 +105,7 @@ public bool EnforceRate set { this._EnforceRate = value; - //Logger.Write(this, LogLevel.Debug, "Enforce Rate = {0}", this.EnforceRate); + Logger.Write(this, LogLevel.Debug, "Enforce Rate = {0}", this.EnforceRate); var task = this.Shutdown(); } } @@ -121,7 +121,7 @@ public bool Float set { this._Float = value; - //Logger.Write(this, LogLevel.Debug, "Float = {0}", this.Float); + Logger.Write(this, LogLevel.Debug, "Float = {0}", this.Float); var task = this.Shutdown(); } } @@ -137,7 +137,7 @@ public int UpdatePeriod set { this._UpdatePeriod = value; - //Logger.Write(this, LogLevel.Debug, "UpdatePeriod = {0}", this.UpdatePeriod); + Logger.Write(this, LogLevel.Debug, "UpdatePeriod = {0}", this.UpdatePeriod); var task = this.Shutdown(); } } @@ -153,7 +153,7 @@ public int UpdateThreads set { this._UpdateThreads = value; - //Logger.Write(this, LogLevel.Debug, "UpdateThreads = {0}", this.UpdateThreads); + Logger.Write(this, LogLevel.Debug, "UpdateThreads = {0}", this.UpdateThreads); var task = this.Shutdown(); } } @@ -169,7 +169,7 @@ public int BufferLength set { this._BufferLength = value; - //Logger.Write(this, LogLevel.Debug, "BufferLength = {0}", this.BufferLength); + Logger.Write(this, LogLevel.Debug, "BufferLength = {0}", this.BufferLength); var task = this.Shutdown(); } } @@ -185,7 +185,7 @@ public int MixerBufferLength set { this._MixerBufferLength = value; - //Logger.Write(this, LogLevel.Debug, "MixerBufferLength = {0}", this.MixerBufferLength); + Logger.Write(this, LogLevel.Debug, "MixerBufferLength = {0}", this.MixerBufferLength); var task = this.Shutdown(); } } @@ -201,7 +201,7 @@ public int ResamplingQuality set { this._ResamplingQuality = value; - //Logger.Write(this, LogLevel.Debug, "ResamplingQuality = {0}", this.ResamplingQuality); + Logger.Write(this, LogLevel.Debug, "ResamplingQuality = {0}", this.ResamplingQuality); var task = this.Shutdown(); } } @@ -247,7 +247,7 @@ protected virtual async Task OnStart(bool force) var exception = default(Exception); for (var a = 1; a <= START_ATTEMPTS; a++) { - //Logger.Write(this, LogLevel.Debug, "Starting BASS, attempt: {0}", a); + Logger.Write(this, LogLevel.Debug, "Starting BASS, attempt: {0}", a); try { this.OnInit(); @@ -257,14 +257,14 @@ protected virtual async Task OnStart(bool force) catch (Exception e) { exception = e; - //Logger.Write(this, LogLevel.Warn, "Failed to start BASS: {0}", e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to start BASS: {0}", e.Message); } await this.ShutdownCore(true).ConfigureAwait(false); Thread.Sleep(START_ATTEMPT_INTERVAL); } if (this.IsStarted) { - //Logger.Write(this, LogLevel.Debug, "Started BASS."); + Logger.Write(this, LogLevel.Debug, "Started BASS."); return; } else if (exception != null) @@ -299,16 +299,16 @@ protected virtual async Task ShutdownCore(bool force) if (force || this.IsStarted) { var exception = default(Exception); - //Logger.Write(this, LogLevel.Debug, "Stopping BASS."); + Logger.Write(this, LogLevel.Debug, "Stopping BASS."); try { await this.PipelineManager.FreePipeline().ConfigureAwait(false); this.OnFree(); - //Logger.Write(this, LogLevel.Debug, "Stopped BASS."); + Logger.Write(this, LogLevel.Debug, "Stopped BASS."); } catch (Exception e) { - //Logger.Write(this, LogLevel.Error, "Failed to stop BASS: {0}", e.Message); + Logger.Write(this, LogLevel.Error, "Failed to stop BASS: {0}", e.Message); exception = e; } await this.SetIsStarted(false).ConfigureAwait(false); @@ -409,7 +409,7 @@ public override async Task Load(PlaylistItem playlistItem, bool i { await this.Start().ConfigureAwait(false); } - //Logger.Write(this, LogLevel.Debug, "Loading stream: {0} => {1}", playlistItem.Id, playlistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Loading stream: {0} => {1}", playlistItem.Id, playlistItem.FileName); var flags = BassFlags.Default; if (this.Float) { @@ -418,7 +418,7 @@ public override async Task Load(PlaylistItem playlistItem, bool i var stream = this.StreamFactory.CreateInteractiveStream(playlistItem, immidiate, flags); if (stream.IsEmpty) { - //Logger.Write(this, LogLevel.Debug, "Failed to load stream: {0} => {1} => {2}", playlistItem.Id, playlistItem.FileName, Enum.GetName(typeof(Errors), stream.Errors)); + Logger.Write(this, LogLevel.Debug, "Failed to load stream: {0} => {1} => {2}", playlistItem.Id, playlistItem.FileName, Enum.GetName(typeof(Errors), stream.Errors)); return null; } var outputStream = new BassOutputStream(this, this.PipelineManager, stream, playlistItem); @@ -432,10 +432,10 @@ public override IOutputStream Duplicate(IOutputStream stream) var outputStream = stream as BassOutputStream; if (outputStream.Provider.Flags.HasFlag(BassStreamProviderFlags.Serial)) { - //Logger.Write(this, LogLevel.Warn, "Cannot duplicate stream for file \"{0}\" with serial provider.", stream.FileName); + Logger.Write(this, LogLevel.Warn, "Cannot duplicate stream for file \"{0}\" with serial provider.", stream.FileName); return null; } - //Logger.Write(this, LogLevel.Debug, "Duplicating stream for file \"{0}\".", stream.FileName); + Logger.Write(this, LogLevel.Debug, "Duplicating stream for file \"{0}\".", stream.FileName); var flags = BassFlags.Default; if (stream.Format == OutputStreamFormat.Float) { @@ -444,7 +444,7 @@ public override IOutputStream Duplicate(IOutputStream stream) var result = this.StreamFactory.CreateBasicStream(stream.PlaylistItem, flags); if (result.IsEmpty) { - //Logger.Write(this, LogLevel.Warn, "Failed to duplicate stream for file \"{0}\".", stream.FileName); + Logger.Write(this, LogLevel.Warn, "Failed to duplicate stream for file \"{0}\".", stream.FileName); return null; } outputStream = new BassOutputStream(this, this.PipelineManager, result, stream.PlaylistItem); @@ -465,7 +465,7 @@ public override Task Preempt(IOutputStream stream) { if (pipeline.Input.Add(outputStream, this.OnStreamAdded)) { - //Logger.Write(this, LogLevel.Debug, "Pre-empted playback of stream from file {0}: {1}", outputStream.FileName, outputStream.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Pre-empted playback of stream from file {0}: {1}", outputStream.FileName, outputStream.ChannelHandle); return true; } else @@ -475,7 +475,7 @@ public override Task Preempt(IOutputStream stream) } else { - //Logger.Write(this, LogLevel.Debug, "Properties differ from current configuration, cannot pre-empt playback of stream from file {0}: {1}", outputStream.FileName, outputStream.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Properties differ from current configuration, cannot pre-empt playback of stream from file {0}: {1}", outputStream.FileName, outputStream.ChannelHandle); } } return false; @@ -483,7 +483,7 @@ public override Task Preempt(IOutputStream stream) } else { - //Logger.Write(this, LogLevel.Debug, "Not yet started, cannot pre-empt playback of stream from file {0}: {1}", outputStream.FileName, outputStream.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Not yet started, cannot pre-empt playback of stream from file {0}: {1}", outputStream.FileName, outputStream.ChannelHandle); } #if NET40 return TaskEx.FromResult(false); @@ -502,7 +502,7 @@ public override async Task Unload(IOutputStream stream) var outputStream = stream as BassOutputStream; if (this.IsStarted) { - //Logger.Write(this, LogLevel.Debug, "Unloading stream for file {0}: {1}", outputStream.FileName, outputStream.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Unloading stream for file {0}: {1}", outputStream.FileName, outputStream.ChannelHandle); await this.PipelineManager.WithPipelineExclusive(pipeline => { if (pipeline != null) @@ -512,7 +512,7 @@ await this.PipelineManager.WithPipelineExclusive(pipeline => { if (!pipeline.Input.PreserveBuffer) { - //Logger.Write(this, LogLevel.Debug, "Track was manually skipped, clearing the playback buffer."); + Logger.Write(this, LogLevel.Debug, "Track was manually skipped, clearing the playback buffer."); pipeline.Pause(); pipeline.ClearBuffer(); resume = true; @@ -546,7 +546,7 @@ protected virtual void Unload(BassOutputStream outputStream) { this.OnUnloaded(outputStream); outputStream.Dispose(); - //Logger.Write(this, LogLevel.Debug, "Unloaded stream for file {0}: {1}", outputStream.FileName, outputStream.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Unloaded stream for file {0}: {1}", outputStream.FileName, outputStream.ChannelHandle); } public IEnumerable GetConfigurationSections() @@ -587,7 +587,7 @@ protected virtual void OnDisposing() ~BassOutput() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass/BassOutputDataSource.cs b/FoxTunes.Output.Bass/BassOutputDataSource.cs index ff6f248f0..88674b1ab 100644 --- a/FoxTunes.Output.Bass/BassOutputDataSource.cs +++ b/FoxTunes.Output.Bass/BassOutputDataSource.cs @@ -230,7 +230,7 @@ public float[] GetBuffer(int fftSize, bool individual = false) var format = default(OutputStreamFormat); if (!this.GetDataFormat(out rate, out channels, out format)) { - //Logger.Write(this, LogLevel.Error, "Failed to determine channel count while creating interleaved FFT buffer."); + Logger.Write(this, LogLevel.Error, "Failed to determine channel count while creating interleaved FFT buffer."); return null; } length *= channels; @@ -288,7 +288,7 @@ protected virtual void OnDisposing() ~BassOutputDataSource() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass/BassOutputStream.cs b/FoxTunes.Output.Bass/BassOutputStream.cs index 1e26c8c98..17fde95a5 100644 --- a/FoxTunes.Output.Bass/BassOutputStream.cs +++ b/FoxTunes.Output.Bass/BassOutputStream.cs @@ -287,7 +287,7 @@ public override Task Seek(long position) //We should follow this with a second call to BASS_ChannelSetPosition with the BASS_POS_DECODETO flag set. position = this.Length - 1; } - //Logger.Write(this, LogLevel.Debug, "Seeking to position {0}", position); + Logger.Write(this, LogLevel.Debug, "Seeking to position {0}", position); if (this.IsPlaying) { if (bufferLength > 0) diff --git a/FoxTunes.Output.Bass/BassOutputVolume.cs b/FoxTunes.Output.Bass/BassOutputVolume.cs index caa25c259..dee55798f 100644 --- a/FoxTunes.Output.Bass/BassOutputVolume.cs +++ b/FoxTunes.Output.Bass/BassOutputVolume.cs @@ -115,7 +115,7 @@ protected virtual void OnDisposing() ~BassOutputVolume() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass/BassStreamComponent.cs b/FoxTunes.Output.Bass/BassStreamComponent.cs index 0ebfbb839..46429530f 100644 --- a/FoxTunes.Output.Bass/BassStreamComponent.cs +++ b/FoxTunes.Output.Bass/BassStreamComponent.cs @@ -97,7 +97,7 @@ protected virtual void Dispose(bool disposing) ~BassStreamComponent() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass/BassStreamFactory.cs b/FoxTunes.Output.Bass/BassStreamFactory.cs index 58e52aa62..4b182855b 100644 --- a/FoxTunes.Output.Bass/BassStreamFactory.cs +++ b/FoxTunes.Output.Bass/BassStreamFactory.cs @@ -48,62 +48,62 @@ public IEnumerable GetProviders(PlaylistItem playlistItem) public IBassStream CreateBasicStream(PlaylistItem playlistItem, BassFlags flags) { flags |= BassFlags.Decode; - //Logger.Write(this, LogLevel.Debug, "Attempting to create stream for file \"{0}\".", playlistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Attempting to create stream for file \"{0}\".", playlistItem.FileName); var providers = this.GetProviders(playlistItem); if (!providers.Any()) { - //Logger.Write(this, LogLevel.Warn, "No provider was found for file \"{0}\".", playlistItem.FileName); + Logger.Write(this, LogLevel.Warn, "No provider was found for file \"{0}\".", playlistItem.FileName); return BassStream.Empty; } foreach (var provider in providers) { - //Logger.Write(this, LogLevel.Debug, "Using bass stream provider \"{0}\".", provider.GetType().Name); + Logger.Write(this, LogLevel.Debug, "Using bass stream provider \"{0}\".", provider.GetType().Name); var advice = this.GetAdvice(provider, playlistItem, BassStreamUsageType.Basic).ToArray(); var stream = provider.CreateBasicStream(playlistItem, advice, flags); if (stream.ChannelHandle != 0) { - //Logger.Write(this, LogLevel.Debug, "Created stream from file {0}: {1}", playlistItem.FileName, stream.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Created stream from file {0}: {1}", playlistItem.FileName, stream.ChannelHandle); return stream; } if (stream.Errors == Errors.Already && provider.Flags.HasFlag(BassStreamProviderFlags.Serial)) { - //Logger.Write(this, LogLevel.Debug, "Provider does not support multiple streams."); + Logger.Write(this, LogLevel.Debug, "Provider does not support multiple streams."); return stream; } - //Logger.Write(this, LogLevel.Debug, "Failed to create stream from file {0}: {1}", playlistItem.FileName, Enum.GetName(typeof(Errors), stream.Errors)); + Logger.Write(this, LogLevel.Debug, "Failed to create stream from file {0}: {1}", playlistItem.FileName, Enum.GetName(typeof(Errors), stream.Errors)); } - //Logger.Write(this, LogLevel.Warn, "All providers failed for file \"{0}\".", playlistItem.FileName); + Logger.Write(this, LogLevel.Warn, "All providers failed for file \"{0}\".", playlistItem.FileName); return BassStream.Empty; } public IBassStream CreateInteractiveStream(PlaylistItem playlistItem, bool immidiate, BassFlags flags) { flags |= BassFlags.Decode; - //Logger.Write(this, LogLevel.Debug, "Attempting to create stream for file \"{0}\".", playlistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Attempting to create stream for file \"{0}\".", playlistItem.FileName); var providers = this.GetProviders(playlistItem); if (!providers.Any()) { - //Logger.Write(this, LogLevel.Warn, "No provider was found for file \"{0}\".", playlistItem.FileName); + Logger.Write(this, LogLevel.Warn, "No provider was found for file \"{0}\".", playlistItem.FileName); return BassStream.Empty; } foreach (var provider in providers) { - //Logger.Write(this, LogLevel.Debug, "Using bass stream provider \"{0}\".", provider.GetType().Name); + Logger.Write(this, LogLevel.Debug, "Using bass stream provider \"{0}\".", provider.GetType().Name); var advice = this.GetAdvice(provider, playlistItem, BassStreamUsageType.Interactive).ToArray(); var stream = provider.CreateInteractiveStream(playlistItem, advice, immidiate, flags); if (!stream.IsEmpty) { - //Logger.Write(this, LogLevel.Debug, "Created stream from file {0}: {1}", playlistItem.FileName, stream.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Created stream from file {0}: {1}", playlistItem.FileName, stream.ChannelHandle); return stream; } else if (stream.IsPending) { - //Logger.Write(this, LogLevel.Debug, "Failed to create stream from file {0}: It is not currently available.", playlistItem.FileName); + Logger.Write(this, LogLevel.Debug, "Failed to create stream from file {0}: It is not currently available.", playlistItem.FileName); return stream; } - //Logger.Write(this, LogLevel.Debug, "Failed to create stream from file {0}: {1}", playlistItem.FileName, Enum.GetName(typeof(Errors), stream.Errors)); + Logger.Write(this, LogLevel.Debug, "Failed to create stream from file {0}: {1}", playlistItem.FileName, Enum.GetName(typeof(Errors), stream.Errors)); } - //Logger.Write(this, LogLevel.Warn, "All providers failed for file \"{0}\".", playlistItem.FileName); + Logger.Write(this, LogLevel.Warn, "All providers failed for file \"{0}\".", playlistItem.FileName); return BassStream.Empty; } diff --git a/FoxTunes.Output.Bass/BassStreamInput.cs b/FoxTunes.Output.Bass/BassStreamInput.cs index 621ae5708..4f04f83b5 100644 --- a/FoxTunes.Output.Bass/BassStreamInput.cs +++ b/FoxTunes.Output.Bass/BassStreamInput.cs @@ -50,12 +50,12 @@ public bool CheckFormat(BassOutputStream stream) var providerType = stream.Provider.GetType(); if (!stream.Provider.SupportedInputs.Any(type => type.IsAssignableFrom(inputType))) { - //Logger.Write(this, LogLevel.Debug, "Provider \"{0}\" does not support input \"{1}\".", providerType.Name, inputType.Name); + Logger.Write(this, LogLevel.Debug, "Provider \"{0}\" does not support input \"{1}\".", providerType.Name, inputType.Name); return false; } if (!this.SupportedProviders.Any(type => type.IsAssignableFrom(providerType))) { - //Logger.Write(this, LogLevel.Debug, "Input \"{0}\" does not support provider \"{1}\".", inputType.Name, providerType.Name); + Logger.Write(this, LogLevel.Debug, "Input \"{0}\" does not support provider \"{1}\".", inputType.Name, providerType.Name); return false; } return this.OnCheckFormat(stream); diff --git a/FoxTunes.Output.Bass/BassStreamPipeline.cs b/FoxTunes.Output.Bass/BassStreamPipeline.cs index 0315f159f..1eeb0301e 100644 --- a/FoxTunes.Output.Bass/BassStreamPipeline.cs +++ b/FoxTunes.Output.Bass/BassStreamPipeline.cs @@ -81,21 +81,21 @@ public void InitializeComponent(IBassStreamInput input, IEnumerable component.ClearBuffer()); } @@ -163,9 +163,9 @@ protected virtual void Dispose(bool disposing) { component.Dispose(); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Error, "Pipeline component \"{0}\" could not be disposed: {1}", component.GetType().Name, e.Message); + Logger.Write(this, LogLevel.Error, "Pipeline component \"{0}\" could not be disposed: {1}", component.GetType().Name, e.Message); } }); this.IsDisposed = true; @@ -173,7 +173,7 @@ protected virtual void Dispose(bool disposing) ~BassStreamPipeline() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass/BassStreamPipelineFactory.cs b/FoxTunes.Output.Bass/BassStreamPipelineFactory.cs index 3df6bff1d..16689874d 100644 --- a/FoxTunes.Output.Bass/BassStreamPipelineFactory.cs +++ b/FoxTunes.Output.Bass/BassStreamPipelineFactory.cs @@ -44,16 +44,19 @@ public IBassStreamPipeline CreatePipeline(BassOutputStream stream) try { pipeline.Connect(stream); - //Logger.Write( - // this, - // LogLevel.Debug, - // "Connected pipeline: {0}", - // string.Join(" => ", pipeline.All.Select(component => string.Format("\"{0}\"", component.GetType().Name))) - //); + if (Logger.IsDebugEnabled(this)) + { + Logger.Write( + this, + LogLevel.Debug, + "Connected pipeline: {0}", + string.Join(" => ", pipeline.All.Select(component => string.Format("\"{0}\"", component.GetType().Name))) + ); + } } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Error, "Failed to create pipeline: {0}", e.Message); + Logger.Write(this, LogLevel.Error, "Failed to create pipeline: {0}", e.Message); pipeline.Dispose(); throw; } diff --git a/FoxTunes.Output.Bass/BassStreamPipelineManager.cs b/FoxTunes.Output.Bass/BassStreamPipelineManager.cs index 326a729c6..dd98e6908 100644 --- a/FoxTunes.Output.Bass/BassStreamPipelineManager.cs +++ b/FoxTunes.Output.Bass/BassStreamPipelineManager.cs @@ -163,7 +163,7 @@ protected virtual async Task WithPipeline(BassOutputStream stream, Action ad { if (stream.ChannelHandle != channelHandle) { - //Logger.Write(this, LogLevel.Debug, "Stream was wrapped by advice \"{0}\": {1} => {1}", advisory.GetType().Name, channelHandle, stream.ChannelHandle); + Logger.Write(this, LogLevel.Debug, "Stream was wrapped by advice \"{0}\": {1} => {1}", advisory.GetType().Name, channelHandle, stream.ChannelHandle); channelHandle = stream.ChannelHandle; } } @@ -144,7 +144,7 @@ public virtual void SetPosition(int channelHandle, long value) public virtual void FreeStream(int channelHandle) { - //Logger.Write(this, LogLevel.Debug, "Freeing stream: {0}", channelHandle); + Logger.Write(this, LogLevel.Debug, "Freeing stream: {0}", channelHandle); Bass.StreamFree(channelHandle); //Not checking result code as it contains an error if the application is shutting down. } @@ -173,7 +173,7 @@ protected virtual void OnDisposing() ~BassStreamProvider() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output.Bass/BassTool.cs b/FoxTunes.Output.Bass/BassTool.cs index 61bf3bcf7..d6886bde8 100644 --- a/FoxTunes.Output.Bass/BassTool.cs +++ b/FoxTunes.Output.Bass/BassTool.cs @@ -28,7 +28,7 @@ public Process Process public override void InitializeComponent(ICore core) { - //Logger.Write(this, LogLevel.Debug, "Initializing BASS (NoSound)."); + Logger.Write(this, LogLevel.Debug, "Initializing BASS (NoSound)."); BassUtils.OK(Bass.Init(Bass.NoSoundDevice)); base.InitializeComponent(core); } @@ -44,7 +44,7 @@ public virtual void Cancel() { return; } - //Logger.Write(this, LogLevel.Warn, "Cancellation requested, shutting down."); + Logger.Write(this, LogLevel.Warn, "Cancellation requested, shutting down."); this.CancellationToken.Cancel(); } @@ -101,7 +101,7 @@ protected virtual IBassStream CreateStream(string fileName, BassFlags flags) ); if (stream.IsPending) { - //Logger.Write(this, LogLevel.Trace, "Failed to create decoder stream for file \"{0}\": Device is already in use.", fileName); + Logger.Write(this, LogLevel.Trace, "Failed to create decoder stream for file \"{0}\": Device is already in use.", fileName); Thread.Sleep(INTERVAL); goto retry; } @@ -176,13 +176,13 @@ protected virtual void Dispose(bool disposing) protected virtual void OnDisposing() { - //Logger.Write(this, LogLevel.Debug, "Releasing BASS (NoSound)."); + Logger.Write(this, LogLevel.Debug, "Releasing BASS (NoSound)."); Bass.Free(); } ~BassTool() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output/NotificationClient.cs b/FoxTunes.Output/NotificationClient.cs index ee6f69699..876ae358f 100644 --- a/FoxTunes.Output/NotificationClient.cs +++ b/FoxTunes.Output/NotificationClient.cs @@ -6,7 +6,15 @@ namespace FoxTunes { public class NotificationClient : IMMNotificationClient, IDisposable { - public NotificationClient() + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public NotificationClient() { Enumerator.RegisterEndpointNotificationCallback(this); } @@ -129,7 +137,7 @@ protected virtual void OnDisposing() ~NotificationClient() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output/OutputDeviceSelector.cs b/FoxTunes.Output/OutputDeviceSelector.cs index 91615df18..b7475666a 100644 --- a/FoxTunes.Output/OutputDeviceSelector.cs +++ b/FoxTunes.Output/OutputDeviceSelector.cs @@ -77,7 +77,7 @@ protected virtual void OnDisposing() ~OutputDeviceSelector() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Output/OutputStreamQueue.cs b/FoxTunes.Output/OutputStreamQueue.cs index 522d762df..95c5b9b4b 100644 --- a/FoxTunes.Output/OutputStreamQueue.cs +++ b/FoxTunes.Output/OutputStreamQueue.cs @@ -30,7 +30,7 @@ public override void InitializeComponent(ICore core) { if (this.Queue.Count > 0) { - //Logger.Write(this, LogLevel.Warn, "Output state changed, disposing queued output streams."); + Logger.Write(this, LogLevel.Warn, "Output state changed, disposing queued output streams."); this.Clear(); } }; @@ -117,7 +117,7 @@ orderby pair.Value.CreatedAt descending { return; } - //Logger.Write(this, LogLevel.Debug, "Evicting output stream from the queue due to exceeded capacity: {0} => {1}", key.Id, key.FileName); + Logger.Write(this, LogLevel.Debug, "Evicting output stream from the queue due to exceeded capacity: {0} => {1}", key.Id, key.FileName); var value = default(OutputStreamQueueValue); if (!this.Queue.TryRemove(key, out value)) { @@ -165,10 +165,10 @@ public void Clear() foreach (var pair in this.Queue) { var outputStream = pair.Value.OutputStream; - //Logger.Write(this, LogLevel.Debug, "Disposing queued output stream: {0} => {1}", outputStream.Id, outputStream.FileName); + Logger.Write(this, LogLevel.Debug, "Disposing queued output stream: {0} => {1}", outputStream.Id, outputStream.FileName); outputStream.Dispose(); } - //Logger.Write(this, LogLevel.Debug, "Clearing output stream queue."); + Logger.Write(this, LogLevel.Debug, "Clearing output stream queue."); this.Queue.Clear(); } } @@ -198,7 +198,7 @@ protected virtual void OnDisposing() ~OutputStreamQueue() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Scripting.JS.ClearScript/JSScriptingRuntime.cs b/FoxTunes.Scripting.JS.ClearScript/JSScriptingRuntime.cs index 1483e806f..ca03d9348 100644 --- a/FoxTunes.Scripting.JS.ClearScript/JSScriptingRuntime.cs +++ b/FoxTunes.Scripting.JS.ClearScript/JSScriptingRuntime.cs @@ -43,7 +43,7 @@ public override void InitializeComponent(ICore core) public override IScriptingContext CreateContext() { - //Logger.Write(this, LogLevel.Debug, "Creating javascript scripting context."); + Logger.Write(this, LogLevel.Debug, "Creating javascript scripting context."); var context = new JSScriptingContext(new V8ScriptEngine()); context.InitializeComponent(this.Core); return context; diff --git a/FoxTunes.Scripting/ScriptingContext.cs b/FoxTunes.Scripting/ScriptingContext.cs index f6abfac43..52c3d6b4a 100644 --- a/FoxTunes.Scripting/ScriptingContext.cs +++ b/FoxTunes.Scripting/ScriptingContext.cs @@ -36,7 +36,7 @@ protected virtual void OnDisposing() ~ScriptingContext() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.Statistics/Behaviours/PlaybackStatisticsBehaviour.cs b/FoxTunes.Statistics/Behaviours/PlaybackStatisticsBehaviour.cs index 9e5f47312..d03393586 100644 --- a/FoxTunes.Statistics/Behaviours/PlaybackStatisticsBehaviour.cs +++ b/FoxTunes.Statistics/Behaviours/PlaybackStatisticsBehaviour.cs @@ -146,9 +146,9 @@ protected virtual async Task IncrementPlayCount(PlaylistItem playlistItem) { await this.StatisticsManager.IncrementPlayCount(playlistItem).ConfigureAwait(false); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Error, "Failed to update play count for file \"{0}\": {1}", playlistItem.FileName, e.Message); + Logger.Write(this, LogLevel.Error, "Failed to update play count for file \"{0}\": {1}", playlistItem.FileName, e.Message); } } @@ -187,7 +187,7 @@ protected virtual void OnDisposing() ~PlaybackStatisticsBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows.Layout/Behaviours/LayoutDesignerBehaviour.cs b/FoxTunes.UI.Windows.Layout/Behaviours/LayoutDesignerBehaviour.cs index 377529616..93467f9f8 100644 --- a/FoxTunes.UI.Windows.Layout/Behaviours/LayoutDesignerBehaviour.cs +++ b/FoxTunes.UI.Windows.Layout/Behaviours/LayoutDesignerBehaviour.cs @@ -246,7 +246,7 @@ protected virtual void OnDisposing() ~LayoutDesignerBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows.Layout/Behaviours/LayoutPresetBehaviour.cs b/FoxTunes.UI.Windows.Layout/Behaviours/LayoutPresetBehaviour.cs index 43f692f10..984d3be70 100644 --- a/FoxTunes.UI.Windows.Layout/Behaviours/LayoutPresetBehaviour.cs +++ b/FoxTunes.UI.Windows.Layout/Behaviours/LayoutPresetBehaviour.cs @@ -180,7 +180,7 @@ protected virtual void OnDisposing() ~LayoutPresetBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows.Layout/Behaviours/ToolWindowBehaviour.cs b/FoxTunes.UI.Windows.Layout/Behaviours/ToolWindowBehaviour.cs index a0f43b365..5bad8ce71 100644 --- a/FoxTunes.UI.Windows.Layout/Behaviours/ToolWindowBehaviour.cs +++ b/FoxTunes.UI.Windows.Layout/Behaviours/ToolWindowBehaviour.cs @@ -72,10 +72,10 @@ protected virtual async Task Load() } if (string.IsNullOrEmpty(value)) { - //Logger.Write(this, LogLevel.Debug, "No config to load."); + Logger.Write(this, LogLevel.Debug, "No config to load."); return; } - //Logger.Write(this, LogLevel.Debug, "Loading config.."); + Logger.Write(this, LogLevel.Debug, "Loading config.."); try { using (var stream = new MemoryStream(Encoding.Default.GetBytes(value))) @@ -87,15 +87,15 @@ protected virtual async Task Load() } } } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to load config: {0}", e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to load config: {0}", e.Message); } } protected virtual async Task Load(ToolWindowConfiguration config) { - //Logger.Write(this, LogLevel.Debug, "Loading config: {0}", ToolWindowConfiguration.GetTitle(config)); + Logger.Write(this, LogLevel.Debug, "Loading config: {0}", ToolWindowConfiguration.GetTitle(config)); try { if (!ScreenHelper.WindowBoundsVisible(new Rect(config.Left, config.Top, config.Width, config.Height))) @@ -107,7 +107,7 @@ protected virtual async Task Load(ToolWindowConfiguration config) var window = default(ToolWindow); await global::FoxTunes.Windows.Invoke(() => { - //Logger.Write(this, LogLevel.Debug, "Creating window: {0}", ToolWindowConfiguration.GetTitle(config)); + Logger.Write(this, LogLevel.Debug, "Creating window: {0}", ToolWindowConfiguration.GetTitle(config)); window = new ToolWindow(); window.Configuration = config; window.ShowActivated = false; @@ -117,9 +117,9 @@ protected virtual async Task Load(ToolWindowConfiguration config) this.OnLoaded(config, window); return window; } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to load config: {0}", e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to load config: {0}", e.Message); return null; } } @@ -145,7 +145,7 @@ protected virtual async Task UpdateVisiblity() protected virtual Task UpdateVisiblity(ToolWindowConfiguration config, ToolWindow window) { - //Logger.Write(this, LogLevel.Debug, "Updating visiblity: {0}", ToolWindowConfiguration.GetTitle(config)); + Logger.Write(this, LogLevel.Debug, "Updating visiblity: {0}", ToolWindowConfiguration.GetTitle(config)); var show = false; var id = default(string); if (global::FoxTunes.Windows.ActiveWindow is WindowBase activeWindow) @@ -169,7 +169,7 @@ protected virtual Task UpdateVisiblity(ToolWindowConfiguration config, ToolWindo { action = () => { - //Logger.Write(this, LogLevel.Debug, "Showing window: {0}", ToolWindowConfiguration.GetTitle(config)); + Logger.Write(this, LogLevel.Debug, "Showing window: {0}", ToolWindowConfiguration.GetTitle(config)); window.Show(); }; } @@ -177,7 +177,7 @@ protected virtual Task UpdateVisiblity(ToolWindowConfiguration config, ToolWindo { action = () => { - //Logger.Write(this, LogLevel.Debug, "Hiding window: {0}", ToolWindowConfiguration.GetTitle(config)); + Logger.Write(this, LogLevel.Debug, "Hiding window: {0}", ToolWindowConfiguration.GetTitle(config)); window.Hide(); }; } @@ -193,7 +193,7 @@ protected virtual Task UpdateVisiblity(ToolWindowConfiguration config, ToolWindo protected virtual void Unload(ToolWindowConfiguration config, ToolWindow window) { - //Logger.Write(this, LogLevel.Debug, "Unloading config: {0}", ToolWindowConfiguration.GetTitle(config)); + Logger.Write(this, LogLevel.Debug, "Unloading config: {0}", ToolWindowConfiguration.GetTitle(config)); this.Windows.TryGetValue(config, out window); if (!this.Windows.TryRemove(config)) { @@ -241,7 +241,7 @@ protected virtual void Save() { return; } - //Logger.Write(this, LogLevel.Debug, "Saving config.."); + Logger.Write(this, LogLevel.Debug, "Saving config.."); try { var value = default(string); @@ -259,11 +259,11 @@ protected virtual void Save() { this.IsSaving = false; } - //Logger.Write(this, LogLevel.Debug, "Saved config for {0} windows.", this.Windows.Count); + Logger.Write(this, LogLevel.Debug, "Saved config for {0} windows.", this.Windows.Count); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to save config: {0}", e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to save config: {0}", e.Message); } } @@ -338,7 +338,7 @@ protected virtual void OnActiveWindowChanged(object sender, EventArgs e) protected virtual void OnShuttingDown(object sender, EventArgs e) { - //Logger.Write(this, LogLevel.Debug, "Shutdown signal recieved."); + Logger.Write(this, LogLevel.Debug, "Shutdown signal recieved."); if (!this.IsLoaded) { return; @@ -424,7 +424,7 @@ public Task InvokeAsync(IInvocationComponent component) public async Task New() { - //Logger.Write(this, LogLevel.Debug, "Creating new config.."); + Logger.Write(this, LogLevel.Debug, "Creating new config.."); var configs = this.Windows.Keys; var config = new ToolWindowConfiguration() { @@ -454,11 +454,11 @@ public Task Shutdown() this.IsLoaded = false; return global::FoxTunes.Windows.Invoke(() => { - //Logger.Write(this, LogLevel.Debug, "Shutting down.."); + Logger.Write(this, LogLevel.Debug, "Shutting down.."); global::FoxTunes.Windows.Registrations.Close(ToolWindowManagerWindow.ID); foreach (var pair in this.Windows) { - //Logger.Write(this, LogLevel.Debug, "Closing window: {0}", pair.Value.Title); + Logger.Write(this, LogLevel.Debug, "Closing window: {0}", pair.Value.Title); pair.Value.Closed -= this.OnClosed; pair.Value.Close(); } @@ -476,12 +476,12 @@ public async Task Refresh() public Task Reset() { - //Logger.Write(this, LogLevel.Debug, "Resetting configuration."); + Logger.Write(this, LogLevel.Debug, "Resetting configuration."); return global::FoxTunes.Windows.Invoke(() => { foreach (var pair in this.Windows) { - //Logger.Write(this, LogLevel.Debug, "Closing window: {0}", pair.Value.Title); + Logger.Write(this, LogLevel.Debug, "Closing window: {0}", pair.Value.Title); pair.Value.Closed -= this.OnClosed; pair.Value.Close(); } @@ -527,7 +527,7 @@ protected virtual void OnDisposing() ~ToolWindowBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows.Layout/UIComponentConfigurationProvider.cs b/FoxTunes.UI.Windows.Layout/UIComponentConfigurationProvider.cs index 14719b8cd..e5028bfd3 100644 --- a/FoxTunes.UI.Windows.Layout/UIComponentConfigurationProvider.cs +++ b/FoxTunes.UI.Windows.Layout/UIComponentConfigurationProvider.cs @@ -107,10 +107,10 @@ protected virtual void Load(string id, string value) var element = default(ConfigurationElement); if (!this.Elements.TryGetValue(id, out element)) { - //Logger.Write(this, LogLevel.Warn, "Configuration element \"{0}\" no longer exists.", id); + Logger.Write(this, LogLevel.Warn, "Configuration element \"{0}\" no longer exists.", id); return; } - //Logger.Write(this, LogLevel.Debug, "Loading configuration element: \"{0}\".", id); + Logger.Write(this, LogLevel.Debug, "Loading configuration element: \"{0}\".", id); element.SetPersistentValue(value); } @@ -220,7 +220,7 @@ public void Save() public void Save(string profile) { this.OnSaving(); - //Logger.Write(this, LogLevel.Debug, "Saving configuration."); + Logger.Write(this, LogLevel.Debug, "Saving configuration."); try { foreach (var element in this.Elements.Values) @@ -231,7 +231,7 @@ public void Save(string profile) var value = default(string); if (this.Component.MetaData.TryRemove(key, out value)) { - //Logger.Write(this, LogLevel.Debug, "Removing config: {0}", key); + Logger.Write(this, LogLevel.Debug, "Removing config: {0}", key); } } else @@ -240,14 +240,14 @@ public void Save(string profile) this.Component.MetaData.AddOrUpdate(key, (_key) => { - //Logger.Write(this, LogLevel.Debug, "Adding config: {0}", key); + Logger.Write(this, LogLevel.Debug, "Adding config: {0}", key); return value; }, (_key, _value) => { if (!string.Equals(value, _value, StringComparison.OrdinalIgnoreCase)) { - //Logger.Write(this, LogLevel.Debug, "Updating config: {0}", key); + Logger.Write(this, LogLevel.Debug, "Updating config: {0}", key); } return value; } @@ -255,9 +255,9 @@ public void Save(string profile) } } } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to save configuration: {0}", e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to save configuration: {0}", e.Message); } this.OnSaved(); } @@ -282,14 +282,14 @@ public bool Contains(string id) private void Add(ConfigurationSection section) { - //Logger.Write(this, LogLevel.Debug, "Adding configuration section: {0} => {1}", section.Id, section.Name); + Logger.Write(this, LogLevel.Debug, "Adding configuration section: {0} => {1}", section.Id, section.Name); section = new ConfigurationSectionWrapper(this, section); this.Sections.Add(section.Id, section); } private void Update(ConfigurationSection section) { - //Logger.Write(this, LogLevel.Debug, "Updating configuration section: {0} => {1}", section.Id, section.Name); + Logger.Write(this, LogLevel.Debug, "Updating configuration section: {0} => {1}", section.Id, section.Name); var existing = this.GetSection(section.Id); existing.Update(section); } @@ -324,7 +324,7 @@ protected virtual void OnDisposing() ~UIComponentConfigurationProvider() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows.Layout/UIComponentContainer.cs b/FoxTunes.UI.Windows.Layout/UIComponentContainer.cs index 074fbfcaa..3c408f39a 100644 --- a/FoxTunes.UI.Windows.Layout/UIComponentContainer.cs +++ b/FoxTunes.UI.Windows.Layout/UIComponentContainer.cs @@ -23,7 +23,15 @@ public class UIComponentContainer : DockPanel, IInvocableComponent, IUIComponent public static readonly UIComponentFactory Factory = ComponentRegistry.Instance.GetComponent(); - public static readonly DependencyProperty ConfigurationProperty = DependencyProperty.Register( + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public static readonly DependencyProperty ConfigurationProperty = DependencyProperty.Register( "Configuration", typeof(UIComponentConfiguration), typeof(UIComponentContainer), @@ -378,7 +386,7 @@ public IConfiguration GetConfiguration(IConfigurableComponent component) { var configuration = new UIComponentConfigurationProvider(this.Configuration); configuration.InitializeComponent(Core.Instance); - //Logger.Write(this, LogLevel.Debug, "Registering configuration for component {0}.", component.GetType().Name); + Logger.Write(this, LogLevel.Debug, "Registering configuration for component {0}.", component.GetType().Name); try { var sections = component.GetConfigurationSections(); @@ -387,9 +395,9 @@ public IConfiguration GetConfiguration(IConfigurableComponent component) configuration.WithSection(section); } } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to register configuration for component {0}: {1}", component.GetType().Name, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to register configuration for component {0}: {1}", component.GetType().Name, e.Message); } configuration.Load(); configuration.ConnectDependencies(); diff --git a/FoxTunes.UI.Windows.Layout/UIComponentDesignerOverlay.cs b/FoxTunes.UI.Windows.Layout/UIComponentDesignerOverlay.cs index 04728d5f5..53f06e122 100644 --- a/FoxTunes.UI.Windows.Layout/UIComponentDesignerOverlay.cs +++ b/FoxTunes.UI.Windows.Layout/UIComponentDesignerOverlay.cs @@ -133,7 +133,7 @@ protected virtual void OnDisposing() ~UIComponentDesignerOverlay() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); @@ -301,7 +301,7 @@ protected virtual void OnDisposing() ~UIComponentDesignerAdorner() { - //Logger.Write(typeof(UIComponentDesignerAdorner), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(typeof(UIComponentDesignerAdorner), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows.Layout/UIComponentLayoutProvider.cs b/FoxTunes.UI.Windows.Layout/UIComponentLayoutProvider.cs index de1f64fd6..1c4005566 100644 --- a/FoxTunes.UI.Windows.Layout/UIComponentLayoutProvider.cs +++ b/FoxTunes.UI.Windows.Layout/UIComponentLayoutProvider.cs @@ -115,7 +115,7 @@ protected virtual void OnValueChanged(object sender, EventArgs e) { return; } - //Logger.Write(this, LogLevel.Debug, "Layout was modified, reloading."); + Logger.Write(this, LogLevel.Debug, "Layout was modified, reloading."); var task = this.Load(); } } @@ -135,11 +135,11 @@ protected virtual Task Load() { if (string.IsNullOrEmpty(this.Main.Value)) { - //Logger.Write(this, LogLevel.Debug, "No component to load."); + Logger.Write(this, LogLevel.Debug, "No component to load."); this.MainComponent = null; return; } - //Logger.Write(this, LogLevel.Debug, "Loading component.."); + Logger.Write(this, LogLevel.Debug, "Loading component.."); try { using (var stream = new MemoryStream(Encoding.Default.GetBytes(this.Main.Value))) @@ -147,9 +147,9 @@ protected virtual Task Load() this.MainComponent = Serializer.LoadComponent(stream); } } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to load component: {0}", e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to load component: {0}", e.Message); } }); } @@ -214,7 +214,7 @@ protected virtual void Save() return; } this.IsSaving = true; - //Logger.Write(this, LogLevel.Debug, "Saving config."); + Logger.Write(this, LogLevel.Debug, "Saving config."); try { this.Main.Value = value; @@ -224,9 +224,9 @@ protected virtual void Save() this.IsSaving = false; } } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to save config: {0}", e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to save config: {0}", e.Message); } } @@ -279,7 +279,7 @@ protected virtual void OnDisposing() ~UIComponentLayoutProvider() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows.Layout/UIComponentSelector.xaml.cs b/FoxTunes.UI.Windows.Layout/UIComponentSelector.xaml.cs index 9c8b77b67..f2fce1238 100644 --- a/FoxTunes.UI.Windows.Layout/UIComponentSelector.xaml.cs +++ b/FoxTunes.UI.Windows.Layout/UIComponentSelector.xaml.cs @@ -8,7 +8,15 @@ namespace FoxTunes { public partial class UIComponentSelector : UserControl, IUIComponent { - public static readonly DependencyProperty ComponentProperty = DependencyProperty.Register( + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public static readonly DependencyProperty ComponentProperty = DependencyProperty.Register( "Component", typeof(UIComponentConfiguration), typeof(UIComponentSelector), diff --git a/FoxTunes.UI.Windows.Layout/Utilities/Serializer.cs b/FoxTunes.UI.Windows.Layout/Utilities/Serializer.cs index 38c2f5c4d..3abae8308 100644 --- a/FoxTunes.UI.Windows.Layout/Utilities/Serializer.cs +++ b/FoxTunes.UI.Windows.Layout/Utilities/Serializer.cs @@ -14,6 +14,14 @@ public static class Serializer const string Name = "Name"; const string Value = "Value"; + private static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + public static void Save(Stream stream, IEnumerable configs) { using (var writer = new XmlTextWriter(stream, Encoding.Default)) @@ -209,7 +217,7 @@ private static UIComponentConfiguration LoadComponent(XmlReader reader) } else { - //Logger.Write(typeof(Serializer), LogLevel.Warn, "Element \"{0}\" was not recognized.", reader.Name); + Logger.Write(typeof(Serializer), LogLevel.Warn, "Element \"{0}\" was not recognized.", reader.Name); break; } } diff --git a/FoxTunes.UI.Windows.LibraryBrowser/Utilities/LibraryBrowserTileBrushFactory.cs b/FoxTunes.UI.Windows.LibraryBrowser/Utilities/LibraryBrowserTileBrushFactory.cs index 64a6b4096..472573af0 100644 --- a/FoxTunes.UI.Windows.LibraryBrowser/Utilities/LibraryBrowserTileBrushFactory.cs +++ b/FoxTunes.UI.Windows.LibraryBrowser/Utilities/LibraryBrowserTileBrushFactory.cs @@ -63,7 +63,7 @@ protected virtual Task OnSignal(object sender, ISignal signal) this.Reset(); break; case CommonSignals.ImagesUpdated: - //Logger.Write(this, LogLevel.Debug, "Images were updated, resetting cache."); + Logger.Write(this, LogLevel.Debug, "Images were updated, resetting cache."); this.Reset(); break; } @@ -119,7 +119,7 @@ public Wrapper Create(LibraryHierarchyNode libraryHierarchyNode, Lib protected virtual ImageBrush Create(LibraryHierarchyNode libraryHierarchyNode, Func metaDataItems, int width, int height, LibraryBrowserImageMode mode, bool cache) { - //Logger.Write(this, LogLevel.Debug, "Creating brush: {0}x{1}", width, height); + Logger.Write(this, LogLevel.Debug, "Creating brush: {0}x{1}", width, height); var source = this.LibraryBrowserTileProvider.CreateImageSource( libraryHierarchyNode, metaDataItems, @@ -145,7 +145,7 @@ protected virtual ImageBrush Create(LibraryHierarchyNode libraryHierarchyNode, F protected virtual void CreateTaskFactory(int threads) { - //Logger.Write(this, LogLevel.Debug, "Creating task factory for {0} threads.", threads); + Logger.Write(this, LogLevel.Debug, "Creating task factory for {0} threads.", threads); this.Factory = new TaskFactory(new TaskScheduler(new ParallelOptions() { MaxDegreeOfParallelism = threads @@ -154,7 +154,7 @@ protected virtual void CreateTaskFactory(int threads) protected virtual void CreateCache(int capacity) { - //Logger.Write(this, LogLevel.Debug, "Creating cache for {0} items.", capacity); + Logger.Write(this, LogLevel.Debug, "Creating cache for {0} items.", capacity); this.Store = new ImageBrushCache>(capacity); } @@ -167,7 +167,7 @@ protected virtual void Reset(IEnumerable names) return; } } - //Logger.Write(this, LogLevel.Debug, "Meta data was updated, resetting cache."); + Logger.Write(this, LogLevel.Debug, "Meta data was updated, resetting cache."); this.Reset(); } @@ -204,7 +204,7 @@ protected virtual void OnDisposing() ~LibraryBrowserTileBrushFactory() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows.LibraryBrowser/Utilities/LibraryBrowserTileProvider.cs b/FoxTunes.UI.Windows.LibraryBrowser/Utilities/LibraryBrowserTileProvider.cs index 2b7276424..db7c0fe6d 100644 --- a/FoxTunes.UI.Windows.LibraryBrowser/Utilities/LibraryBrowserTileProvider.cs +++ b/FoxTunes.UI.Windows.LibraryBrowser/Utilities/LibraryBrowserTileProvider.cs @@ -40,7 +40,7 @@ protected virtual Task OnSignal(object sender, ISignal signal) this.OnMetaDataUpdated(signal.State as MetaDataUpdatedSignalState); break; case CommonSignals.ImagesUpdated: - //Logger.Write(this, LogLevel.Debug, "Images were updated, resetting cache."); + Logger.Write(this, LogLevel.Debug, "Images were updated, resetting cache."); this.ClearCache(); break; } @@ -65,12 +65,12 @@ protected virtual void OnMetaDataUpdated(MetaDataUpdatedSignalState state) var libraryHierarchyNodes = state.FileDatas.GetParents(); foreach (var libraryHierarchyNode in libraryHierarchyNodes) { - //Logger.Write(this, LogLevel.Debug, "Meta data was updated for item {0}, resetting cache.", libraryHierarchyNode.Id); + Logger.Write(this, LogLevel.Debug, "Meta data was updated for item {0}, resetting cache.", libraryHierarchyNode.Id); this.ClearCache(libraryHierarchyNode); } return; } - //Logger.Write(this, LogLevel.Debug, "Meta data was updated, resetting cache."); + Logger.Write(this, LogLevel.Debug, "Meta data was updated, resetting cache."); this.ClearCache(); } @@ -93,9 +93,9 @@ public ImageSource CreateImageSource(LibraryHierarchyNode libraryHierarchyNode, } return this.CreateImageSourceCore(libraryHierarchyNode, metaDataItems, width, height, mode, cache); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Error, "Error creating image source: {0}", e.Message); + Logger.Write(this, LogLevel.Error, "Error creating image source: {0}", e.Message); return null; } } @@ -325,9 +325,9 @@ private void ClearCache(LibraryHierarchyNode libraryHierarchyNode) this.GetCachePrefix(libraryHierarchyNode) ); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to clear storage \"{0}\": {1}", this.GetCachePrefix(libraryHierarchyNode), e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to clear storage \"{0}\": {1}", this.GetCachePrefix(libraryHierarchyNode), e.Message); } } @@ -337,9 +337,9 @@ private void ClearCache() { FileMetaDataStore.Clear(PREFIX); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to clear storage \"{0}\": {1}", PREFIX, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to clear storage \"{0}\": {1}", PREFIX, e.Message); } } @@ -371,7 +371,7 @@ protected virtual void OnDisposing() ~LibraryBrowserTileProvider() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows.LibraryBrowser/VirtualizingWrapPanel.cs b/FoxTunes.UI.Windows.LibraryBrowser/VirtualizingWrapPanel.cs index 0b7b6f747..08d6b71a8 100644 --- a/FoxTunes.UI.Windows.LibraryBrowser/VirtualizingWrapPanel.cs +++ b/FoxTunes.UI.Windows.LibraryBrowser/VirtualizingWrapPanel.cs @@ -12,7 +12,15 @@ namespace FoxTunes { public class VirtualizingWrapPanel : VirtualizingPanel, IScrollInfo { - public VirtualizingWrapPanel() + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public VirtualizingWrapPanel() { this.ContainerLayouts = new Dictionary(); this.PreviousSize = new Size(16, 16); @@ -507,7 +515,7 @@ protected virtual void OnDisposing() ~ChildGenerator() { - //Logger.Write(typeof(ChildGenerator), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(typeof(ChildGenerator), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows.Lyrics/Behaviours/LyricsBehaviour.cs b/FoxTunes.UI.Windows.Lyrics/Behaviours/LyricsBehaviour.cs index b95179934..c8dc408d0 100644 --- a/FoxTunes.UI.Windows.Lyrics/Behaviours/LyricsBehaviour.cs +++ b/FoxTunes.UI.Windows.Lyrics/Behaviours/LyricsBehaviour.cs @@ -164,7 +164,7 @@ public async Task Edit() Path.GetTempPath(), string.Format("Lyrics-{0}.txt", DateTime.Now.ToFileTimeUtc()) ); - //Logger.Write(this, LogLevel.Debug, "Editing lyrics for file \"{0}\": \"{1}\"", playlistItem.FileName, fileName); + Logger.Write(this, LogLevel.Debug, "Editing lyrics for file \"{0}\": \"{1}\"", playlistItem.FileName, fileName); if (metaDataItem != null) { File.WriteAllText(fileName, metaDataItem.Value); @@ -179,7 +179,7 @@ public async Task Edit() await process.WaitForExitAsync().ConfigureAwait(false); if (process.ExitCode != 0) { - //Logger.Write(this, LogLevel.Warn, "Process does not indicate success: Code = {0}", process.ExitCode); + Logger.Write(this, LogLevel.Warn, "Process does not indicate success: Code = {0}", process.ExitCode); return; } var flags = MetaDataUpdateFlags.None; @@ -208,9 +208,9 @@ await this.OnDemandMetaDataProvider.SetMetaData( { File.Delete(fileName); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to delete temp file \"{0}\":", fileName, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to delete temp file \"{0}\":", fileName, e.Message); } } } diff --git a/FoxTunes.UI.Windows.Lyrics/MetaData/LyricsMetaDataSource.cs b/FoxTunes.UI.Windows.Lyrics/MetaData/LyricsMetaDataSource.cs index 536f2e476..b3cd129d8 100644 --- a/FoxTunes.UI.Windows.Lyrics/MetaData/LyricsMetaDataSource.cs +++ b/FoxTunes.UI.Windows.Lyrics/MetaData/LyricsMetaDataSource.cs @@ -92,14 +92,14 @@ public async Task GetValues(IEnumerable fileD var values = new List(); foreach (var fileData in fileDatas) { - //Logger.Write(this, LogLevel.Debug, "Looking up lyrics for file \"{0}\"..", fileData.FileName); + Logger.Write(this, LogLevel.Debug, "Looking up lyrics for file \"{0}\"..", fileData.FileName); var result = await provider.Lookup(fileData).ConfigureAwait(false); if (!result.Success) { - //Logger.Write(this, LogLevel.Warn, "Failed to look up lyrics for file \"{0}\".", fileData.FileName); + Logger.Write(this, LogLevel.Warn, "Failed to look up lyrics for file \"{0}\".", fileData.FileName); continue; } - //Logger.Write(this, LogLevel.Debug, "Looking up lyrics for file \"{0}\": OK.", fileData.FileName); + Logger.Write(this, LogLevel.Debug, "Looking up lyrics for file \"{0}\": OK.", fileData.FileName); values.Add(new OnDemandMetaDataValue(fileData, result.Lyrics)); } var flags = MetaDataUpdateFlags.None; @@ -121,12 +121,12 @@ protected virtual ILyricsProvider GetAutoLookupProvider() } if (provider == null) { - //Logger.Write(this, LogLevel.Warn, "Failed to determine the preferred provider."); + Logger.Write(this, LogLevel.Warn, "Failed to determine the preferred provider."); provider = this.Behaviour.Providers.FirstOrDefault(); } if (provider == null) { - //Logger.Write(this, LogLevel.Warn, "No providers."); + Logger.Write(this, LogLevel.Warn, "No providers."); } return provider; } diff --git a/FoxTunes.UI.Windows.Lyrics/Providers/ChartLyricsProvider.cs b/FoxTunes.UI.Windows.Lyrics/Providers/ChartLyricsProvider.cs index f23740c00..808eb12ce 100644 --- a/FoxTunes.UI.Windows.Lyrics/Providers/ChartLyricsProvider.cs +++ b/FoxTunes.UI.Windows.Lyrics/Providers/ChartLyricsProvider.cs @@ -53,35 +53,35 @@ public override string None public override async Task Lookup(IFileData fileData) { - //Logger.Write(this, LogLevel.Debug, "Getting track information for file \"{0}\"..", fileData.FileName); + Logger.Write(this, LogLevel.Debug, "Getting track information for file \"{0}\"..", fileData.FileName); var artist = default(string); var song = default(string); if (!this.TryGetLookup(fileData, out artist, out song)) { - //Logger.Write(this, LogLevel.Warn, "Failed to get track information: The required meta data was not found."); + Logger.Write(this, LogLevel.Warn, "Failed to get track information: The required meta data was not found."); return LyricsResult.Fail; } - //Logger.Write(this, LogLevel.Debug, "Got track information: Artist = \"{0}\", Song = \"{1}\".", artist, song); + Logger.Write(this, LogLevel.Debug, "Got track information: Artist = \"{0}\", Song = \"{1}\".", artist, song); var searchResult = default(SearchLyricResult); var lyricsResult = default(GetLyricResult); try { - //Logger.Write(this, LogLevel.Debug, "Searching for match.."); + Logger.Write(this, LogLevel.Debug, "Searching for match.."); searchResult = await this.Lookup(artist, song).ConfigureAwait(false); if (searchResult != null) { - //Logger.Write(this, LogLevel.Debug, "Got match, fetching lyrics.."); + Logger.Write(this, LogLevel.Debug, "Got match, fetching lyrics.."); lyricsResult = await this.Lookup(searchResult).ConfigureAwait(false); if (lyricsResult != null && !string.IsNullOrEmpty(lyricsResult.Lyric)) { - //Logger.Write(this, LogLevel.Debug, "Success."); + Logger.Write(this, LogLevel.Debug, "Success."); return new LyricsResult(lyricsResult.Lyric); } } } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to fetch lyrics: {0}", e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to fetch lyrics: {0}", e.Message); } finally { @@ -101,13 +101,13 @@ public override async Task Lookup(IFileData fileData) protected virtual async Task Lookup(string artist, string song) { var url = this.GetUrl(artist, song); - //Logger.Write(this, LogLevel.Debug, "Querying the API: {0}", url); + Logger.Write(this, LogLevel.Debug, "Querying the API: {0}", url); var request = WebRequestFactory.Create(url); using (var response = (HttpWebResponse)request.GetResponse()) { if (response.StatusCode != HttpStatusCode.OK) { - //Logger.Write(this, LogLevel.Warn, "Status code does not indicate success."); + Logger.Write(this, LogLevel.Warn, "Status code does not indicate success."); return null; } using (var stream = response.GetResponseStream()) @@ -174,13 +174,13 @@ protected virtual Task Lookup(SearchLyricResult searchResult) Uri.EscapeDataString(searchResult.LyricId), Uri.EscapeDataString(searchResult.LyricChecksum) ); - //Logger.Write(this, LogLevel.Debug, "Querying the API: {0}", url); + Logger.Write(this, LogLevel.Debug, "Querying the API: {0}", url); var request = WebRequest.Create(url); using (var response = (HttpWebResponse)request.GetResponse()) { if (response.StatusCode != HttpStatusCode.OK) { - //Logger.Write(this, LogLevel.Warn, "Status code does not indicate success."); + Logger.Write(this, LogLevel.Warn, "Status code does not indicate success."); #if NET40 return TaskEx.FromResult(default(GetLyricResult)); #else @@ -448,7 +448,7 @@ public bool Valid { valid = false; } - //Logger.Write(typeof(ChartLyricsProvider), LogLevel.Trace, "Lyric search: LyricChecksum = {0}, LyricId = {1}, Artist = \"{2}\", Song = \"{3}\", Valid = {4}.", this.LyricChecksum, this.LyricId, this.Artist, this.Song, valid); + Logger.Write(typeof(ChartLyricsProvider), LogLevel.Trace, "Lyric search: LyricChecksum = {0}, LyricId = {1}, Artist = \"{2}\", Song = \"{3}\", Valid = {4}.", this.LyricChecksum, this.LyricId, this.Artist, this.Song, valid); return valid; } } @@ -456,7 +456,7 @@ public bool Valid public float Similarity(string artist, string song) { var similarity = (this.Artist.Similarity(artist, true) + this.Song.Similarity(song, true)) / 2; - //Logger.Write(typeof(ChartLyricsProvider), LogLevel.Trace, "Lyric search: LyricChecksum = {0}, LyricId = {1}, Confidence = {2}.", this.LyricChecksum, this.LyricId, similarity); + Logger.Write(typeof(ChartLyricsProvider), LogLevel.Trace, "Lyric search: LyricChecksum = {0}, LyricId = {1}, Confidence = {2}.", this.LyricChecksum, this.LyricId, similarity); return similarity; } } diff --git a/FoxTunes.UI.Windows.MetaDataEditor/ViewModel/MetaDataEntry.cs b/FoxTunes.UI.Windows.MetaDataEditor/ViewModel/MetaDataEntry.cs index 0d110bdb1..d59298f37 100644 --- a/FoxTunes.UI.Windows.MetaDataEditor/ViewModel/MetaDataEntry.cs +++ b/FoxTunes.UI.Windows.MetaDataEditor/ViewModel/MetaDataEntry.cs @@ -437,9 +437,9 @@ protected virtual void UpdateDragDropEffects(DragEventArgs e) effects = DragDropEffects.Copy; } } - catch + catch (Exception exception) { - //Logger.Write(this, LogLevel.Warn, "Failed to query clipboard contents: {0}", exception.Message); + Logger.Write(this, LogLevel.Warn, "Failed to query clipboard contents: {0}", exception.Message); } e.Effects = effects; } @@ -464,9 +464,9 @@ protected virtual Task OnDrop(DragEventArgs e) this.Value = paths.FirstOrDefault(); } } - catch + catch (Exception exception) { - //Logger.Write(this, LogLevel.Warn, "Failed to process clipboard contents: {0}", exception.Message); + Logger.Write(this, LogLevel.Warn, "Failed to process clipboard contents: {0}", exception.Message); } #if NET40 return TaskEx.FromResult(false); diff --git a/FoxTunes.UI.Windows.MetaDataViewer/ViewModel/SelectionProperties.cs b/FoxTunes.UI.Windows.MetaDataViewer/ViewModel/SelectionProperties.cs index f7ba79051..06bccef52 100644 --- a/FoxTunes.UI.Windows.MetaDataViewer/ViewModel/SelectionProperties.cs +++ b/FoxTunes.UI.Windows.MetaDataViewer/ViewModel/SelectionProperties.cs @@ -632,9 +632,9 @@ protected virtual Row GetRow(string name, IEnumerable fileDatas, IDic provider.GetValue(fileData, metaData, name) ); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to read property \"{0}\" of file \"{1}\": {2}", name, fileData.FileName, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to read property \"{0}\" of file \"{1}\": {2}", name, fileData.FileName, e.Message); } } var value = aggregator.GetValue(values); diff --git a/FoxTunes.UI.Windows.MiniPlayer/ViewModel/Mini.cs b/FoxTunes.UI.Windows.MiniPlayer/ViewModel/Mini.cs index 1b8a53017..067abefee 100644 --- a/FoxTunes.UI.Windows.MiniPlayer/ViewModel/Mini.cs +++ b/FoxTunes.UI.Windows.MiniPlayer/ViewModel/Mini.cs @@ -165,9 +165,9 @@ protected virtual void UpdateDragDropEffects(DragEventArgs e) effects = DragDropEffects.Copy; } } - catch + catch (Exception exception) { - //Logger.Write(this, LogLevel.Warn, "Failed to query clipboard contents: {0}", exception.Message); + Logger.Write(this, LogLevel.Warn, "Failed to query clipboard contents: {0}", exception.Message); } e.Effects = effects; } @@ -209,9 +209,9 @@ protected virtual void OnDrop(DragEventArgs e) var task = this.AddToPlaylist(paths); } } - catch + catch (Exception exception) { - //Logger.Write(this, LogLevel.Warn, "Failed to process clipboard contents: {0}", exception.Message); + Logger.Write(this, LogLevel.Warn, "Failed to process clipboard contents: {0}", exception.Message); } } diff --git a/FoxTunes.UI.Windows.MiniPlayer/ViewModel/MiniPlaylist.cs b/FoxTunes.UI.Windows.MiniPlayer/ViewModel/MiniPlaylist.cs index 9c6c6ca2c..67db84c0b 100644 --- a/FoxTunes.UI.Windows.MiniPlayer/ViewModel/MiniPlaylist.cs +++ b/FoxTunes.UI.Windows.MiniPlayer/ViewModel/MiniPlaylist.cs @@ -218,9 +218,9 @@ protected virtual void UpdateDragDropEffects(DragEventArgs e) effects = DragDropEffects.Copy; } } - catch + catch (Exception exception) { - //Logger.Write(this, LogLevel.Warn, "Failed to query clipboard contents: {0}", exception.Message); + Logger.Write(this, LogLevel.Warn, "Failed to query clipboard contents: {0}", exception.Message); } e.Effects = effects; } @@ -255,9 +255,9 @@ protected virtual Task OnDrop(DragEventArgs e) return this.AddToPlaylist(paths); } } - catch + catch (Exception exception) { - //Logger.Write(this, LogLevel.Warn, "Failed to process clipboard contents: {0}", exception.Message); + Logger.Write(this, LogLevel.Warn, "Failed to process clipboard contents: {0}", exception.Message); } #if NET40 return TaskEx.FromResult(false); diff --git a/FoxTunes.UI.Windows.Ratings/Behaviours/RatingBehaviour.cs b/FoxTunes.UI.Windows.Ratings/Behaviours/RatingBehaviour.cs index 73fc0fdbc..b3255cd1f 100644 --- a/FoxTunes.UI.Windows.Ratings/Behaviours/RatingBehaviour.cs +++ b/FoxTunes.UI.Windows.Ratings/Behaviours/RatingBehaviour.cs @@ -231,7 +231,7 @@ public Task InvokeAsync(IInvocationComponent component) protected virtual async Task GetRating(LibraryHierarchyNode libraryHierarchyNode, Dictionary invocationComponents) { - //Logger.Write(this, LogLevel.Debug, "Determining rating for library hierarchy node: {0}", libraryHierarchyNode.Id); + Logger.Write(this, LogLevel.Debug, "Determining rating for library hierarchy node: {0}", libraryHierarchyNode.Id); var rating = default(byte); var ratings = await this.MetaDataBrowser.GetMetaDatas( libraryHierarchyNode, @@ -242,19 +242,19 @@ protected virtual async Task GetRating(LibraryHierarchyNode libraryHierarchyNode switch (ratings.Length) { case 0: - //Logger.Write(this, LogLevel.Debug, "Library hierarchy node {0} tracks have no rating.", libraryHierarchyNode.Id); + Logger.Write(this, LogLevel.Debug, "Library hierarchy node {0} tracks have no rating.", libraryHierarchyNode.Id); rating = 0; break; case 1: if (!byte.TryParse(ratings[0].Value, out rating)) { - //Logger.Write(this, LogLevel.Warn, "Library hierarchy node {0} tracks have rating \"{1}\" which is in an unknown format.", libraryHierarchyNode.Id, rating); + Logger.Write(this, LogLevel.Warn, "Library hierarchy node {0} tracks have rating \"{1}\" which is in an unknown format.", libraryHierarchyNode.Id, rating); return; } - //Logger.Write(this, LogLevel.Debug, "Library hierarchy node {0} tracks have rating {1}.", libraryHierarchyNode.Id, rating); + Logger.Write(this, LogLevel.Debug, "Library hierarchy node {0} tracks have rating {1}.", libraryHierarchyNode.Id, rating); break; default: - //Logger.Write(this, LogLevel.Debug, "Library hierarchy node {0} tracks have multiple ratings.", libraryHierarchyNode.Id); + Logger.Write(this, LogLevel.Debug, "Library hierarchy node {0} tracks have multiple ratings.", libraryHierarchyNode.Id); return; } foreach (var key in invocationComponents.Keys) @@ -272,10 +272,10 @@ protected virtual async Task GetRating(PlaylistItem[] playlistItems, Dictionary< if (playlistItems.Length > ListViewExtensions.MAX_SELECTED_ITEMS) { //This would result in too many parameters. - //Logger.Write(this, LogLevel.Debug, "Cannot determining rating for {0} playlist items, max is {1}.", playlistItems.Length, ListViewExtensions.MAX_SELECTED_ITEMS); + Logger.Write(this, LogLevel.Debug, "Cannot determining rating for {0} playlist items, max is {1}.", playlistItems.Length, ListViewExtensions.MAX_SELECTED_ITEMS); return; } - //Logger.Write(this, LogLevel.Debug, "Determining rating for {0} playlist items.", playlistItems.Length); + Logger.Write(this, LogLevel.Debug, "Determining rating for {0} playlist items.", playlistItems.Length); var rating = default(byte); var ratings = await this.MetaDataBrowser.GetMetaDatas( playlistItems, @@ -286,19 +286,19 @@ protected virtual async Task GetRating(PlaylistItem[] playlistItems, Dictionary< switch (ratings.Length) { case 0: - //Logger.Write(this, LogLevel.Debug, "{0} playlist items have no rating.", playlistItems.Length); + Logger.Write(this, LogLevel.Debug, "{0} playlist items have no rating.", playlistItems.Length); rating = 0; break; case 1: if (!byte.TryParse(ratings[0].Value, out rating)) { - //Logger.Write(this, LogLevel.Warn, "{0} playlist items have rating \"{1}\" which is in an unknown format.", playlistItems.Length, rating); + Logger.Write(this, LogLevel.Warn, "{0} playlist items have rating \"{1}\" which is in an unknown format.", playlistItems.Length, rating); return; } - //Logger.Write(this, LogLevel.Debug, "{0} playlist items have rating {1}.", playlistItems.Length, rating); + Logger.Write(this, LogLevel.Debug, "{0} playlist items have rating {1}.", playlistItems.Length, rating); break; default: - //Logger.Write(this, LogLevel.Debug, "{0} playlist items have multiple ratings.", playlistItems.Length); + Logger.Write(this, LogLevel.Debug, "{0} playlist items have multiple ratings.", playlistItems.Length); return; } foreach (var key in invocationComponents.Keys) diff --git a/FoxTunes.UI.Windows.Snapping/Behaviours/WindowSnappingBehaviour.cs b/FoxTunes.UI.Windows.Snapping/Behaviours/WindowSnappingBehaviour.cs index 1b0f56bba..02026ace7 100644 --- a/FoxTunes.UI.Windows.Snapping/Behaviours/WindowSnappingBehaviour.cs +++ b/FoxTunes.UI.Windows.Snapping/Behaviours/WindowSnappingBehaviour.cs @@ -134,7 +134,7 @@ protected virtual void OnDisposing() ~WindowSnappingBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows.Snapping/Utilities/SnappingHelper.cs b/FoxTunes.UI.Windows.Snapping/Utilities/SnappingHelper.cs index 6ab135b1b..b8a27bebf 100644 --- a/FoxTunes.UI.Windows.Snapping/Utilities/SnappingHelper.cs +++ b/FoxTunes.UI.Windows.Snapping/Utilities/SnappingHelper.cs @@ -6,6 +6,14 @@ namespace FoxTunes { public static class SnappingHelper { + private static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + static SnappingHelper() { var configuration = ComponentRegistry.Instance.GetComponent(); @@ -37,7 +45,7 @@ public static SnapDirection Snap(ref Rectangle from, Rectangle to, bool resize) from.X += -(from.Right - to.Left); } result |= SnapDirection.OutsideLeft; - //Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snap outside left."); + Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snap outside left."); } else if (Math.Abs(from.Left - to.Left) <= proximity) { @@ -47,7 +55,7 @@ public static SnapDirection Snap(ref Rectangle from, Rectangle to, bool resize) } from.X += -(from.Left - to.Left); result |= SnapDirection.InsideLeft; - //Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snap inside left."); + Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snap inside left."); } if (Math.Abs(from.Left - to.Right) <= proximity) { @@ -57,7 +65,7 @@ public static SnapDirection Snap(ref Rectangle from, Rectangle to, bool resize) } from.X += -(from.Left - to.Right); result |= SnapDirection.OutsideRight; - //Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snap outside right."); + Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snap outside right."); } else if (Math.Abs(from.Right - to.Right) <= proximity) { @@ -70,7 +78,7 @@ public static SnapDirection Snap(ref Rectangle from, Rectangle to, bool resize) from.X += -(from.Right - to.Right); } result |= SnapDirection.InsideRight; - //Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snap inside right."); + Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snap inside right."); } } if (from.Right >= to.Left - proximity && from.Left <= to.Right + proximity) @@ -86,7 +94,7 @@ public static SnapDirection Snap(ref Rectangle from, Rectangle to, bool resize) from.Y += -(from.Bottom - to.Top); } result |= SnapDirection.OutsideTop; - //Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snap outside top."); + Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snap outside top."); } else if (Math.Abs(from.Top - to.Top) <= proximity) { @@ -96,7 +104,7 @@ public static SnapDirection Snap(ref Rectangle from, Rectangle to, bool resize) } from.Y += -(from.Top - to.Top); result |= SnapDirection.InsideTop; - //Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snap inside top."); + Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snap inside top."); } if (Math.Abs(from.Top - to.Bottom) <= proximity) { @@ -106,7 +114,7 @@ public static SnapDirection Snap(ref Rectangle from, Rectangle to, bool resize) } from.Y += -(from.Top - to.Bottom); result |= SnapDirection.OutsideBottom; - //Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snap outside bottom."); + Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snap outside bottom."); } else if (Math.Abs(from.Bottom - to.Bottom) <= proximity) { @@ -119,7 +127,7 @@ public static SnapDirection Snap(ref Rectangle from, Rectangle to, bool resize) from.Y += -(from.Bottom - to.Bottom); } result |= SnapDirection.InsideBottom; - //Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snap inside bottom."); + Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snap inside bottom."); } } return result; @@ -138,22 +146,22 @@ public static SnapDirection IsSnapped(Rectangle from, Rectangle to, int proximit if (Math.Abs(from.Right - to.Left) <= proximity) { result |= SnapDirection.OutsideLeft; - //Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snapped outside left."); + Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snapped outside left."); } else if (Math.Abs(from.Left - to.Left) <= proximity) { result |= SnapDirection.InsideLeft; - //Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snapped inside left."); + Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snapped inside left."); } if (Math.Abs(from.Left - to.Right) <= proximity) { result |= SnapDirection.OutsideRight; - //Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snapped outside right."); + Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snapped outside right."); } else if (Math.Abs(from.Right - to.Right) <= proximity) { result |= SnapDirection.InsideRight; - //Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snapped inside right."); + Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snapped inside right."); } } if (from.Right >= to.Left - proximity && from.Left <= to.Right + proximity) @@ -161,22 +169,22 @@ public static SnapDirection IsSnapped(Rectangle from, Rectangle to, int proximit if (Math.Abs(from.Bottom - to.Top) <= proximity) { result |= SnapDirection.OutsideTop; - //Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snapped outside top."); + Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snapped outside top."); } else if (Math.Abs(from.Top - to.Top) <= proximity) { result |= SnapDirection.InsideTop; - //Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snapped inside top."); + Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snapped inside top."); } if (Math.Abs(from.Top - to.Bottom) <= proximity) { result |= SnapDirection.OutsideBottom; - //Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snapped outside bottom."); + Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snapped outside bottom."); } else if (Math.Abs(from.Bottom - to.Bottom) <= proximity) { result |= SnapDirection.InsideBottom; - //Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snapped inside bottom."); + Logger.Write(typeof(SnappingHelper), LogLevel.Debug, "Snapped inside bottom."); } } return result; diff --git a/FoxTunes.UI.Windows.Snapping/Utilities/SnappingWindow.cs b/FoxTunes.UI.Windows.Snapping/Utilities/SnappingWindow.cs index b1dd4de1c..51d1f9f0e 100644 --- a/FoxTunes.UI.Windows.Snapping/Utilities/SnappingWindow.cs +++ b/FoxTunes.UI.Windows.Snapping/Utilities/SnappingWindow.cs @@ -381,7 +381,7 @@ protected virtual SnapDirection SnapToWindows(Point mousePosition, ref Rectangle { this.StickyWindows.Remove(snappingWindow); snappingWindow.StickyWindows.Remove(this); - //Logger.Write(this, LogLevel.Debug, "Unstick."); + Logger.Write(this, LogLevel.Debug, "Unstick."); } continue; } @@ -659,7 +659,7 @@ protected virtual void OnDisposing() ~SnappingWindow() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows.Visualizations/Utilities/EnhancedSpectrumRenderer.cs b/FoxTunes.UI.Windows.Visualizations/Utilities/EnhancedSpectrumRenderer.cs index 2011e5157..7d7c4ff9a 100644 --- a/FoxTunes.UI.Windows.Visualizations/Utilities/EnhancedSpectrumRenderer.cs +++ b/FoxTunes.UI.Windows.Visualizations/Utilities/EnhancedSpectrumRenderer.cs @@ -220,12 +220,12 @@ protected virtual Task Render(SpectrumRendererData data) Render(ref info, data); success = true; } - catch + catch (Exception e) { #if DEBUG - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrum: {0}", e.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrum: {0}", e.Message); #else - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrum, disabling: {0}", e.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrum, disabling: {0}", e.Message); success = false; #endif } @@ -275,13 +275,13 @@ protected override void OnUpdateData(object sender, ElapsedEventArgs e) this.BeginUpdateData(); } - catch + catch (Exception exception) { #if DEBUG - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update spectrum data: {0}", exception.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update spectrum data: {0}", exception.Message); this.BeginUpdateData(); #else - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update spectrum data, disabling: {0}", exception.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update spectrum data, disabling: {0}", exception.Message); #endif } } @@ -300,13 +300,13 @@ protected override async void OnUpdateDisplay(object sender, ElapsedEventArgs e) this.BeginUpdateDisplay(); } - catch + catch (Exception exception) { #if DEBUG - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrum data: {0}", exception.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrum data: {0}", exception.Message); this.BeginUpdateData(); #else - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrum data, disabling: {0}", exception.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrum data, disabling: {0}", exception.Message); #endif } } diff --git a/FoxTunes.UI.Windows.Visualizations/Utilities/OscilloscopeRenderer.cs b/FoxTunes.UI.Windows.Visualizations/Utilities/OscilloscopeRenderer.cs index d5f9d9ba2..b01e763f8 100644 --- a/FoxTunes.UI.Windows.Visualizations/Utilities/OscilloscopeRenderer.cs +++ b/FoxTunes.UI.Windows.Visualizations/Utilities/OscilloscopeRenderer.cs @@ -161,12 +161,12 @@ protected virtual Task Render(OscilloscopeRendererData data) Render(info, data); success = true; } - catch + catch (Exception e) { #if DEBUG - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render oscilloscope: {0}", e.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render oscilloscope: {0}", e.Message); #else - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render oscilloscope, disabling: {0}", e.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render oscilloscope, disabling: {0}", e.Message); success = false; #endif } @@ -229,13 +229,13 @@ protected override void OnUpdateData(object sender, ElapsedEventArgs e) this.BeginUpdateData(); } - catch + catch (Exception exception) { #if DEBUG - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update oscilloscope data: {0}", exception.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update oscilloscope data: {0}", exception.Message); this.BeginUpdateData(); #else - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update oscilloscope data, disabling: {0}", exception.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update oscilloscope data, disabling: {0}", exception.Message); #endif } } @@ -254,13 +254,13 @@ protected override async void OnUpdateDisplay(object sender, ElapsedEventArgs e) this.BeginUpdateDisplay(); } - catch + catch (Exception exception) { #if DEBUG - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render oscilloscope data: {0}", exception.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render oscilloscope data: {0}", exception.Message); this.BeginUpdateData(); #else - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render oscilloscope data, disabling: {0}", exception.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render oscilloscope data, disabling: {0}", exception.Message); #endif } } diff --git a/FoxTunes.UI.Windows.Visualizations/Utilities/PeakRenderer.cs b/FoxTunes.UI.Windows.Visualizations/Utilities/PeakRenderer.cs index d2bfa69f8..1e95b8cf1 100644 --- a/FoxTunes.UI.Windows.Visualizations/Utilities/PeakRenderer.cs +++ b/FoxTunes.UI.Windows.Visualizations/Utilities/PeakRenderer.cs @@ -253,9 +253,9 @@ protected virtual Task Render(PeakRendererData data) catch { #if DEBUG - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render peaks: {0}", e.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render peaks: {0}", e.Message); #else - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render peaks, disabling: {0}", e.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render peaks, disabling: {0}", e.Message); success = false; #endif } @@ -309,10 +309,10 @@ protected override void OnUpdateData(object sender, ElapsedEventArgs e) catch { #if DEBUG - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update peak data: {0}", exception.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update peak data: {0}", exception.Message); this.BeginUpdateData(); #else - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update peak data, disabling: {0}", exception.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update peak data, disabling: {0}", exception.Message); #endif } } @@ -334,10 +334,10 @@ protected override async void OnUpdateDisplay(object sender, ElapsedEventArgs e) catch { #if DEBUG - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render peak data: {0}", exception.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render peak data: {0}", exception.Message); this.BeginUpdateData(); #else - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render peak data, disabling: {0}", exception.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render peak data, disabling: {0}", exception.Message); #endif } } diff --git a/FoxTunes.UI.Windows.Visualizations/Utilities/SpectrogramRenderer.cs b/FoxTunes.UI.Windows.Visualizations/Utilities/SpectrogramRenderer.cs index a54d1b373..0d6616944 100644 --- a/FoxTunes.UI.Windows.Visualizations/Utilities/SpectrogramRenderer.cs +++ b/FoxTunes.UI.Windows.Visualizations/Utilities/SpectrogramRenderer.cs @@ -137,9 +137,9 @@ protected override WriteableBitmap CreateBitmap(int width, int height) } } } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Error, "Failed to restore spectrogram from history: {0}", e.Message); + Logger.Write(this, LogLevel.Error, "Failed to restore spectrogram from history: {0}", e.Message); } } else @@ -196,12 +196,12 @@ protected virtual Task Render(SpectrogramRendererData data) success = true; } } - catch + catch (Exception e) { #if DEBUG - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrogram: {0}", e.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrogram: {0}", e.Message); #else - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrogram, disabling: {0}", e.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrogram, disabling: {0}", e.Message); success = false; #endif } @@ -248,13 +248,13 @@ protected override void OnUpdateData(object sender, ElapsedEventArgs e) this.BeginUpdateData(); } - catch + catch (Exception exception) { #if DEBUG - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update spectrogram data: {0}", exception.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update spectrogram data: {0}", exception.Message); this.BeginUpdateData(); #else - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update spectrogram data, disabling: {0}", exception.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update spectrogram data, disabling: {0}", exception.Message); #endif } } @@ -273,13 +273,13 @@ protected override async void OnUpdateDisplay(object sender, ElapsedEventArgs e) this.BeginUpdateDisplay(); } - catch + catch (Exception exception) { #if DEBUG - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrogram data: {0}", exception.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrogram data: {0}", exception.Message); this.BeginUpdateData(); #else - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrogram data, disabling: {0}", exception.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrogram data, disabling: {0}", exception.Message); #endif } } diff --git a/FoxTunes.UI.Windows.Visualizations/Utilities/SpectrumRenderer.cs b/FoxTunes.UI.Windows.Visualizations/Utilities/SpectrumRenderer.cs index 6287e5246..49e121b5e 100644 --- a/FoxTunes.UI.Windows.Visualizations/Utilities/SpectrumRenderer.cs +++ b/FoxTunes.UI.Windows.Visualizations/Utilities/SpectrumRenderer.cs @@ -201,12 +201,12 @@ protected virtual Task Render(SpectrumRendererData data) Render(ref info, data); success = true; } - catch + catch (Exception e) { #if DEBUG - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrum: {0}", e.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrum: {0}", e.Message); #else - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrum, disabling: {0}", e.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrum, disabling: {0}", e.Message); success = false; #endif } @@ -257,13 +257,13 @@ protected override void OnUpdateData(object sender, ElapsedEventArgs e) this.BeginUpdateData(); } - catch + catch (Exception exception) { #if DEBUG - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update spectrum data: {0}", exception.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update spectrum data: {0}", exception.Message); this.BeginUpdateData(); #else - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update spectrum data, disabling: {0}", exception.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update spectrum data, disabling: {0}", exception.Message); #endif } } @@ -282,13 +282,13 @@ protected override async void OnUpdateDisplay(object sender, ElapsedEventArgs e) this.BeginUpdateDisplay(); } - catch + catch (Exception exception) { #if DEBUG - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrum data: {0}", exception.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrum data: {0}", exception.Message); this.BeginUpdateData(); #else - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrum data, disabling: {0}", exception.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render spectrum data, disabling: {0}", exception.Message); #endif } } diff --git a/FoxTunes.UI.Windows.WaveBar/Utilities/BandedWaveFormCache.cs b/FoxTunes.UI.Windows.WaveBar/Utilities/BandedWaveFormCache.cs index b03083531..5d449d5e2 100644 --- a/FoxTunes.UI.Windows.WaveBar/Utilities/BandedWaveFormCache.cs +++ b/FoxTunes.UI.Windows.WaveBar/Utilities/BandedWaveFormCache.cs @@ -78,7 +78,7 @@ protected virtual bool TryLoad(string fileName, out BandedWaveFormGenerator.Wave } catch { - //Logger.Write(this, LogLevel.Warn, "Failed to load wave form from file \"{0}\": {1}", fileName, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to load wave form from file \"{0}\": {1}", fileName, e.Message); } data = null; return false; @@ -107,9 +107,9 @@ protected virtual void Save(string id, BandedWaveFormGenerator.WaveFormGenerator stream.Seek(0, SeekOrigin.Begin); } } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to save wave form: {0}", e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to save wave form: {0}", e.Message); } } @@ -143,7 +143,7 @@ public static void Cleanup() } catch { - //Logger.Write(typeof(WaveFormCache), LogLevel.Warn, "Failed to clear caches: {0}", e.Message); + Logger.Write(typeof(WaveFormCache), LogLevel.Warn, "Failed to clear caches: {0}", e.Message); } } diff --git a/FoxTunes.UI.Windows.WaveBar/Utilities/BandedWaveFormGenerator.cs b/FoxTunes.UI.Windows.WaveBar/Utilities/BandedWaveFormGenerator.cs index ca1bffc32..d68b8dffb 100644 --- a/FoxTunes.UI.Windows.WaveBar/Utilities/BandedWaveFormGenerator.cs +++ b/FoxTunes.UI.Windows.WaveBar/Utilities/BandedWaveFormGenerator.cs @@ -95,7 +95,7 @@ protected virtual void Populate(IOutputStream stream, WaveFormGeneratorData data { if (duplicated == null) { - //Logger.Write(this, LogLevel.Warn, "Failed to duplicate stream for file \"{0}\", cannot generate.", stream.FileName); + Logger.Write(this, LogLevel.Warn, "Failed to duplicate stream for file \"{0}\", cannot generate.", stream.FileName); return; } var dataSource = this.DataSourceFactory.Create(duplicated); @@ -105,7 +105,7 @@ protected virtual void Populate(IOutputStream stream, WaveFormGeneratorData data if (data.Position < data.Capacity) { - //Logger.Write(this, LogLevel.Debug, "Wave form generation for file \"{0}\" failed to complete.", stream.FileName); + Logger.Write(this, LogLevel.Debug, "Wave form generation for file \"{0}\" failed to complete.", stream.FileName); this.Cache.Remove(stream, data.Resolution); return; } @@ -113,22 +113,22 @@ protected virtual void Populate(IOutputStream stream, WaveFormGeneratorData data if (data.CancellationToken.IsCancellationRequested) { - //Logger.Write(this, LogLevel.Debug, "Wave form generation for file \"{0}\" was cancelled.", stream.FileName); + Logger.Write(this, LogLevel.Debug, "Wave form generation for file \"{0}\" was cancelled.", stream.FileName); this.Cache.Remove(stream, data.Resolution); return; } data.Update(); - //Logger.Write(this, LogLevel.Debug, "Wave form generated for file \"{0}\" with {1} elements: Peak = {2:0.00}", stream.FileName, data.Capacity, data.Peak); + Logger.Write(this, LogLevel.Debug, "Wave form generated for file \"{0}\" with {1} elements: Peak = {2:0.00}", stream.FileName, data.Capacity, data.Peak); try { this.Cache.Save(stream, data); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to save wave form data for file \"{0}\": {1}", stream.FileName, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to save wave form data for file \"{0}\": {1}", stream.FileName, e.Message); } } diff --git a/FoxTunes.UI.Windows.WaveBar/Utilities/BandedWaveFormRenderer.cs b/FoxTunes.UI.Windows.WaveBar/Utilities/BandedWaveFormRenderer.cs index 13674351d..21d197ccc 100644 --- a/FoxTunes.UI.Windows.WaveBar/Utilities/BandedWaveFormRenderer.cs +++ b/FoxTunes.UI.Windows.WaveBar/Utilities/BandedWaveFormRenderer.cs @@ -251,7 +251,7 @@ public Task Render(WaveFormRendererData data) } catch { - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render wave form: {0}", e.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render wave form: {0}", e.Message); } finally { @@ -278,9 +278,9 @@ public void Update() rendererData ); } - catch + catch (Exception e) { - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update wave form data: {0}", e.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update wave form data: {0}", e.Message); return; } var task = this.Render(rendererData); diff --git a/FoxTunes.UI.Windows.WaveBar/Utilities/WaveFormCache.cs b/FoxTunes.UI.Windows.WaveBar/Utilities/WaveFormCache.cs index 8d4524897..16d93768e 100644 --- a/FoxTunes.UI.Windows.WaveBar/Utilities/WaveFormCache.cs +++ b/FoxTunes.UI.Windows.WaveBar/Utilities/WaveFormCache.cs @@ -77,9 +77,9 @@ protected virtual bool TryLoad(string fileName, out WaveFormGenerator.WaveFormGe return true; } } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to load wave form from file \"{0}\": {1}", fileName, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to load wave form from file \"{0}\": {1}", fileName, e.Message); } data = null; return false; @@ -108,9 +108,9 @@ protected virtual void Save(string id, WaveFormGenerator.WaveFormGeneratorData d stream.Seek(0, SeekOrigin.Begin); } } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to save wave form: {0}", e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to save wave form: {0}", e.Message); } } @@ -142,9 +142,9 @@ public static void Cleanup() } FileMetaDataStore.Clear(PREFIX); } - catch + catch (Exception e) { - //Logger.Write(typeof(WaveFormCache), LogLevel.Warn, "Failed to clear caches: {0}", e.Message); + Logger.Write(typeof(WaveFormCache), LogLevel.Warn, "Failed to clear caches: {0}", e.Message); } } diff --git a/FoxTunes.UI.Windows.WaveBar/Utilities/WaveFormGenerator.cs b/FoxTunes.UI.Windows.WaveBar/Utilities/WaveFormGenerator.cs index f73bb3c26..bd1001a05 100644 --- a/FoxTunes.UI.Windows.WaveBar/Utilities/WaveFormGenerator.cs +++ b/FoxTunes.UI.Windows.WaveBar/Utilities/WaveFormGenerator.cs @@ -71,18 +71,18 @@ protected virtual void Populate(IOutputStream stream, WaveFormGeneratorData data { if (duplicated == null) { - //Logger.Write(this, LogLevel.Warn, "Failed to duplicate stream for file \"{0}\", cannot generate.", stream.FileName); + Logger.Write(this, LogLevel.Warn, "Failed to duplicate stream for file \"{0}\", cannot generate.", stream.FileName); return; } var dataSource = this.Factory.Create(duplicated); switch (duplicated.Format) { case OutputStreamFormat.Short: - //Logger.Write(typeof(WaveFormGenerator), LogLevel.Debug, "Creating 16 bit wave form for file \"{0}\" with resolution of {1}ms", stream.FileName, data.Resolution); + Logger.Write(typeof(WaveFormGenerator), LogLevel.Debug, "Creating 16 bit wave form for file \"{0}\" with resolution of {1}ms", stream.FileName, data.Resolution); PopulateShort(this.Output, dataSource, data); break; case OutputStreamFormat.Float: - //Logger.Write(typeof(WaveFormGenerator), LogLevel.Debug, "Creating 32 bit wave form for file \"{0}\" with resolution of {1}ms", stream.FileName, data.Resolution); + Logger.Write(typeof(WaveFormGenerator), LogLevel.Debug, "Creating 32 bit wave form for file \"{0}\" with resolution of {1}ms", stream.FileName, data.Resolution); PopulateFloat(this.Output, dataSource, data); break; default: @@ -90,7 +90,7 @@ protected virtual void Populate(IOutputStream stream, WaveFormGeneratorData data } if (data.Position < data.Capacity) { - //Logger.Write(typeof(WaveFormGenerator), LogLevel.Debug, "Wave form generation for file \"{0}\" failed to complete.", stream.FileName); + Logger.Write(typeof(WaveFormGenerator), LogLevel.Debug, "Wave form generation for file \"{0}\" failed to complete.", stream.FileName); this.Cache.Remove(stream, data.Resolution); return; } @@ -98,22 +98,22 @@ protected virtual void Populate(IOutputStream stream, WaveFormGeneratorData data if (data.CancellationToken.IsCancellationRequested) { - //Logger.Write(typeof(WaveFormGenerator), LogLevel.Debug, "Wave form generation for file \"{0}\" was cancelled.", stream.FileName); + Logger.Write(typeof(WaveFormGenerator), LogLevel.Debug, "Wave form generation for file \"{0}\" was cancelled.", stream.FileName); this.Cache.Remove(stream, data.Resolution); return; } data.Update(); - //Logger.Write(typeof(WaveFormGenerator), LogLevel.Debug, "Wave form generated for file \"{0}\" with {1} elements: Peak = {2:0.00}", stream.FileName, data.Capacity, data.Peak); + Logger.Write(typeof(WaveFormGenerator), LogLevel.Debug, "Wave form generated for file \"{0}\" with {1} elements: Peak = {2:0.00}", stream.FileName, data.Capacity, data.Peak); try { this.Cache.Save(stream, data); } - catch + catch (Exception e) { - //Logger.Write(typeof(WaveFormGenerator), LogLevel.Warn, "Failed to save wave form data for file \"{0}\": {1}", stream.FileName, e.Message); + Logger.Write(typeof(WaveFormGenerator), LogLevel.Warn, "Failed to save wave form data for file \"{0}\": {1}", stream.FileName, e.Message); } } diff --git a/FoxTunes.UI.Windows.WaveBar/Utilities/WaveFormRenderer.cs b/FoxTunes.UI.Windows.WaveBar/Utilities/WaveFormRenderer.cs index cd0a00cf5..c5f396542 100644 --- a/FoxTunes.UI.Windows.WaveBar/Utilities/WaveFormRenderer.cs +++ b/FoxTunes.UI.Windows.WaveBar/Utilities/WaveFormRenderer.cs @@ -261,9 +261,9 @@ public Task Render(WaveFormRendererData data) { Render(ref info, data); } - catch + catch (Exception e) { - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render wave form: {0}", e.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to render wave form: {0}", e.Message); } finally { @@ -290,9 +290,9 @@ public void Update() rendererData ); } - catch + catch (Exception e) { - //Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update wave form data: {0}", e.Message); + Logger.Write(this.GetType(), LogLevel.Warn, "Failed to update wave form data: {0}", e.Message); return; } var task = this.Render(rendererData); diff --git a/FoxTunes.UI.Windows/Behaviours/InputManagerBehaviour.cs b/FoxTunes.UI.Windows/Behaviours/InputManagerBehaviour.cs index 4e2a53d4f..857c748c4 100644 --- a/FoxTunes.UI.Windows/Behaviours/InputManagerBehaviour.cs +++ b/FoxTunes.UI.Windows/Behaviours/InputManagerBehaviour.cs @@ -183,7 +183,7 @@ protected virtual void OnDisposing() ~InputManagerBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows/Behaviours/KeyBindingsBehaviour.cs b/FoxTunes.UI.Windows/Behaviours/KeyBindingsBehaviour.cs index c18d7fff4..3e9e98913 100644 --- a/FoxTunes.UI.Windows/Behaviours/KeyBindingsBehaviour.cs +++ b/FoxTunes.UI.Windows/Behaviours/KeyBindingsBehaviour.cs @@ -84,7 +84,7 @@ protected virtual void AddCommandBinding(Window window, string id, Key key, Modi var binding = new InputBinding(command, gesture); this.Bindings.GetOrAdd(window, () => new Dictionary(StringComparer.OrdinalIgnoreCase))[id] = binding; window.InputBindings.Add(binding); - //Logger.Write(this, LogLevel.Debug, "AddCommandBinding: {0}/{1} => {2}", window.GetType().Name, window.Title, id); + Logger.Write(this, LogLevel.Debug, "AddCommandBinding: {0}/{1} => {2}", window.GetType().Name, window.Title, id); } catch (Exception e) { @@ -140,11 +140,11 @@ protected virtual void RemoveCommandBinding(Window window, string id, InputBindi try { window.InputBindings.Remove(binding); - //Logger.Write(this, LogLevel.Debug, "RemoveCommandBinding: {0}/{1} => {2}", window.GetType().Name, window.Title, id); + Logger.Write(this, LogLevel.Debug, "RemoveCommandBinding: {0}/{1} => {2}", window.GetType().Name, window.Title, id); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to remove command binding {0}: {1}", id, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to remove command binding {0}: {1}", id, e.Message); } } @@ -202,7 +202,7 @@ protected virtual void OnDisposing() ~KeyBindingsBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows/Behaviours/KeyBindingsBehaviourBase.cs b/FoxTunes.UI.Windows/Behaviours/KeyBindingsBehaviourBase.cs index 161ba23ab..734eb244a 100644 --- a/FoxTunes.UI.Windows/Behaviours/KeyBindingsBehaviourBase.cs +++ b/FoxTunes.UI.Windows/Behaviours/KeyBindingsBehaviourBase.cs @@ -82,7 +82,7 @@ protected virtual void OnDisposing() ~KeyBindingsBehaviourBase() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows/Behaviours/PlaylistColumnsBehaviour.cs b/FoxTunes.UI.Windows/Behaviours/PlaylistColumnsBehaviour.cs index ea8f33aac..2416fdfea 100644 --- a/FoxTunes.UI.Windows/Behaviours/PlaylistColumnsBehaviour.cs +++ b/FoxTunes.UI.Windows/Behaviours/PlaylistColumnsBehaviour.cs @@ -122,12 +122,12 @@ protected virtual void Update(PlaylistColumn column, bool notify) { this.Columns.AddOrUpdate(column, notify); this.Debouncer.Exec(this.Update); - //Logger.Write(this, LogLevel.Debug, "Queued update for column {0} => {1}.", column.Id, column.Name); + Logger.Write(this, LogLevel.Debug, "Queued update for column {0} => {1}.", column.Id, column.Name); } protected virtual async Task Update() { - //Logger.Write(this, LogLevel.Debug, "Updating {0} columns...", this.Columns.Count); + Logger.Write(this, LogLevel.Debug, "Updating {0} columns...", this.Columns.Count); var columns = new List(); using (var database = this.DatabaseFactory.Create()) { @@ -138,7 +138,7 @@ protected virtual async Task Update() var set = database.Set(transaction); foreach (var pair in this.Columns) { - //Logger.Write(this, LogLevel.Debug, "Updating column {0} => {1}.", pair.Key.Id, pair.Key.Name); + Logger.Write(this, LogLevel.Debug, "Updating column {0} => {1}.", pair.Key.Id, pair.Key.Name); await set.AddOrUpdateAsync(pair.Key).ConfigureAwait(false); if (pair.Value) { @@ -192,7 +192,7 @@ protected virtual void OnDisposing() ~PlaylistColumnsBehaviour() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows/Behaviours/PlaylistSortingBehaviour.cs b/FoxTunes.UI.Windows/Behaviours/PlaylistSortingBehaviour.cs index f90b32e14..ccf1a9e03 100644 --- a/FoxTunes.UI.Windows/Behaviours/PlaylistSortingBehaviour.cs +++ b/FoxTunes.UI.Windows/Behaviours/PlaylistSortingBehaviour.cs @@ -98,12 +98,12 @@ public async Task Sort(Playlist playlist, PlaylistColumn playlistColumn) var changes = await this.PlaylistManager.Sort(playlist, playlistColumn, descending).ConfigureAwait(false); if (changes == 0) { - //Logger.Write(this, LogLevel.Debug, "Playlist was already sorted, reversing direction."); + Logger.Write(this, LogLevel.Debug, "Playlist was already sorted, reversing direction."); descending = !descending; changes = await this.PlaylistManager.Sort(playlist, playlistColumn, descending).ConfigureAwait(false); if (changes == 0) { - //Logger.Write(this, LogLevel.Debug, "Playlist was already sorted, all values are equal."); + Logger.Write(this, LogLevel.Debug, "Playlist was already sorted, all values are equal."); } } if (!descending) @@ -145,7 +145,7 @@ protected virtual void OnDisposing() ~PlaylistSortingBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows/Behaviours/ReportBehaviour.cs b/FoxTunes.UI.Windows/Behaviours/ReportBehaviour.cs index b52e75874..4dd92e500 100644 --- a/FoxTunes.UI.Windows/Behaviours/ReportBehaviour.cs +++ b/FoxTunes.UI.Windows/Behaviours/ReportBehaviour.cs @@ -65,7 +65,7 @@ protected virtual void OnDisposing() ~ReportBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows/Behaviours/TrayIconBehaviour.cs b/FoxTunes.UI.Windows/Behaviours/TrayIconBehaviour.cs index 1352dfd08..51757c8e5 100644 --- a/FoxTunes.UI.Windows/Behaviours/TrayIconBehaviour.cs +++ b/FoxTunes.UI.Windows/Behaviours/TrayIconBehaviour.cs @@ -127,7 +127,7 @@ protected virtual void AddWindowHooks(Window window) { window.StateChanged += this.OnStateChanged; window.Closing += this.OnClosing; - //Logger.Write(this, LogLevel.Debug, "Registered window events: {0}/{1}", window.GetType().Name, window.Title); + Logger.Write(this, LogLevel.Debug, "Registered window events: {0}/{1}", window.GetType().Name, window.Title); } protected virtual void RemoveWindowHooks() @@ -145,7 +145,7 @@ protected virtual void RemoveWindowHooks(Window window) { window.StateChanged -= this.OnStateChanged; window.Closing -= this.OnClosing; - //Logger.Write(this, LogLevel.Debug, "Unregistered window events: {0}/{1}", window.GetType().Name, window.Title); + Logger.Write(this, LogLevel.Debug, "Unregistered window events: {0}/{1}", window.GetType().Name, window.Title); } protected virtual void OnWindowCreated(object sender, EventArgs e) @@ -173,7 +173,7 @@ protected virtual void Enable() { this.NotifyIcon.MessageSink.MouseLeftButtonUp += this.OnMouseLeftButtonUp; this.NotifyIcon.MessageSink.MouseRightButtonUp += this.OnMouseRightButtonUp; - //Logger.Write(this, LogLevel.Debug, "Registered message sink events."); + Logger.Write(this, LogLevel.Debug, "Registered message sink events."); } this.AddWindowHooks(); } @@ -188,7 +188,7 @@ protected virtual void Disable() { this.NotifyIcon.MessageSink.MouseLeftButtonUp -= this.OnMouseLeftButtonUp; this.NotifyIcon.MessageSink.MouseRightButtonUp -= this.OnMouseRightButtonUp; - //Logger.Write(this, LogLevel.Debug, "Unregistered message sink events."); + Logger.Write(this, LogLevel.Debug, "Unregistered message sink events."); } } this.RemoveWindowHooks(); @@ -196,7 +196,7 @@ protected virtual void Disable() protected virtual void OnShuttingDown(object sender, EventArgs e) { - //Logger.Write(this, LogLevel.Debug, "Shutdown signal recieved."); + Logger.Write(this, LogLevel.Debug, "Shutdown signal recieved."); this.Disable(); } @@ -205,13 +205,13 @@ protected virtual void OnMouseLeftButtonUp(object sender, EventArgs e) var window = this.Window ?? Windows.ActiveWindow; if (window == null) { - //Logger.Write(this, LogLevel.Warn, "No window to restore."); + Logger.Write(this, LogLevel.Warn, "No window to restore."); return; } this.Window = null; var task = Windows.Invoke(() => { - //Logger.Write(this, LogLevel.Debug, "Restoring window: {0}/{1}", window.GetType().Name, window.Title); + Logger.Write(this, LogLevel.Debug, "Restoring window: {0}/{1}", window.GetType().Name, window.Title); window.Show(); if (window.WindowState == WindowState.Minimized) { @@ -261,7 +261,7 @@ protected virtual void OnStateChanged(object sender, EventArgs e) { if (window.WindowState == WindowState.Minimized) { - //Logger.Write(this, LogLevel.Debug, "MinimizeToTray: Hiding window: {0}/{1}", window.GetType().Name, window.Title); + Logger.Write(this, LogLevel.Debug, "MinimizeToTray: Hiding window: {0}/{1}", window.GetType().Name, window.Title); window.Hide(); this.Window = window; return; @@ -278,7 +278,7 @@ protected virtual void OnClosing(object sender, CancelEventArgs e) if (sender is Window window) { e.Cancel = true; - //Logger.Write(this, LogLevel.Debug, "CloseToTray: Hiding window: {0}/{1}", window.GetType().Name, window.Title); + Logger.Write(this, LogLevel.Debug, "CloseToTray: Hiding window: {0}/{1}", window.GetType().Name, window.Title); window.Hide(); this.Window = window; return; @@ -349,7 +349,7 @@ protected virtual void OnDisposing() ~TrayIconBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows/Behaviours/WindowBlurProvider.cs b/FoxTunes.UI.Windows/Behaviours/WindowBlurProvider.cs index f055f43a7..4d96a0940 100644 --- a/FoxTunes.UI.Windows/Behaviours/WindowBlurProvider.cs +++ b/FoxTunes.UI.Windows/Behaviours/WindowBlurProvider.cs @@ -112,7 +112,7 @@ protected virtual void OnDisposing() ~WindowBlurProvider() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows/Behaviours/WindowStateBehaviour.cs b/FoxTunes.UI.Windows/Behaviours/WindowStateBehaviour.cs index 76af8109b..d54458ed3 100644 --- a/FoxTunes.UI.Windows/Behaviours/WindowStateBehaviour.cs +++ b/FoxTunes.UI.Windows/Behaviours/WindowStateBehaviour.cs @@ -101,7 +101,7 @@ protected virtual void OnDisposing() ~WindowStateBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); @@ -237,7 +237,7 @@ protected virtual void OnDisposing() ~MinMaxBehaviour() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows/Behaviours/WindowTitleBehaviour.cs b/FoxTunes.UI.Windows/Behaviours/WindowTitleBehaviour.cs index 5439062aa..e3d222506 100644 --- a/FoxTunes.UI.Windows/Behaviours/WindowTitleBehaviour.cs +++ b/FoxTunes.UI.Windows/Behaviours/WindowTitleBehaviour.cs @@ -112,7 +112,7 @@ protected virtual void SetWindowTitle(string title) protected virtual void SetWindowTitle(Window window, string title) { - //Logger.Write(this, LogLevel.Debug, "Setting window title {0}: {1}", window.GetType().Name, title); + Logger.Write(this, LogLevel.Debug, "Setting window title {0}: {1}", window.GetType().Name, title); window.Title = title; } @@ -157,7 +157,7 @@ protected virtual void OnDisposing() ~WindowTitleBehaviour() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows/Extensions/Button_Command.cs b/FoxTunes.UI.Windows/Extensions/Button_Command.cs index b3ae35f4a..dc79e73a0 100644 --- a/FoxTunes.UI.Windows/Extensions/Button_Command.cs +++ b/FoxTunes.UI.Windows/Extensions/Button_Command.cs @@ -173,7 +173,7 @@ protected virtual ICommand WrapCommand(ICommand command) } catch (Exception e) { - //Logger.Write(typeof(CommandBehaviour), LogLevel.Warn, "Failed to execute command: {0}", e.Message); + Logger.Write(typeof(CommandBehaviour), LogLevel.Warn, "Failed to execute command: {0}", e.Message); var task = ErrorEmitter.Send(this, string.Format("Failed to execute command: {0}", e.Message), e); } }); diff --git a/FoxTunes.UI.Windows/Extensions/GridView_ColumnHeaderContainerStyle.cs b/FoxTunes.UI.Windows/Extensions/GridView_ColumnHeaderContainerStyle.cs index 89b37d033..49bf4b170 100644 --- a/FoxTunes.UI.Windows/Extensions/GridView_ColumnHeaderContainerStyle.cs +++ b/FoxTunes.UI.Windows/Extensions/GridView_ColumnHeaderContainerStyle.cs @@ -76,7 +76,7 @@ protected override void Apply() { if (Windows.ActiveWindow == null) { - //Logger.Write(typeof(ColumnHeaderContainerStyleBehaviour), LogLevel.Warn, "Could not apply, no active window."); + Logger.Write(typeof(ColumnHeaderContainerStyleBehaviour), LogLevel.Warn, "Could not apply, no active window."); return; } Windows.Registrations.RemoveCreated( diff --git a/FoxTunes.UI.Windows/Extensions/ListView_AutoSizeColumns.cs b/FoxTunes.UI.Windows/Extensions/ListView_AutoSizeColumns.cs index 6ad47355d..350cdfb10 100644 --- a/FoxTunes.UI.Windows/Extensions/ListView_AutoSizeColumns.cs +++ b/FoxTunes.UI.Windows/Extensions/ListView_AutoSizeColumns.cs @@ -229,7 +229,7 @@ protected virtual void OnDisposing() ~AutoSizeColumn() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows/Extensions/TabControl_DragOverSelection.cs b/FoxTunes.UI.Windows/Extensions/TabControl_DragOverSelection.cs index 8b0e990bd..31800cb9c 100644 --- a/FoxTunes.UI.Windows/Extensions/TabControl_DragOverSelection.cs +++ b/FoxTunes.UI.Windows/Extensions/TabControl_DragOverSelection.cs @@ -81,12 +81,12 @@ protected virtual void OnDragOver(object sender, DragEventArgs e) if (tabItem == null) { //This message removed as it fires a lot. - ////Logger.Write(typeof(DragOverSelectionBehaviour), LogLevel.Trace, "No tab under cursor, cancelling selection."); + //Logger.Write(typeof(DragOverSelectionBehaviour), LogLevel.Trace, "No tab under cursor, cancelling selection."); this.Debouncer.Cancel(this.UpdateSelection); } else if (!object.ReferenceEquals(this.TabItem, tabItem)) { - //Logger.Write(typeof(DragOverSelectionBehaviour), LogLevel.Trace, "Tab appeared \"{0}\" under cursor, will select in {1}ms.", tabItem.Header, TIMEOUT.TotalMilliseconds); + Logger.Write(typeof(DragOverSelectionBehaviour), LogLevel.Trace, "Tab appeared \"{0}\" under cursor, will select in {1}ms.", tabItem.Header, TIMEOUT.TotalMilliseconds); this.Debouncer.Exec(this.UpdateSelection); } this.TabItem = tabItem; @@ -100,7 +100,7 @@ protected virtual void UpdateSelection() { return; } - //Logger.Write(typeof(DragOverSelectionBehaviour), LogLevel.Trace, "Selecting tab \"{0}\".", this.TabItem.Header); + Logger.Write(typeof(DragOverSelectionBehaviour), LogLevel.Trace, "Selecting tab \"{0}\".", this.TabItem.Header); this.TabItem.IsSelected = true; }); } diff --git a/FoxTunes.UI.Windows/Extensions/UIBehaviour.cs b/FoxTunes.UI.Windows/Extensions/UIBehaviour.cs index 30faa6fc3..c30840496 100644 --- a/FoxTunes.UI.Windows/Extensions/UIBehaviour.cs +++ b/FoxTunes.UI.Windows/Extensions/UIBehaviour.cs @@ -76,7 +76,7 @@ protected virtual void OnDisposing() ~UIBehaviour() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); @@ -89,21 +89,21 @@ protected virtual void OnDisposing() public static void Shutdown() { - //Logger.Write(typeof(UIBehaviour), LogLevel.Debug, "Shutting down.."); + Logger.Write(typeof(UIBehaviour), LogLevel.Debug, "Shutting down.."); foreach (var instance in Active) { try { instance.Dispose(); } - catch + catch (Exception e) { - //Logger.Write(typeof(UIBehaviour), LogLevel.Warn, "Instance failed to dispose: {0}", e.Message); + Logger.Write(typeof(UIBehaviour), LogLevel.Warn, "Instance failed to dispose: {0}", e.Message); } } if (Active.Any()) { - //Logger.Write(typeof(UIBehaviour), LogLevel.Warn, "Some instances failed to disposed."); + Logger.Write(typeof(UIBehaviour), LogLevel.Warn, "Some instances failed to disposed."); } } } diff --git a/FoxTunes.UI.Windows/Main.cs b/FoxTunes.UI.Windows/Main.cs index b22803cfe..c5d48e354 100644 --- a/FoxTunes.UI.Windows/Main.cs +++ b/FoxTunes.UI.Windows/Main.cs @@ -8,7 +8,15 @@ namespace FoxTunes { public class Main : ContentControl, IDisposable { - + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public Main() { LayoutManager.Instance.ProviderChanged += this.OnProviderChanged; @@ -77,7 +85,7 @@ protected virtual void OnDisposing() ~Main() { - //Logger.Write(typeof(Main), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(typeof(Main), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows/StringResourceReader.cs b/FoxTunes.UI.Windows/StringResourceReader.cs index a1f14966b..94024a699 100644 --- a/FoxTunes.UI.Windows/StringResourceReader.cs +++ b/FoxTunes.UI.Windows/StringResourceReader.cs @@ -8,6 +8,14 @@ namespace FoxTunes { public static class StringResourceReader { + private static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + public static readonly ConcurrentDictionary ResourceManagers = new ConcurrentDictionary(); public static string GetString(Type type, string name) @@ -20,14 +28,14 @@ public static string GetString(Assembly assembly, Type type, string name) var resourceManager = GetResourceManager(assembly); if (resourceManager == null) { - //Logger.Write(typeof(StringResourceReader), LogLevel.Warn, "Failed to determine ResourceManager for type \"{0}\".", type.FullName); + Logger.Write(typeof(StringResourceReader), LogLevel.Warn, "Failed to determine ResourceManager for type \"{0}\".", type.FullName); return null; } var result = resourceManager.GetString(string.Format("{0}.{1}", type.Name, name)); //TODO: We currently have a lot of missing Description strings so don't bother warning for now. //if (string.IsNullOrEmpty(result)) //{ - // //Logger.Write(typeof(StringResourceReader), LogLevel.Warn, "Failed to locate resource string {0}.{1}.", type.Name, name); + // Logger.Write(typeof(StringResourceReader), LogLevel.Warn, "Failed to locate resource string {0}.{1}.", type.Name, name); //} return result; } @@ -54,9 +62,9 @@ public static ResourceManager GetResourceManager(Assembly assembly) } return property.GetValue(null, null) as ResourceManager; } - catch + catch (Exception e) { - //Logger.Write(typeof(StringResourceReader), LogLevel.Error, "Failed to locate Strings ResourceManager in assembly \"{0}\": {1}", assembly.FullName, e.Message); + Logger.Write(typeof(StringResourceReader), LogLevel.Error, "Failed to locate Strings ResourceManager in assembly \"{0}\": {1}", assembly.FullName, e.Message); return null; } }); diff --git a/FoxTunes.UI.Windows/TabControl.cs b/FoxTunes.UI.Windows/TabControl.cs index 41c030722..689d14655 100644 --- a/FoxTunes.UI.Windows/TabControl.cs +++ b/FoxTunes.UI.Windows/TabControl.cs @@ -13,7 +13,15 @@ namespace FoxTunes { public class TabControl : Control, IDisposable { - public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register( + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register( "ItemsSource", typeof(IEnumerable), typeof(TabControl), @@ -470,7 +478,7 @@ protected virtual void OnDisposing() ~TabControl() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows/UIComponentBase.cs b/FoxTunes.UI.Windows/UIComponentBase.cs index 5da6cc408..97cbf50e1 100644 --- a/FoxTunes.UI.Windows/UIComponentBase.cs +++ b/FoxTunes.UI.Windows/UIComponentBase.cs @@ -10,7 +10,15 @@ namespace FoxTunes { public abstract class UIComponentBase : UserControl, IUIComponent, IObservable, IDisposable { - public static readonly DependencyProperty IsComponentEnabledProperty = DependencyProperty.Register( + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public static readonly DependencyProperty IsComponentEnabledProperty = DependencyProperty.Register( "IsComponentEnabled", typeof(bool), typeof(UIComponentBase), diff --git a/FoxTunes.UI.Windows/Utilities/ArtworkBrushFactory.cs b/FoxTunes.UI.Windows/Utilities/ArtworkBrushFactory.cs index 6a91157e7..6a0bc4bb6 100644 --- a/FoxTunes.UI.Windows/Utilities/ArtworkBrushFactory.cs +++ b/FoxTunes.UI.Windows/Utilities/ArtworkBrushFactory.cs @@ -57,7 +57,7 @@ protected virtual Task OnSignal(object sender, ISignal signal) this.OnMetaDataUpdated(signal.State as MetaDataUpdatedSignalState); break; case CommonSignals.ImagesUpdated: - //Logger.Write(this, LogLevel.Debug, "Images were updated, resetting cache."); + Logger.Write(this, LogLevel.Debug, "Images were updated, resetting cache."); this.Reset(); break; } @@ -108,7 +108,7 @@ public AsyncResult Create(string fileName, int width, int height) protected virtual ImageBrush Create(string fileName, int width, int height, bool cache) { - //Logger.Write(this, LogLevel.Debug, "Creating brush: {0}x{1}", width, height); + Logger.Write(this, LogLevel.Debug, "Creating brush: {0}x{1}", width, height); var source = this.ImageLoader.Load( fileName, width, @@ -132,7 +132,7 @@ protected virtual ImageBrush Create(string fileName, int width, int height, bool protected virtual void CreateTaskFactory(int threads) { - //Logger.Write(this, LogLevel.Debug, "Creating task factory for {0} threads.", threads); + Logger.Write(this, LogLevel.Debug, "Creating task factory for {0} threads.", threads); this.Factory = new TaskFactory(new TaskScheduler(new ParallelOptions() { MaxDegreeOfParallelism = threads @@ -141,7 +141,7 @@ protected virtual void CreateTaskFactory(int threads) protected virtual void CreateCache(int capacity) { - //Logger.Write(this, LogLevel.Debug, "Creating cache for {0} items.", capacity); + Logger.Write(this, LogLevel.Debug, "Creating cache for {0} items.", capacity); this.Store = new ImageBrushCache(capacity); } @@ -154,7 +154,7 @@ protected virtual void Reset(IEnumerable names) return; } } - //Logger.Write(this, LogLevel.Debug, "Meta data was updated, resetting cache."); + Logger.Write(this, LogLevel.Debug, "Meta data was updated, resetting cache."); this.Reset(); } @@ -191,7 +191,7 @@ protected virtual void OnDisposing() ~ArtworkBrushFactory() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows/Utilities/ArtworkPlaceholderBrushFactory.cs b/FoxTunes.UI.Windows/Utilities/ArtworkPlaceholderBrushFactory.cs index c69ac5d3e..bd8ed09ee 100644 --- a/FoxTunes.UI.Windows/Utilities/ArtworkPlaceholderBrushFactory.cs +++ b/FoxTunes.UI.Windows/Utilities/ArtworkPlaceholderBrushFactory.cs @@ -30,7 +30,7 @@ public ImageBrush Create(int width, int height) protected virtual ImageBrush Create(int width, int height, bool cache) { - //Logger.Write(this, LogLevel.Debug, "Creating brush: {0}x{1}", width, height); + Logger.Write(this, LogLevel.Debug, "Creating brush: {0}x{1}", width, height); var source = ImageLoader.Load( this.ThemeLoader.Theme.Id, this.ThemeLoader.Theme.GetArtworkPlaceholder, @@ -64,7 +64,7 @@ public override void InitializeComponent(ICore core) protected virtual void OnThemeChanged(object sender, EventArgs e) { - //Logger.Write(this, LogLevel.Debug, "Theme was changed, resetting cache."); + Logger.Write(this, LogLevel.Debug, "Theme was changed, resetting cache."); this.Store.Clear(); } @@ -96,7 +96,7 @@ protected virtual void OnDisposing() ~ArtworkPlaceholderBrushFactory() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows/Utilities/ImageLoader.cs b/FoxTunes.UI.Windows/Utilities/ImageLoader.cs index ef008d1c9..1db592158 100644 --- a/FoxTunes.UI.Windows/Utilities/ImageLoader.cs +++ b/FoxTunes.UI.Windows/Utilities/ImageLoader.cs @@ -106,9 +106,9 @@ private ImageSource LoadCore(string fileName, int width, int height) } return source; } - catch + catch (Exception e) { - //Logger.Write(typeof(ImageLoader), LogLevel.Warn, "Failed to load image: {0}", e.Message); + Logger.Write(typeof(ImageLoader), LogLevel.Warn, "Failed to load image: {0}", e.Message); return null; } } @@ -148,9 +148,9 @@ public ImageSource LoadCore(Func factory, int width, int height) } return source; } - catch + catch (Exception e) { - //Logger.Write(typeof(ImageLoader), LogLevel.Warn, "Failed to load image: {0}", e.Message); + Logger.Write(typeof(ImageLoader), LogLevel.Warn, "Failed to load image: {0}", e.Message); return null; } } diff --git a/FoxTunes.UI.Windows/Utilities/ImageResizer.cs b/FoxTunes.UI.Windows/Utilities/ImageResizer.cs index 28a7fb478..7575a4f59 100644 --- a/FoxTunes.UI.Windows/Utilities/ImageResizer.cs +++ b/FoxTunes.UI.Windows/Utilities/ImageResizer.cs @@ -129,9 +129,9 @@ public void Clear() { FileMetaDataStore.Clear(PREFIX); } - catch + catch (Exception e) { - //Logger.Write(this, LogLevel.Warn, "Failed to clear storage \"{0}\": {1}", PREFIX, e.Message); + Logger.Write(this, LogLevel.Warn, "Failed to clear storage \"{0}\": {1}", PREFIX, e.Message); } finally { @@ -177,7 +177,7 @@ protected virtual void OnDisposing() ~ImageResizer() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows/Utilities/MetaDataBinding.cs b/FoxTunes.UI.Windows/Utilities/MetaDataBinding.cs index 0e129427a..97706ef6e 100644 --- a/FoxTunes.UI.Windows/Utilities/MetaDataBinding.cs +++ b/FoxTunes.UI.Windows/Utilities/MetaDataBinding.cs @@ -8,7 +8,15 @@ namespace FoxTunes { public abstract class MetaDataBinding : Binding, INotifyPropertyChanged, IValueConverter { - protected MetaDataBinding() + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + protected MetaDataBinding() { this.Converter = this; this.Formatter = new Lazy(() => FormatterFactory.Create(this.Format)); diff --git a/FoxTunes.UI.Windows/Utilities/PlaylistGridViewColumnFactory.cs b/FoxTunes.UI.Windows/Utilities/PlaylistGridViewColumnFactory.cs index 8b2cac9bf..dde3e954d 100644 --- a/FoxTunes.UI.Windows/Utilities/PlaylistGridViewColumnFactory.cs +++ b/FoxTunes.UI.Windows/Utilities/PlaylistGridViewColumnFactory.cs @@ -77,7 +77,7 @@ public PlaylistGridViewColumn Create(PlaylistColumn column) var provider = PlaylistColumnProviderManager.GetProvider(column.Plugin) as IUIPlaylistColumnProvider; if (provider == null) { - //Logger.Write(this, LogLevel.Warn, "Playlist column plugin \"{0}\" was not found, has it been uninstalled?", column.Plugin); + Logger.Write(this, LogLevel.Warn, "Playlist column plugin \"{0}\" was not found, has it been uninstalled?", column.Plugin); } else { @@ -200,7 +200,7 @@ protected virtual void OnDisposing() ~PlaylistGridViewColumnFactory() { - //Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this.GetType(), LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true); diff --git a/FoxTunes.UI.Windows/Utilities/RendererBase.cs b/FoxTunes.UI.Windows/Utilities/RendererBase.cs index cf217bc88..f6627c0d7 100644 --- a/FoxTunes.UI.Windows/Utilities/RendererBase.cs +++ b/FoxTunes.UI.Windows/Utilities/RendererBase.cs @@ -26,7 +26,15 @@ public abstract class RendererBase : FrameworkElement, IBaseComponent, IConfigur public const DispatcherPriority DISPATCHER_PRIORITY = DispatcherPriority.Render; - public static readonly Duration LockTimeout = new Duration(TimeSpan.FromMilliseconds(1)); + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + public static readonly Duration LockTimeout = new Duration(TimeSpan.FromMilliseconds(1)); public static readonly DependencyProperty BackgroundProperty = DependencyProperty.Register( "Background", diff --git a/FoxTunes.UI.Windows/Utilities/ScriptBinding.cs b/FoxTunes.UI.Windows/Utilities/ScriptBinding.cs index 106223271..31576d6fd 100644 --- a/FoxTunes.UI.Windows/Utilities/ScriptBinding.cs +++ b/FoxTunes.UI.Windows/Utilities/ScriptBinding.cs @@ -8,7 +8,15 @@ namespace FoxTunes { public abstract class ScriptBinding : Binding, INotifyPropertyChanged, IValueConverter { - protected ScriptBinding() + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + protected ScriptBinding() { this.Converter = this; } diff --git a/FoxTunes.UI.Windows/Utilities/VisualizationBase.cs b/FoxTunes.UI.Windows/Utilities/VisualizationBase.cs index e22a3da92..6e15a3a13 100644 --- a/FoxTunes.UI.Windows/Utilities/VisualizationBase.cs +++ b/FoxTunes.UI.Windows/Utilities/VisualizationBase.cs @@ -91,12 +91,12 @@ protected virtual void Update() } if (PlaybackStateNotifier.IsPlaying && !this.Enabled) { - //Logger.Write(this, LogLevel.Debug, "Playback was started, starting renderer."); + Logger.Write(this, LogLevel.Debug, "Playback was started, starting renderer."); this.Start(); } else if (!PlaybackStateNotifier.IsPlaying && this.Enabled) { - //Logger.Write(this, LogLevel.Debug, "Playback was stopped, stopping renderer."); + Logger.Write(this, LogLevel.Debug, "Playback was stopped, stopping renderer."); this.Stop(); } } diff --git a/FoxTunes.UI.Windows/Utilities/Windows.cs b/FoxTunes.UI.Windows/Utilities/Windows.cs index cca59c622..175812871 100644 --- a/FoxTunes.UI.Windows/Utilities/Windows.cs +++ b/FoxTunes.UI.Windows/Utilities/Windows.cs @@ -11,6 +11,14 @@ namespace FoxTunes { public static class Windows { + private static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + public static bool IsShuttingDown { get; set; } public static readonly WindowRegistrations Registrations = new WindowRegistrations(); @@ -65,27 +73,27 @@ private static void OnActiveWindowChanged() public static Task TryShutdown() { - //Logger.Write(typeof(Windows), LogLevel.Debug, "Looking for main window.."); + Logger.Write(typeof(Windows), LogLevel.Debug, "Looking for main window.."); return Invoke(() => { var window = ActiveWindow; if (window != null && window.IsVisible) { - //Logger.Write(typeof(Windows), LogLevel.Debug, "Main window is visible, nothing to do: {0}/{1}", window.GetType().Name, window.Title); + Logger.Write(typeof(Windows), LogLevel.Debug, "Main window is visible, nothing to do: {0}/{1}", window.GetType().Name, window.Title); #if NET40 return TaskEx.FromResult(false); #else return Task.CompletedTask; #endif } - //Logger.Write(typeof(Windows), LogLevel.Debug, "No visible windows, shutting down.."); + Logger.Write(typeof(Windows), LogLevel.Debug, "No visible windows, shutting down.."); return Shutdown(); }); } public static Task Shutdown() { - //Logger.Write(typeof(Windows), LogLevel.Debug, "Shutting down.."); + Logger.Write(typeof(Windows), LogLevel.Debug, "Shutting down.."); IsShuttingDown = true; return Invoke(() => { @@ -95,12 +103,12 @@ public static Task Shutdown() } foreach (var window in Registrations.Windows) { - //Logger.Write(typeof(Windows), LogLevel.Debug, "Closing window: {0}/{1}", window.GetType().Name, window.Title); + Logger.Write(typeof(Windows), LogLevel.Debug, "Closing window: {0}/{1}", window.GetType().Name, window.Title); window.Close(); } foreach (var window in WindowBase.Active) { - //Logger.Write(typeof(Windows), LogLevel.Debug, "Closing window: {0}/{1}", window.GetType().Name, window.Title); + Logger.Write(typeof(Windows), LogLevel.Debug, "Closing window: {0}/{1}", window.GetType().Name, window.Title); window.Close(); } UIBehaviour.Shutdown(); @@ -141,7 +149,7 @@ public static Task Invoke(Action action, DispatcherPriority priority = Dispatche } else { - //Logger.Write(typeof(Windows), LogLevel.Warn, "Cannot Invoke, Dispatcher is not available."); + Logger.Write(typeof(Windows), LogLevel.Warn, "Cannot Invoke, Dispatcher is not available."); } #if NET40 return TaskEx.FromResult(false); @@ -182,7 +190,7 @@ public static Task Invoke(Func func) } else { - //Logger.Write(typeof(Windows), LogLevel.Warn, "Cannot Invoke, Dispatcher is not available."); + Logger.Write(typeof(Windows), LogLevel.Warn, "Cannot Invoke, Dispatcher is not available."); } #if NET40 return TaskEx.FromResult(false); @@ -269,7 +277,7 @@ public bool Add(WindowRegistration registration) protected virtual void OnAdded(WindowRegistration registration) { - //Logger.Write(this, LogLevel.Debug, "Window registered: {0}", registration.Id); + Logger.Write(this, LogLevel.Debug, "Window registered: {0}", registration.Id); var callbacks = default(ISet); if (this.Callbacks.TryGetValue(registration.Id, out callbacks)) { @@ -313,7 +321,7 @@ public Window Show(string id) { return default(Window); } - //Logger.Write(this, LogLevel.Debug, "Showing window: {0}", id); + Logger.Write(this, LogLevel.Debug, "Showing window: {0}", id); var window = registration.GetInstance(); if (!window.IsVisible) { @@ -331,7 +339,7 @@ public bool Hide(string id) { return false; } - //Logger.Write(this, LogLevel.Debug, "Hiding window: {0}", id); + Logger.Write(this, LogLevel.Debug, "Hiding window: {0}", id); window.Hide(); return true; } @@ -343,7 +351,7 @@ public bool Close(string id) { return false; } - //Logger.Write(this, LogLevel.Debug, "Closing window: {0}", id); + Logger.Write(this, LogLevel.Debug, "Closing window: {0}", id); window.Close(); return true; } @@ -530,9 +538,9 @@ protected virtual Func Create(Func factory) { return () => { - //Logger.Write(this, LogLevel.Debug, "Creating window: {0}", this.Id); + Logger.Write(this, LogLevel.Debug, "Creating window: {0}", this.Id); var window = factory(); - //Logger.Write(this, LogLevel.Debug, "Created window: {0}/{1}", window.GetType().Name, window.Title); + Logger.Write(this, LogLevel.Debug, "Created window: {0}/{1}", window.GetType().Name, window.Title); window.Owner = Windows.ActiveWindow; window.IsVisibleChanged += this.OnIsVisibleChanged; window.Closed += this.OnClosed; @@ -555,7 +563,7 @@ protected virtual void OnIsVisibleChanged(object sender, DependencyPropertyChang { if (this.Role == UserInterfaceWindowRole.Main) { - //Logger.Write(this, LogLevel.Debug, "Main window visiblity changed, refreshing active window: {0}", this.Id); + Logger.Write(this, LogLevel.Debug, "Main window visiblity changed, refreshing active window: {0}", this.Id); OnActiveWindowChanged(); } if (this.IsVisibleChanged != null) @@ -568,7 +576,7 @@ protected virtual void OnIsVisibleChanged(object sender, DependencyPropertyChang protected virtual void OnClosed(object sender, EventArgs e) { - //Logger.Write(this, LogLevel.Debug, "Window was closed: {0}", this.Id); + Logger.Write(this, LogLevel.Debug, "Window was closed: {0}", this.Id); this.Reset(); if (this.Closed != null) { @@ -576,7 +584,7 @@ protected virtual void OnClosed(object sender, EventArgs e) } if (this.Role == UserInterfaceWindowRole.Main) { - //Logger.Write(this, LogLevel.Debug, "Main window was closed, attempting shutdown: {0}", this.Id); + Logger.Write(this, LogLevel.Debug, "Main window was closed, attempting shutdown: {0}", this.Id); var task = TryShutdown(); } } diff --git a/FoxTunes.UI.Windows/ViewModel/AsyncCommand.cs b/FoxTunes.UI.Windows/ViewModel/AsyncCommand.cs index 0cd3791db..d175a6b99 100644 --- a/FoxTunes.UI.Windows/ViewModel/AsyncCommand.cs +++ b/FoxTunes.UI.Windows/ViewModel/AsyncCommand.cs @@ -48,7 +48,7 @@ public override void Execute(object parameter) } catch (Exception e) { - //Logger.Write(typeof(AsyncCommand), LogLevel.Warn, "Failed to execute command: {0}", e.Message); + Logger.Write(typeof(AsyncCommand), LogLevel.Warn, "Failed to execute command: {0}", e.Message); await ErrorEmitter.Send(this, string.Format("Failed to execute command: {0}", e.Message), e).ConfigureAwait(false); } return Windows.Invoke(() => this.OnCanExecuteChanged()); @@ -114,7 +114,7 @@ public override void Execute(object parameter) } catch (Exception e) { - //Logger.Write(typeof(AsyncCommand), LogLevel.Warn, "Failed to execute command: {0}", e.Message); + Logger.Write(typeof(AsyncCommand), LogLevel.Warn, "Failed to execute command: {0}", e.Message); await ErrorEmitter.Send(this, string.Format("Failed to execute command: {0}", e.Message), e).ConfigureAwait(false); } return Windows.Invoke(() => this.OnCanExecuteChanged()); diff --git a/FoxTunes.UI.Windows/ViewModel/Command.cs b/FoxTunes.UI.Windows/ViewModel/Command.cs index e5708fd25..ca822afb5 100644 --- a/FoxTunes.UI.Windows/ViewModel/Command.cs +++ b/FoxTunes.UI.Windows/ViewModel/Command.cs @@ -46,7 +46,7 @@ public override void Execute(object parameter) } catch (Exception e) { - //Logger.Write(typeof(Command), LogLevel.Warn, "Failed to execute command: {0}", e.Message); + Logger.Write(typeof(Command), LogLevel.Warn, "Failed to execute command: {0}", e.Message); var task = ErrorEmitter.Send(this, string.Format("Failed to execute command: {0}", e.Message), e); } this.OnCanExecuteChanged(); @@ -110,7 +110,7 @@ public override void Execute(object parameter) } catch (Exception e) { - //Logger.Write(typeof(Command), LogLevel.Warn, "Failed to execute command: {0}", e.Message); + Logger.Write(typeof(Command), LogLevel.Warn, "Failed to execute command: {0}", e.Message); var task = ErrorEmitter.Send(this, string.Format("Failed to execute command: {0}", e.Message), e); } this.OnCanExecuteChanged(); diff --git a/FoxTunes.UI.Windows/ViewModel/GridPlaylist.cs b/FoxTunes.UI.Windows/ViewModel/GridPlaylist.cs index ed3e50d20..009bb593b 100644 --- a/FoxTunes.UI.Windows/ViewModel/GridPlaylist.cs +++ b/FoxTunes.UI.Windows/ViewModel/GridPlaylist.cs @@ -300,9 +300,9 @@ protected virtual void UpdateDragDropEffects(DragEventArgs e) effects = DragDropEffects.Copy; } } - catch + catch (Exception exception) { - //Logger.Write(this, LogLevel.Warn, "Failed to query clipboard contents: {0}", exception.Message); + Logger.Write(this, LogLevel.Warn, "Failed to query clipboard contents: {0}", exception.Message); } e.Effects = effects; } @@ -344,9 +344,9 @@ protected virtual Task OnDrop(DragEventArgs e) return this.AddToPlaylist(paths); } } - catch + catch (Exception exception) { - //Logger.Write(this, LogLevel.Warn, "Failed to process clipboard contents: {0}", exception.Message); + Logger.Write(this, LogLevel.Warn, "Failed to process clipboard contents: {0}", exception.Message); } #if NET40 return TaskEx.FromResult(false); diff --git a/FoxTunes.UI.Windows/ViewModel/LibraryBase.cs b/FoxTunes.UI.Windows/ViewModel/LibraryBase.cs index 19838513f..0f536738a 100644 --- a/FoxTunes.UI.Windows/ViewModel/LibraryBase.cs +++ b/FoxTunes.UI.Windows/ViewModel/LibraryBase.cs @@ -389,9 +389,9 @@ protected virtual void UpdateDragDropEffects(DragEventArgs e) effects = DragDropEffects.Copy; } } - catch + catch (Exception exception) { - //Logger.Write(this, LogLevel.Warn, "Failed to query clipboard contents: {0}", exception.Message); + Logger.Write(this, LogLevel.Warn, "Failed to query clipboard contents: {0}", exception.Message); } e.Effects = effects; } @@ -421,9 +421,9 @@ protected virtual Task OnDrop(DragEventArgs e) return this.LibraryManager.Add(paths); } } - catch + catch (Exception exception) { - //Logger.Write(this, LogLevel.Warn, "Failed to process clipboard contents: {0}", exception.Message); + Logger.Write(this, LogLevel.Warn, "Failed to process clipboard contents: {0}", exception.Message); } #if NET40 return TaskEx.FromResult(false); diff --git a/FoxTunes.UI.Windows/ViewModel/Playlists.cs b/FoxTunes.UI.Windows/ViewModel/Playlists.cs index c23036dee..e259309f0 100644 --- a/FoxTunes.UI.Windows/ViewModel/Playlists.cs +++ b/FoxTunes.UI.Windows/ViewModel/Playlists.cs @@ -273,9 +273,9 @@ protected virtual void UpdateDragDropEffects(DragEventArgs e) effects = DragDropEffects.Copy; } } - catch + catch (Exception exception) { - //Logger.Write(this, LogLevel.Warn, "Failed to query clipboard contents: {0}", exception.Message); + Logger.Write(this, LogLevel.Warn, "Failed to query clipboard contents: {0}", exception.Message); } e.Effects = effects; } @@ -334,9 +334,9 @@ protected virtual Task AddPlaylist(DragEventArgs e) return this.AddPlaylist(paths); } } - catch + catch (Exception exception) { - //Logger.Write(this, LogLevel.Warn, "Failed to process clipboard contents: {0}", exception.Message); + Logger.Write(this, LogLevel.Warn, "Failed to process clipboard contents: {0}", exception.Message); } #if NET40 return TaskEx.FromResult(false); @@ -391,9 +391,9 @@ protected virtual Task AddToPlaylist(DragEventArgs e) return PlaylistActionsBehaviour.Instance.Add(playlist, paths, false); } } - catch + catch (Exception exception) { - //Logger.Write(this, LogLevel.Warn, "Failed to process clipboard contents: {0}", exception.Message); + Logger.Write(this, LogLevel.Warn, "Failed to process clipboard contents: {0}", exception.Message); } #if NET40 return TaskEx.FromResult(false); diff --git a/FoxTunes.UI.Windows/ViewModel/ViewModelBase.cs b/FoxTunes.UI.Windows/ViewModel/ViewModelBase.cs index 721cd08b8..7a659dc33 100644 --- a/FoxTunes.UI.Windows/ViewModel/ViewModelBase.cs +++ b/FoxTunes.UI.Windows/ViewModel/ViewModelBase.cs @@ -8,7 +8,15 @@ namespace FoxTunes.ViewModel { public abstract class ViewModelBase : Freezable, IBaseComponent, IObservable, IDisposable { - protected ViewModelBase(bool initialize = true) + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + + protected ViewModelBase(bool initialize = true) { if (initialize && Core.Instance != null) { diff --git a/FoxTunes.UI.Windows/WindowBase.cs b/FoxTunes.UI.Windows/WindowBase.cs index 99ecf5855..493851d74 100644 --- a/FoxTunes.UI.Windows/WindowBase.cs +++ b/FoxTunes.UI.Windows/WindowBase.cs @@ -21,6 +21,14 @@ namespace FoxTunes { public abstract class WindowBase : Window, IUserInterfaceWindow { + protected static ILogger Logger + { + get + { + return LogManager.Logger; + } + } + static WindowBase() { Instances = new List>(); diff --git a/FoxTunes.UI.Windows/WindowsUserInterface.cs b/FoxTunes.UI.Windows/WindowsUserInterface.cs index 00cfc8334..0982de286 100644 --- a/FoxTunes.UI.Windows/WindowsUserInterface.cs +++ b/FoxTunes.UI.Windows/WindowsUserInterface.cs @@ -98,7 +98,7 @@ public override Task Show() var window = default(Window); if (registration.TryGetInstance(out window)) { - //Logger.Write(this, LogLevel.Debug, "Found window instance with role {0}, running.", Enum.GetName(typeof(UserInterfaceWindowRole), UserInterfaceWindowRole.Main)); + Logger.Write(this, LogLevel.Debug, "Found window instance with role {0}, running.", Enum.GetName(typeof(UserInterfaceWindowRole), UserInterfaceWindowRole.Main)); this.Application.Run(window); goto done; } @@ -216,7 +216,7 @@ public override void Restart() protected virtual void OnApplicationDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { - //Logger.Write(this, LogLevel.Fatal, e.Exception.Message, e); + Logger.Write(this, LogLevel.Fatal, e.Exception.Message, e); //Don't crash out. e.Handled = true; } @@ -272,7 +272,7 @@ protected virtual void OnDisposing() ~WindowsUserInterface() { - //Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); + Logger.Write(this, LogLevel.Error, "Component was not disposed: {0}", this.GetType().Name); try { this.Dispose(true);