aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAdam Frisby2008-12-09 03:06:26 +0000
committerAdam Frisby2008-12-09 03:06:26 +0000
commit888151833b1b08a6a8686d75a0385232b7fa90e9 (patch)
tree0507ca2ddf342242561193e027c876e6bcf5bc2d
parentRemove null checks on structs (diff)
downloadopensim-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 '')
-rw-r--r--OpenSim/Framework/Util.cs28
-rw-r--r--OpenSim/Region/Application/Application.cs29
-rw-r--r--bin/OpenSim.ini.example9
3 files changed, 57 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
28using System; 28using System;
29using System.IO;
29using System.Net; 30using System.Net;
30using System.Reflection; 31using System.Reflection;
31using log4net; 32using 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;
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example
index eeb8f04..b3c7199 100644
--- a/bin/OpenSim.ini.example
+++ b/bin/OpenSim.ini.example
@@ -1,4 +1,13 @@
1[Startup] 1[Startup]
2; Set this to true if you want to log crashes to disk
3; this can be useful when submitting bug reports.
4save_crashes = false
5
6; Directory to save crashes to if above is enabled
7; (eg default is /opensimdir/crashes/*.txt or C:\opensim\crashes\*.txt)
8crash_dir = "crashes"
9
10
2 ; Set this to true if you are connecting your OpenSimulator regions to a grid 11 ; Set this to true if you are connecting your OpenSimulator regions to a grid
3 ; Set this to false if you are running OpenSimulator in standalone mode 12 ; Set this to false if you are running OpenSimulator in standalone mode
4 gridmode = false 13 gridmode = false