Commit 7f7a27ec authored by Andrés G. Aragoneses's avatar Andrés G. Aragoneses

Logging: bring latest hyena (& kill majority of warnings from it)

Latest change in hyena is the deprecation of Log.Exception() methods
because of its severity ambiguity. To fix the warnings generated by
this deprecation, I've taken this rule of thumb:

- If the exception being logged comes from a generic catch(Exception)
it's probably a way to avoid that Banshee crashes, and having a generic
Exception type (instead of a more specific one, i.e. FormatException)
most likely means that the reason for the exception is unknown, so it's
convenient to file this as an error. If any of this particular cases
becomes frequent enough, we can always look at the stacktrace, and put
a more specific catch() block that uses Log.Warning() in the future.

- If the exception being logged comes from a specific catch block of
a specific exception type (derived from System.Exception) it normally
corresponds to a non-severe problem that can be ignored, but logged as
a warning.
parent 9ce3a5f3
......@@ -106,7 +106,7 @@ namespace Banshee.GStreamer
Log.DebugFormat ("GStreamer running beat detection on {0}", path);
bbd_process_file (handle, path_ptr);
} catch (Exception e) {
Log.Exception (e);
Log.Error (e);
} finally {
GLib.Marshaller.Free (path_ptr);
}
......
......@@ -608,7 +608,7 @@ namespace Banshee.GStreamer
try {
handler (cbd, new float[][] { spec });
} catch (Exception e) {
Log.Exception ("Uncaught exception during visualization data post.", e);
Log.Error ("Uncaught exception during visualization data post.", e);
}
}
......@@ -857,7 +857,7 @@ namespace Banshee.GStreamer
clutter_video_texture = IntPtr.Zero;
}
} catch (Exception e) {
Log.Exception ("Clutter support could not be initialized", e);
Log.Error ("Clutter support could not be initialized", e);
clutter_video_sink = IntPtr.Zero;
clutter_video_texture = IntPtr.Zero;
clutter_video_sink_enabled = false;
......
......@@ -104,7 +104,7 @@ namespace Banshee.GStreamerSharp
}
pipeline.Bus.AddWatch (OnBusMessage);
} catch (Exception e) {
Log.Exception (e);
Log.Error (e);
throw new ApplicationException (Catalog.GetString ("Could not create BPM detection driver."), e);
}
}
......@@ -201,7 +201,7 @@ namespace Banshee.GStreamerSharp
filesrc ["location"] = path;
pipeline.SetState (State.Playing);
} catch (Exception e) {
Log.Exception (e);
Log.Error (e);
}
}
......
......@@ -287,7 +287,7 @@ namespace Banshee.GStreamerSharp
try {
OnDataAvailable (cbd, new float[][] { spec });
} catch (System.Exception e) {
Log.Exception ("Uncaught exception during visualization data post.", e);
Log.Error ("Uncaught exception during visualization data post.", e);
}
vis_buffer.Flush ((uint)wanted_size);
......
......@@ -163,7 +163,7 @@ namespace Banshee.Hardware.Gio
Hyena.Log.ErrorFormat ("Failed to eject {0}", Volume.Name);
}
} catch (Exception e) {
Hyena.Log.Exception (e);
Hyena.Log.Error (e);
}
});
}
......
......@@ -101,7 +101,8 @@ namespace Banshee.GnomeBackend
try {
Run (file_args.ToString ());
} catch (Exception e) {
Log.Exception ("Problem starting Brasero", e);
Log.Error ("Problem starting Brasero", e);
Log.Error (Catalog.GetString ("Could not write CD"),
Catalog.GetString ("Brasero could not be started"), true);
}
......
......@@ -55,7 +55,7 @@ namespace Banshee.GnomeBackend
try {
gnome.Brasero.Run (String.Format ("-c {0}", device));
} catch (Exception e) {
Log.Exception (e);
Log.Error (e);
return false;
}
......@@ -68,7 +68,7 @@ namespace Banshee.GnomeBackend
System.Diagnostics.Process.Start ("nautilus-cd-burner",
String.Format ("--source-device={0}", device));
} catch (Exception e) {
Log.Exception (e);
Log.Error (e);
return false;
}
......
......@@ -115,7 +115,7 @@ namespace Banshee.GnomeBackend
return true;
} catch (GConf.NoSuchKeyException) {
} catch (Exception e) {
Log.Exception (String.Format ("Could not read GConf key {0}.{1}", @namespace, key), e);
Log.Error (String.Format ("Could not read GConf key {0}.{1}", @namespace, key), e);
}
result = default (T);
......@@ -137,7 +137,7 @@ namespace Banshee.GnomeBackend
try {
client.Set (CreateKey (@namespace, key), value);
} catch (Exception e) {
Log.Exception (String.Format ("Could not set GConf key {0}.{1}.", @namespace, key), e);
Log.Error (String.Format ("Could not set GConf key {0}.{1}.", @namespace, key), e);
}
}
}
......
......@@ -52,7 +52,7 @@ namespace Banshee.GnomeBackend
// FIXME: this needs to be deferred/delayed initialized
gconf_proxy = new GConfProxy ();
} catch (Exception e) {
Hyena.Log.Exception ("GConfProxy", e);
Hyena.Log.Error ("Problem initializing GConfProxy", e);
gconf_proxy = null;
}
......
......@@ -91,7 +91,7 @@ namespace Booter
indexer.RebootWhenFinished (Environment.GetCommandLineArgs ());
Log.Warning ("The Banshee indexer is currently running. Banshee will be started when the indexer finishes.");
} catch (Exception e) {
Log.Exception ("CollectionIndexer found on the Bus, but doesn't say Hello", e);
Log.Error ("CollectionIndexer found on the Bus, but doesn't say Hello", e);
}
} else if (ApplicationContext.CommandLine.Contains ("indexer")) {
// Indexer Client
......@@ -122,7 +122,7 @@ namespace Booter
gdk_notify_startup_complete ();
}
} catch (Exception e) {
Hyena.Log.Exception ("Problem with NotifyStartupComplete", e);
Log.Error ("Problem with NotifyStartupComplete", e);
}
}
......
......@@ -477,7 +477,7 @@ namespace Banshee.Collection
property.SetValue (dest, property.GetValue (source, null), null);
}
} catch (Exception e) {
Log.Exception (e);
Log.Error (e);
}
}
}
......
......@@ -73,7 +73,7 @@ namespace Banshee.IO
is_directory = !is_regular_file && Banshee.IO.Directory.Exists (source);
if (Debug) Log.InformationFormat (" > item {0} is reg file? {1} is dir? {2}", source, is_regular_file, is_directory);
} catch (Exception e) {
if (Debug) Log.Exception ("Testing if path is file or dir", e);
if (Debug) Log.Error ("Testing if path is file or dir", e);
if (Debug) Log.InformationFormat (" > item {0} is reg file? {1} is dir? {2}", source, is_regular_file, is_directory);
return;
}
......@@ -101,11 +101,11 @@ namespace Banshee.IO
}
}
} catch (Exception e) {
Hyena.Log.Exception (e);
Log.Error (e);
}
}
} catch (System.ArgumentException) {
// If there are illegal characters in path
} catch (ArgumentException ex) {
Log.Warning (String.Format ("There are illegal characters in the path '{0}'", source), ex);
}
}
}
......
......@@ -233,7 +233,7 @@ namespace Banshee.Kernel
current_running_job.Run();
OnJobFinished(current_running_job);
} catch(Exception e) {
Log.Exception (e);
Log.Error (e);
}
}
}
......
......@@ -110,7 +110,7 @@ namespace Banshee.Collection.Database
random_modes.Add (random_by);
node_map[tnode] = random_by;
} catch (Exception e) {
Log.Exception (String.Format ("Failed to load RandomBy extension: {0}", args.Path), e);
Log.Error (String.Format ("Failed to load RandomBy extension: {0}", args.Path), e);
}
}
......
......@@ -183,7 +183,7 @@ namespace Banshee.Collection.Indexer
success = true;
} catch (Exception e) {
Log.Exception (e);
Log.Error (e);
}
Hyena.Log.DebugTimerPrint (timer_id, "CollectionIndexer.SaveToXml: {0}");
......
......@@ -66,7 +66,7 @@ namespace Banshee.Collection
if (manager.Debug) Log.InformationFormat ("ImportElement processing {0}", item);
manager.OnImportRequested (item);
} catch (Exception e) {
Hyena.Log.Exception (e);
Hyena.Log.Error (e);
}
return null;
}
......
......@@ -229,7 +229,7 @@ namespace Banshee.Collection
}
}
} catch (Exception e) {
Hyena.Log.Exception (e);
Hyena.Log.Error (e);
}
return null;
}
......
......@@ -61,7 +61,7 @@ namespace Banshee.Configuration
Log.DebugFormat ("Loaded Default Application Helper: {0}", helper.GetType ().FullName);
break;
} catch (Exception e) {
Log.Exception ("Default Application Helper backend failed to load", e);
Log.Error ("Default Application Helper backend failed to load", e);
}
}
}
......
......@@ -95,7 +95,7 @@ namespace Banshee.Database
try {
OptimizeDatabase ();
} catch (Exception e) {
Log.Exception ("Error determining if ANALYZE is necessary", e);
Log.Error ("Error determining if ANALYZE is necessary", e);
}
// Update cached sorting keys
......
......@@ -751,7 +751,7 @@ namespace Banshee.Database
connection.RemoveFunction<MigratePartialFunction> ();
}
} catch (Exception e) {
Hyena.Log.Exception (e);
Hyena.Log.Error (e);
}
return true;
}
......@@ -1315,7 +1315,7 @@ namespace Banshee.Database
SELECT * FROM PlaylistEntries
");
} catch (Exception e) {
Log.Exception ("Must be a pre-0.13.2 banshee.db, attempting to migrate", e);
Log.Error ("Must be a pre-0.13.2 banshee.db, attempting to migrate", e);
try {
Execute(@"
INSERT INTO CorePlaylists (PlaylistID, Name)
......@@ -1325,7 +1325,7 @@ namespace Banshee.Database
");
Log.Debug ("Success, was able to migrate older playlist information");
} catch (Exception e2) {
Log.Exception ("Failed to migrate playlists", e2);
Log.Error ("Failed to migrate playlists", e2);
}
}
......
......@@ -79,7 +79,7 @@ namespace Banshee.Equalizer
try {
Load ();
} catch (Exception e) {
Log.Exception ("Failed to load equalizer", e);
Log.Error ("Failed to load equalizer", e);
}
}
......@@ -234,11 +234,11 @@ namespace Banshee.Equalizer
}
Log.Information ("Converted legacy XML equalizer presets to new JSON format");
} catch (Exception xe) {
Log.Exception ("Could not load equalizers.xml", xe);
Log.Error ("Could not load equalizers.xml", xe);
}
}
} catch (Exception e) {
Log.Exception ("Could not load equalizers.json", e);
Log.Error ("Could not load equalizers.json", e);
}
Log.DebugTimerPrint (timer, "Loaded equalizer presets: {0}");
......@@ -325,7 +325,7 @@ namespace Banshee.Equalizer
}
Log.Debug ("EqualizerManager", "Saved equalizers to disk");
} catch (Exception e) {
Log.Exception ("Unable to save equalizers", e);
Log.Error ("Unable to save equalizers", e);
}
}
......
......@@ -58,7 +58,7 @@ namespace Banshee.Hardware
Log.DebugFormat ("Loaded HardwareManager backend: {0}", node.Id);
break;
} catch (Exception e) {
Log.Exception ("Hardware manager extension failed to load", e);
Log.Error ("Hardware manager extension failed to load", e);
}
}
......@@ -218,7 +218,7 @@ namespace Banshee.Hardware
return new_device;
}
} catch (Exception e) {
Log.Exception ("Exception casting device", e);
Log.Error ("Exception casting device", e);
}
}
......
......@@ -130,7 +130,7 @@ namespace Banshee.MediaEngine
SetNextTrackUri (track == null ? null : track.Uri,
track == null || track.HasAttribute (TrackMediaAttributes.VideoStream) || track is UnknownTrackInfo);
} catch (Exception e) {
Log.Exception ("Failed to pre-buffer next track", e);
Log.Error ("Failed to pre-buffer next track", e);
}
}
......
......@@ -371,7 +371,7 @@ namespace Banshee.MediaEngine
try {
OpenCheck (track, play);
} catch (Exception e) {
Log.Exception (e);
Log.Error (e);
Log.Error (Catalog.GetString ("Problem with Player Engine"), e.Message, true);
Close ();
ActiveEngine = default_engine;
......@@ -921,7 +921,7 @@ namespace Banshee.MediaEngine
try {
node.Value.Handler (args);
} catch (Exception e) {
Log.Exception (String.Format ("Error running PlayerEngine handler for {0}", args.Event), e);
Log.Error (String.Format ("Error running PlayerEngine handler for {0}", args.Event), e);
}
}
node = node.Next;
......
......@@ -122,7 +122,7 @@ namespace Banshee.Metadata.FileSystem
Log.Debug ("Got cover art from track's folder", best_file);
} catch (Exception e) {
Log.Exception (e);
Log.Error (e);
}
}
}
......
......@@ -126,7 +126,7 @@ namespace Banshee.Metadata.LastFM
AddTag (tag);
}
} catch (Exception e) {
Log.Exception ("Cover art found on Lastfm, but downloading it failed. Probably server under high load or dead link", e);
Log.Error ("Cover art found on Lastfm, but downloading it failed. Probably server under high load or dead link", e);
}
}
}
......
......@@ -99,7 +99,7 @@ namespace Banshee.Metadata
} catch (System.Threading.ThreadAbortException) {
throw;
} catch(Exception e) {
Hyena.Log.Exception (e);
Log.Error (e);
}
}
......@@ -201,7 +201,7 @@ namespace Banshee.Metadata
Banshee.IO.StreamAssist.Save (from_stream, Banshee.IO.File.OpenWrite (tmp_uri, true));
Banshee.IO.File.Move (tmp_uri, path_uri);
} catch (Exception e) {
Hyena.Log.Exception (e);
Log.Error (e);
}
}
}
......
......@@ -58,7 +58,7 @@ namespace Banshee.Metrics
try {
banshee_metrics = new BansheeMetrics ();
} catch (Exception e) {
Hyena.Log.Exception ("Failed to start collection of anonymous usage data", e);
Log.Error ("Failed to start collection of anonymous usage data", e);
banshee_metrics = null;
}
}
......
......@@ -45,7 +45,7 @@ namespace Banshee.PlatformServices
Log.DebugFormat ("Loaded IScreensaverManager: {0}", manager.GetType ().FullName);
break;
} catch (Exception e) {
Log.Exception ("IScreensaverManager extension failed to load", e);
Log.Error ("IScreensaverManager extension failed to load", e);
}
}
}
......
......@@ -250,7 +250,7 @@ namespace Banshee.Playlist
}
}
} catch (Exception e) {
Hyena.Log.Exception (e);
Log.Error (e);
}
}
}
......@@ -282,7 +282,7 @@ namespace Banshee.Playlist
importer.Finished += CreatePlaylist;
importer.Enqueue (uris);
} catch (PlaylistImportCanceledException e) {
Hyena.Log.Exception (e);
Log.Warning (e);
}
}
......@@ -314,7 +314,7 @@ namespace Banshee.Playlist
playlist.Reload ();
playlist.NotifyUser ();
} catch (Exception e) {
Hyena.Log.Exception (e);
Log.Error (e);
}
}
}
......
......@@ -115,7 +115,7 @@ namespace Banshee.ServiceStack
return true;
}
} catch (Exception e) {
Log.Exception ("DBus support could not be started. Disabling for this session.", e);
Log.Error ("DBus support could not be started. Disabling for this session.", e);
enabled = false;
}
......
......@@ -119,7 +119,7 @@ namespace Banshee.ServiceStack
Cleanup ();
throw;
} catch (Exception e) {
Log.Exception (e);
Log.Error (e);
failure_count++;
if (failure_count > MAX_FAILURE_COUNT) {
Log.WarningFormat ("Too many consecutive errors for job '{0}', aborting", this.Title);
......
......@@ -79,7 +79,7 @@ namespace Banshee.ServiceStack
try {
AddinManager.Registry.DisableAddin (a.AddinId);
} catch {}
Log.Exception (a.Message, a.Exception);
Log.Error (a.Message, a.Exception);
};
if (ApplicationContext.Debugging) {
......@@ -189,7 +189,7 @@ namespace Banshee.ServiceStack
Log.Warning (String.Format ("Service `{0}' not started: {1}", type.FullName,
e.InnerException != null ? e.InnerException.Message : e.Message));
Log.Exception (e.InnerException ?? e);
Log.Error (e.InnerException ?? e);
}
return null;
......@@ -221,7 +221,7 @@ namespace Banshee.ServiceStack
dispose_services.Push (service);
} catch (Exception e) {
Log.Exception (e.InnerException ?? e);
Log.Error (e.InnerException ?? e);
Log.Warning (String.Format ("Extension `{0}' not started: {1}",
service == null ? node.Path : service.GetType ().FullName, e.Message));
}
......@@ -282,7 +282,7 @@ namespace Banshee.ServiceStack
((IDelayedInitializeService)service).DelayedInitialize ();
}
} catch (Exception e) {
Log.Exception (e.InnerException ?? e);
Log.Error (e.InnerException ?? e);
Log.Warning (String.Format ("Service `{0}' not initialized: {1}",
service.GetType ().FullName, e.Message));
}
......@@ -297,7 +297,7 @@ namespace Banshee.ServiceStack
((IDisposable)service).Dispose ();
Log.DebugFormat ("Service disposed ({0})", service.ServiceName);
} catch (Exception e) {
Log.Exception (String.Format ("Service disposal ({0}) threw an exception", service.ServiceName), e);
Log.Error (String.Format ("Service disposal ({0}) threw an exception", service.ServiceName), e);
}
}
......
......@@ -531,7 +531,7 @@ namespace Banshee.Sources
skip_deletion.Add (track);
}
} catch (Exception e) {
Log.Exception (e);
Log.Error (e);
ErrorSource.AddMessage (e.Message, track.Uri.ToString ());
}
......@@ -647,7 +647,7 @@ namespace Banshee.Sources
AddTrackAndIncrementCount (track);
} catch (Exception e) {
IncrementAddedTracks ();
Log.Exception (e);
Log.Error (e);
ErrorSource.AddMessage (e.Message, track.Uri.ToString ());
}
}
......
......@@ -134,7 +134,7 @@ namespace Banshee.Sources
}
Log.DebugFormat ("Extension source loaded: {0}", source.Name);
} catch (Exception e) {
Log.Exception (e);
Log.Error (e);
}
} else if (args.Change == ExtensionChange.Remove && extension_sources.ContainsKey (node.Id)) {
Source source = extension_sources[node.Id];
......
......@@ -54,7 +54,7 @@ namespace Banshee.Streaming
try {
return OpenPlay (new SafeUri (uri));
} catch (Exception e) {
Hyena.Log.Exception (e);
Log.Error (e);
return null;
}
}
......@@ -166,7 +166,7 @@ namespace Banshee.Streaming
LoadStreamUris ();
} catch (Exception e) {
trying_to_play = false;
Log.Exception (this.ToString (), e);
Log.Error (this.ToString (), e);
SavePlaybackError (StreamPlaybackError.Unknown);
OnParsingPlaylistFinished ();
ServiceManager.PlayerEngine.Close ();
......@@ -307,10 +307,10 @@ namespace Banshee.Streaming
}
Log.DebugFormat ("Parsed {0} URIs out of {1}", stream_uris.Count, this);
} catch (System.Net.WebException e) {
Hyena.Log.Exception (this.ToString (), e);
Log.Warning (this.ToString (), e);
SavePlaybackError (StreamPlaybackError.ResourceNotFound);
} catch (Exception e) {
Hyena.Log.Exception (this.ToString (), e);
Log.Error (this.ToString (), e);
SavePlaybackError (StreamPlaybackError.Unknown);
}
}
......
......@@ -175,7 +175,7 @@ namespace Banshee.Web
while (HandleRequest(client));
} catch (IOException) {
} catch (Exception e) {
Log.Exception (e);
Log.Error (e);
} finally {
clients.Remove (client);
client.Close ();
......@@ -191,7 +191,7 @@ namespace Banshee.Web
if (e.SocketErrorCode == SocketError.AddressAlreadyInUse && this.EndPoint is IPEndPoint) {
Log.InformationFormat ("Unable to bind {0} to port {1}", name, (EndPoint as IPEndPoint).Port);
} else {
Log.Exception (e);
Log.Warning (e);
}
return false;
}
......
......@@ -83,7 +83,7 @@ namespace Banshee.Collection.Gui
try {
MigrateCacheDir ();
} catch (Exception e) {
Log.Exception ("Could not migrate album artwork cache directory", e);
Log.Error ("Could not migrate album artwork cache directory", e);
}
if (ApplicationContext.CommandLine.Contains ("fetch-artwork")) {
......
......@@ -91,7 +91,7 @@ namespace Banshee.Collection.Gui
}
}
} catch (Exception e) {
Log.Exception (e);
Log.Error (e);
}
};
......@@ -104,7 +104,7 @@ namespace Banshee.Collection.Gui
NotifyUpdated (track);
}
} catch (Exception e) {
Log.Exception (e);
Log.Error (e);
}
};
......@@ -134,7 +134,7 @@ namespace Banshee.Collection.Gui
}
}
} catch (Exception e) {
Log.Exception (e);
Log.Error (e);
}
};
......@@ -143,7 +143,7 @@ namespace Banshee.Collection.Gui
try {
SetCoverArt (GetTrack (), Encoding.UTF8.GetString (a.SelectionData.Data));
} catch (Exception e) {
Log.Exception (e);
Log.Error (e);
}
};
}
......
......@@ -63,7 +63,7 @@ namespace Banshee.Gui.TrackEditor
}
}
} catch (Exception e) {
Log.Exception (e);
Log.Error (e);
}
}
}
......@@ -99,7 +99,7 @@ namespace Banshee.Gui.TrackEditor
return StreamTagger.ProcessUri (Uri);
} catch (Exception e) {
if (Uri.Scheme == "file") {
Hyena.Log.Exception ("Cannot load TagLib file", e);
Log.Error ("Cannot load TagLib file", e);
}
}
......
......@@ -33,6 +33,7 @@ using Mono.Unix;
using Mono.Addins;
using Gtk;
using Hyena;
using Hyena.Gui;
using Hyena.Widgets;
......@@ -237,7 +238,7 @@ namespace Banshee.Gui.TrackEditor
page.Widget.Show ();
}