diff options
author | Adam Frisby | 2008-12-09 03:06:26 +0000 |
---|---|---|
committer | Adam Frisby | 2008-12-09 03:06:26 +0000 |
commit | 888151833b1b08a6a8686d75a0385232b7fa90e9 (patch) | |
tree | 0507ca2ddf342242561193e027c876e6bcf5bc2d /OpenSim | |
parent | Remove null checks on structs (diff) | |
download | opensim-SC-888151833b1b08a6a8686d75a0385232b7fa90e9.zip opensim-SC-888151833b1b08a6a8686d75a0385232b7fa90e9.tar.gz opensim-SC-888151833b1b08a6a8686d75a0385232b7fa90e9.tar.bz2 opensim-SC-888151833b1b08a6a8686d75a0385232b7fa90e9.tar.xz |
* Added primitive exception logging capabilities.
* Disabled by default (see OpenSim.ini.example for how to enable)
* Saves exceptions to a folder on disk (default "crashes") when enabled.
* These reports can then be uploaded or posted to help debug an error.
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Framework/Util.cs | 28 | ||||
-rw-r--r-- | OpenSim/Region/Application/Application.cs | 29 |
2 files changed, 48 insertions, 9 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index c1429df..23bdb94 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -560,6 +560,34 @@ namespace OpenSim.Framework | |||
560 | return "."; | 560 | return "."; |
561 | } | 561 | } |
562 | 562 | ||
563 | // From: http://coercedcode.blogspot.com/2008/03/c-generate-unique-filenames-within.html | ||
564 | public static string GetUniqueFilename(string FileName) | ||
565 | { | ||
566 | int count = 0; | ||
567 | string Name; | ||
568 | |||
569 | if (File.Exists(FileName)) | ||
570 | { | ||
571 | FileInfo f = new FileInfo(FileName); | ||
572 | |||
573 | if (!string.IsNullOrEmpty(f.Extension)) | ||
574 | { | ||
575 | Name = f.FullName.Substring(0, f.FullName.LastIndexOf('.')); | ||
576 | } | ||
577 | else | ||
578 | { | ||
579 | Name = f.FullName; | ||
580 | } | ||
581 | |||
582 | while (File.Exists(FileName)) | ||
583 | { | ||
584 | count++; | ||
585 | FileName = Name + count + f.Extension; | ||
586 | } | ||
587 | } | ||
588 | return FileName; | ||
589 | } | ||
590 | |||
563 | // Nini (config) related Methods | 591 | // Nini (config) related Methods |
564 | public static IConfigSource ConvertDataRowToXMLConfig(DataRow row, string fileName) | 592 | public static IConfigSource ConvertDataRowToXMLConfig(DataRow row, string fileName) |
565 | { | 593 | { |
diff --git a/OpenSim/Region/Application/Application.cs b/OpenSim/Region/Application/Application.cs index c891549..08dd7df 100644 --- a/OpenSim/Region/Application/Application.cs +++ b/OpenSim/Region/Application/Application.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | ||
29 | using System.Net; | 30 | using System.Net; |
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using log4net; | 32 | using log4net; |
@@ -42,6 +43,9 @@ namespace OpenSim | |||
42 | 43 | ||
43 | public static string iniFilePath = ""; | 44 | public static string iniFilePath = ""; |
44 | 45 | ||
46 | public static bool m_saveCrashDumps = false; | ||
47 | public static string m_crashDir = "crashes"; | ||
48 | |||
45 | //could move our main function into OpenSimMain and kill this class | 49 | //could move our main function into OpenSimMain and kill this class |
46 | public static void Main(string[] args) | 50 | public static void Main(string[] args) |
47 | { | 51 | { |
@@ -84,6 +88,9 @@ namespace OpenSim | |||
84 | bool background = configSource.Configs["Startup"].GetBoolean("background", false); | 88 | bool background = configSource.Configs["Startup"].GetBoolean("background", false); |
85 | bool hgrid = configSource.Configs["Startup"].GetBoolean("hypergrid", false); | 89 | bool hgrid = configSource.Configs["Startup"].GetBoolean("hypergrid", false); |
86 | 90 | ||
91 | m_saveCrashDumps = configSource.Configs["Startup"].GetBoolean("save_crashes", false); | ||
92 | m_crashDir = configSource.Configs["Startup"].GetString("crash_dir", m_crashDir); | ||
93 | |||
87 | if (background) | 94 | if (background) |
88 | { | 95 | { |
89 | OpenSimBase sim = new OpenSimBackground(configSource); | 96 | OpenSimBase sim = new OpenSimBackground(configSource); |
@@ -139,19 +146,23 @@ namespace OpenSim | |||
139 | 146 | ||
140 | m_log.ErrorFormat("[APPLICATION]: {0}", msg); | 147 | m_log.ErrorFormat("[APPLICATION]: {0}", msg); |
141 | 148 | ||
142 | // Try to post errormessage to an URL | 149 | // Log exception to disk |
143 | try | 150 | try |
144 | { | 151 | { |
145 | // DISABLED UNTIL WE CAN DISCUSS IF THIS IS MORALLY RIGHT OR NOT | 152 | if (!Directory.Exists(m_crashDir)) |
146 | // Note! Needs reference to System.Web | 153 | { |
147 | //System.Net.WebClient wc = new WebClient(); | 154 | Directory.CreateDirectory(m_crashDir); |
148 | //wc.DownloadData("http://www.opensimulator.org/ErrorReport.php?Msg=" + | 155 | } |
149 | // System.Web.HttpUtility.UrlEncode(msg)); | 156 | StreamWriter m_crashLog = |
150 | //wc.Dispose(); | 157 | new StreamWriter( |
158 | Path.Combine(m_crashDir, Util.GetUniqueFilename(ex.GetType() + ".txt")) | ||
159 | ); | ||
160 | m_crashLog.WriteLine(msg); | ||
161 | m_crashLog.Close(); | ||
151 | } | 162 | } |
152 | catch (WebException) | 163 | catch (Exception e2) |
153 | { | 164 | { |
154 | // Ignore | 165 | m_log.ErrorFormat("[CRASH LOGGER CRASHED]: {0}", e2); |
155 | } | 166 | } |
156 | 167 | ||
157 | _IsHandlingException=false; | 168 | _IsHandlingException=false; |