* 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.0.6.1-post-fixes
parent
8c33fcb321
commit
888151833b
|
@ -560,6 +560,34 @@ namespace OpenSim.Framework
|
|||
return ".";
|
||||
}
|
||||
|
||||
// From: http://coercedcode.blogspot.com/2008/03/c-generate-unique-filenames-within.html
|
||||
public static string GetUniqueFilename(string FileName)
|
||||
{
|
||||
int count = 0;
|
||||
string Name;
|
||||
|
||||
if (File.Exists(FileName))
|
||||
{
|
||||
FileInfo f = new FileInfo(FileName);
|
||||
|
||||
if (!string.IsNullOrEmpty(f.Extension))
|
||||
{
|
||||
Name = f.FullName.Substring(0, f.FullName.LastIndexOf('.'));
|
||||
}
|
||||
else
|
||||
{
|
||||
Name = f.FullName;
|
||||
}
|
||||
|
||||
while (File.Exists(FileName))
|
||||
{
|
||||
count++;
|
||||
FileName = Name + count + f.Extension;
|
||||
}
|
||||
}
|
||||
return FileName;
|
||||
}
|
||||
|
||||
// Nini (config) related Methods
|
||||
public static IConfigSource ConvertDataRowToXMLConfig(DataRow row, string fileName)
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
catch (WebException)
|
||||
if (!Directory.Exists(m_crashDir))
|
||||
{
|
||||
// Ignore
|
||||
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 (Exception e2)
|
||||
{
|
||||
m_log.ErrorFormat("[CRASH LOGGER CRASHED]: {0}", e2);
|
||||
}
|
||||
|
||||
_IsHandlingException=false;
|
||||
|
|
|
@ -1,4 +1,13 @@
|
|||
[Startup]
|
||||
; Set this to true if you want to log crashes to disk
|
||||
; this can be useful when submitting bug reports.
|
||||
save_crashes = false
|
||||
|
||||
; Directory to save crashes to if above is enabled
|
||||
; (eg default is /opensimdir/crashes/*.txt or C:\opensim\crashes\*.txt)
|
||||
crash_dir = "crashes"
|
||||
|
||||
|
||||
; Set this to true if you are connecting your OpenSimulator regions to a grid
|
||||
; Set this to false if you are running OpenSimulator in standalone mode
|
||||
gridmode = false
|
||||
|
|
Loading…
Reference in New Issue