From 888151833b1b08a6a8686d75a0385232b7fa90e9 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Tue, 9 Dec 2008 03:06:26 +0000 Subject: * 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. --- OpenSim/Region/Application/Application.cs | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/Application/Application.cs') 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 @@ */ 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; -- cgit v1.1