* Added 'LogFilename' attribute to simconfig.xml - in order to specify log name

* removed some greedy try-catch
* ignored some bins
Sugilite
lbsa71 2007-06-17 09:44:39 +00:00
parent 3c8daee510
commit c6b99fbca5
2 changed files with 130 additions and 141 deletions

View File

@ -49,8 +49,7 @@ namespace OpenSim.GenericConfig
public void LoadData() public void LoadData()
{ {
doc = new XmlDocument(); doc = new XmlDocument();
try
{
if (System.IO.File.Exists(fileName)) if (System.IO.File.Exists(fileName))
{ {
XmlTextReader reader = new XmlTextReader(fileName); XmlTextReader reader = new XmlTextReader(fileName);
@ -67,14 +66,7 @@ namespace OpenSim.GenericConfig
rootNode.AppendChild(configNode); rootNode.AppendChild(configNode);
} }
}
catch (Exception e)
{
Console.WriteLine(e.Message);
return;
}
try
{
rootNode = doc.FirstChild; rootNode = doc.FirstChild;
if (rootNode.Name != "Root") if (rootNode.Name != "Root")
throw new Exception("Error: Invalid .xml File. Missing <Root>"); throw new Exception("Error: Invalid .xml File. Missing <Root>");
@ -83,11 +75,6 @@ namespace OpenSim.GenericConfig
if (configNode.Name != "Config") if (configNode.Name != "Config")
throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>"); throw new Exception("Error: Invalid .xml File. <Root> first child should be <Config>");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
if (createdFile) if (createdFile)
{ {
this.Commit(); this.Commit();

View File

@ -63,6 +63,8 @@ namespace OpenSim
private CheckSumServer checkServer; private CheckSumServer checkServer;
protected CommunicationsManager commsManager; protected CommunicationsManager commsManager;
private bool m_silent;
private string m_logFilename = "region-console-" + Guid.NewGuid().ToString() + ".log";
public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile) public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile)
{ {
@ -71,8 +73,7 @@ namespace OpenSim
m_loginserver = startLoginServer; m_loginserver = startLoginServer;
m_physicsEngine = physicsEngine; m_physicsEngine = physicsEngine;
m_config = configFile; m_config = configFile;
m_console = new ConsoleBase("region-console-" + Guid.NewGuid().ToString() + ".log", "Region", this, silent); m_silent = silent;
OpenSim.Framework.Console.MainConsole.Instance = m_console;
} }
/// <summary> /// <summary>
@ -81,19 +82,18 @@ namespace OpenSim
public override void StartUp() public override void StartUp()
{ {
this.serversData = new NetworkServersInfo(); this.serversData = new NetworkServersInfo();
try
{
this.localConfig = new XmlConfig(m_config); this.localConfig = new XmlConfig(m_config);
this.localConfig.LoadData(); this.localConfig.LoadData();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
if (this.configFileSetup) if (this.configFileSetup)
{ {
this.SetupFromConfigFile(this.localConfig); this.SetupFromConfigFile(this.localConfig);
} }
m_console = new ConsoleBase(m_logFilename, "Region", this, m_silent);
OpenSim.Framework.Console.MainConsole.Instance = m_console;
m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Loading configuration"); m_console.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Loading configuration");
this.serversData.InitConfig(this.m_sandbox, this.localConfig); this.serversData.InitConfig(this.m_sandbox, this.localConfig);
this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change this.localConfig.Close();//for now we can close it as no other classes read from it , but this should change
@ -284,10 +284,19 @@ namespace OpenSim
private void SetupFromConfigFile(IGenericConfig configData) private void SetupFromConfigFile(IGenericConfig configData)
{ {
try // Log filename
{
// SandBoxMode
string attri = ""; string attri = "";
attri = configData.GetAttribute("LogFilename");
if (String.IsNullOrEmpty(attri))
{
}
else
{
m_logFilename = attri;
}
// SandBoxMode
attri = "";
attri = configData.GetAttribute("SandBox"); attri = configData.GetAttribute("SandBox");
if ((attri == "") || ((attri != "false") && (attri != "true"))) if ((attri == "") || ((attri != "false") && (attri != "true")))
{ {
@ -372,14 +381,7 @@ namespace OpenSim
} }
configData.Commit(); configData.Commit();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine("\nSorry, a fatal error occurred while trying to initialise the configuration data");
Console.WriteLine("Can not continue starting up");
Environment.Exit(1);
}
} }
/// <summary> /// <summary>