* 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.
This commit is contained in:
Adam Frisby
2008-12-09 03:06:26 +00:00
parent 8c33fcb321
commit 888151833b
3 changed files with 57 additions and 9 deletions

View File

@@ -26,6 +26,7 @@
*/
using System;
using System.IO;
using System.Net;
using System.Reflection;
using log4net;
@@ -42,6 +43,9 @@ namespace OpenSim
public static string iniFilePath = "";
public static bool m_saveCrashDumps = false;
public static string m_crashDir = "crashes";
//could move our main function into OpenSimMain and kill this class
public static void Main(string[] args)
{
@@ -84,6 +88,9 @@ namespace OpenSim
bool background = configSource.Configs["Startup"].GetBoolean("background", false);
bool hgrid = configSource.Configs["Startup"].GetBoolean("hypergrid", false);
m_saveCrashDumps = configSource.Configs["Startup"].GetBoolean("save_crashes", false);
m_crashDir = configSource.Configs["Startup"].GetString("crash_dir", m_crashDir);
if (background)
{
OpenSimBase sim = new OpenSimBackground(configSource);
@@ -139,19 +146,23 @@ namespace OpenSim
m_log.ErrorFormat("[APPLICATION]: {0}", msg);
// Try to post errormessage to an URL
// Log exception to disk
try
{
// DISABLED UNTIL WE CAN DISCUSS IF THIS IS MORALLY RIGHT OR NOT
// Note! Needs reference to System.Web
//System.Net.WebClient wc = new WebClient();
//wc.DownloadData("http://www.opensimulator.org/ErrorReport.php?Msg=" +
// System.Web.HttpUtility.UrlEncode(msg));
//wc.Dispose();
if (!Directory.Exists(m_crashDir))
{
Directory.CreateDirectory(m_crashDir);
}
StreamWriter m_crashLog =
new StreamWriter(
Path.Combine(m_crashDir, Util.GetUniqueFilename(ex.GetType() + ".txt"))
);
m_crashLog.WriteLine(msg);
m_crashLog.Close();
}
catch (WebException)
catch (Exception e2)
{
// Ignore
m_log.ErrorFormat("[CRASH LOGGER CRASHED]: {0}", e2);
}
_IsHandlingException=false;