[hyena] Log: Catch exceptions when trying to redirect log output on Windows
- From: Bertrand Lorentz <blorentz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hyena] Log: Catch exceptions when trying to redirect log output on Windows
- Date: Sun, 11 Mar 2012 13:13:14 +0000 (UTC)
commit 057fc780ec36383f0231c72c6157bde14c772906
Author: Dustin C. Hatch <admiralnemo gmail com>
Date: Tue Mar 8 19:06:00 2011 -0600
Log: Catch exceptions when trying to redirect log output on Windows
Exceptions when trying to redirect standard output to a file are
now caught and logged to standard error. Fixes bgo#644270.
Signed-off-by: Bertrand Lorentz <bertrand lorentz gmail com>
Hyena/Hyena/Log.cs | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/Hyena/Hyena/Log.cs b/Hyena/Hyena/Log.cs
index 5a659f2..ce74484 100644
--- a/Hyena/Hyena/Log.cs
+++ b/Hyena/Hyena/Log.cs
@@ -96,12 +96,16 @@ namespace Hyena
// On Windows, if running uninstalled, leave STDOUT alone so it's visible in the IDE,
// otherwise write it to a file so it's not lost.
if (PlatformDetection.IsWindows && !ApplicationContext.CommandLine.Contains ("uninstalled")) {
- var log_path = Paths.Combine (Paths.ApplicationData, "log");
+ var log_path = Paths.Combine (Paths.ApplicationData, "banshee.log");
Console.WriteLine ("Logging to {0}", log_path);
- var log_writer = new System.IO.StreamWriter (log_path, false);
- log_writer.AutoFlush = true;
- Console.SetOut (log_writer);
+ try {
+ var log_writer = new System.IO.StreamWriter (log_path, false);
+ log_writer.AutoFlush = true;
+ Console.SetOut (log_writer);
+ } catch (Exception ex) {
+ Console.Error.WriteLine ("Unable to log to {0}: {1}", log_path, ex);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]