mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 08:55:56 +08:00
Converted logging to use log4net.
Changed LogBase to ConsoleBase, which handles console I/O. This is mostly an in-place conversion, so lots of refactoring can still be done.
This commit is contained in:
@@ -37,6 +37,8 @@ namespace OpenSim.Grid.ScriptServer
|
||||
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
log4net.Config.XmlConfigurator.Configure();
|
||||
|
||||
AppDomain.CurrentDomain.UnhandledException +=
|
||||
new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
|
||||
|
||||
|
||||
@@ -33,14 +33,12 @@ namespace OpenSim.Grid.ScriptServer
|
||||
// Maintains connection and communication to a region
|
||||
public class RegionConnectionManager : RegionBase
|
||||
{
|
||||
private LogBase m_log;
|
||||
private ScriptServerMain m_ScriptServerMain;
|
||||
private object m_Connection;
|
||||
|
||||
public RegionConnectionManager(ScriptServerMain scm, LogBase logger, object Connection)
|
||||
public RegionConnectionManager(ScriptServerMain scm, object Connection)
|
||||
{
|
||||
m_ScriptServerMain = scm;
|
||||
m_log = logger;
|
||||
m_Connection = Connection;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,13 +38,11 @@ namespace OpenSim.Grid.ScriptServer
|
||||
|
||||
private List<RegionConnectionManager> Regions = new List<RegionConnectionManager>();
|
||||
|
||||
private LogBase m_log;
|
||||
private ScriptServerMain m_ScriptServerMain;
|
||||
|
||||
public RegionCommManager(ScriptServerMain scm, LogBase logger)
|
||||
public RegionCommManager(ScriptServerMain scm)
|
||||
{
|
||||
m_ScriptServerMain = scm;
|
||||
m_log = logger;
|
||||
}
|
||||
|
||||
~RegionCommManager()
|
||||
@@ -96,9 +94,8 @@ namespace OpenSim.Grid.ScriptServer
|
||||
// ~ ask scriptengines if they will accept script?
|
||||
// - Add script to shared communication channel towards that region
|
||||
|
||||
|
||||
// TODO: FAKING A CONNECTION
|
||||
Regions.Add(new RegionConnectionManager(m_ScriptServerMain, m_log, null));
|
||||
Regions.Add(new RegionConnectionManager(m_ScriptServerMain, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,13 +35,7 @@ namespace OpenSim.Grid.ScriptServer.ScriptServer
|
||||
{
|
||||
internal class ScriptEngineLoader
|
||||
{
|
||||
private LogBase m_log;
|
||||
|
||||
|
||||
public ScriptEngineLoader(LogBase logger)
|
||||
{
|
||||
m_log = logger;
|
||||
}
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public ScriptServerInterfaces.ScriptEngine LoadScriptEngine(string EngineName)
|
||||
{
|
||||
@@ -55,7 +49,7 @@ namespace OpenSim.Grid.ScriptServer.ScriptServer
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error("ScriptEngine",
|
||||
m_log.Error("[ScriptEngine]: " +
|
||||
"Error loading assembly \"" + EngineName + "\": " + e.Message + ", " +
|
||||
e.StackTrace.ToString());
|
||||
}
|
||||
@@ -87,7 +81,7 @@ namespace OpenSim.Grid.ScriptServer.ScriptServer
|
||||
//}
|
||||
//catch (Exception e)
|
||||
//{
|
||||
// m_log.Error("ScriptEngine", "Error loading assembly \String.Empty + FileName + "\": " + e.ToString());
|
||||
// m_log.Error("[ScriptEngine]: Error loading assembly \String.Empty + FileName + "\": " + e.ToString());
|
||||
//}
|
||||
|
||||
|
||||
@@ -104,7 +98,7 @@ namespace OpenSim.Grid.ScriptServer.ScriptServer
|
||||
//}
|
||||
//catch (Exception e)
|
||||
//{
|
||||
// m_log.Error("ScriptEngine", "Error initializing type \String.Empty + NameSpace + "\" from \String.Empty + FileName + "\": " + e.ToString());
|
||||
// m_log.Error("[ScriptEngine]: Error initializing type \String.Empty + NameSpace + "\" from \String.Empty + FileName + "\": " + e.ToString());
|
||||
//}
|
||||
|
||||
ScriptServerInterfaces.ScriptEngine ret;
|
||||
@@ -114,7 +108,7 @@ namespace OpenSim.Grid.ScriptServer.ScriptServer
|
||||
//}
|
||||
//catch (Exception e)
|
||||
//{
|
||||
// m_log.Error("ScriptEngine", "Error initializing type \String.Empty + NameSpace + "\" from \String.Empty + FileName + "\": " + e.ToString());
|
||||
// m_log.Error("[ScriptEngine]: Error initializing type \String.Empty + NameSpace + "\" from \String.Empty + FileName + "\": " + e.ToString());
|
||||
//}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -34,17 +34,15 @@ namespace OpenSim.Grid.ScriptServer.ScriptServer
|
||||
{
|
||||
internal class ScriptEngineManager
|
||||
{
|
||||
private LogBase m_log;
|
||||
private ScriptEngineLoader ScriptEngineLoader;
|
||||
private List<ScriptServerInterfaces.ScriptEngine> scriptEngines = new List<ScriptServerInterfaces.ScriptEngine>();
|
||||
private ScriptServerMain m_ScriptServerMain;
|
||||
|
||||
// Initialize
|
||||
public ScriptEngineManager(ScriptServerMain scm, LogBase logger)
|
||||
public ScriptEngineManager(ScriptServerMain scm)
|
||||
{
|
||||
m_ScriptServerMain = scm;
|
||||
m_log = logger;
|
||||
ScriptEngineLoader = new ScriptEngineLoader(m_log);
|
||||
ScriptEngineLoader = new ScriptEngineLoader();
|
||||
}
|
||||
|
||||
~ScriptEngineManager()
|
||||
|
||||
@@ -40,11 +40,12 @@ namespace OpenSim.Grid.ScriptServer
|
||||
{
|
||||
public class ScriptServerMain : BaseOpenSimServer, conscmd_callback
|
||||
{
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
//
|
||||
// Root object. Creates objects used.
|
||||
//
|
||||
private int listenPort = 8010;
|
||||
private readonly string m_logFilename = ("scriptserver.log");
|
||||
|
||||
// TEMP
|
||||
public static ScriptServerInterfaces.ScriptEngine Engine;
|
||||
@@ -59,16 +60,15 @@ namespace OpenSim.Grid.ScriptServer
|
||||
|
||||
public ScriptServerMain()
|
||||
{
|
||||
m_log = CreateLog();
|
||||
|
||||
m_console = CreateConsole();
|
||||
|
||||
// Set up script engine mananger
|
||||
ScriptEngines = new ScriptEngineManager(this, m_log);
|
||||
ScriptEngines = new ScriptEngineManager(this);
|
||||
|
||||
// Load DotNetEngine
|
||||
Engine = ScriptEngines.LoadEngine("DotNetEngine");
|
||||
IConfigSource config = null;
|
||||
Engine.InitializeEngine(null, null, m_log, false, Engine.GetScriptManager());
|
||||
Engine.InitializeEngine(null, null, false, Engine.GetScriptManager());
|
||||
|
||||
|
||||
// Set up server
|
||||
@@ -83,12 +83,12 @@ namespace OpenSim.Grid.ScriptServer
|
||||
|
||||
private void RPC_ReceiveCommand(int ID, string Command, object[] p)
|
||||
{
|
||||
m_log.Notice("SERVER", "Received command: '" + Command + "'");
|
||||
m_log.Info("[SERVER]: Received command: '" + Command + "'");
|
||||
if (p != null)
|
||||
{
|
||||
for (int i = 0; i < p.Length; i++)
|
||||
{
|
||||
m_log.Notice("SERVER", "Param " + i + ": " + p[i].ToString());
|
||||
m_log.Info("[SERVER]: Param " + i + ": " + p[i].ToString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,14 +102,9 @@ namespace OpenSim.Grid.ScriptServer
|
||||
{
|
||||
}
|
||||
|
||||
protected LogBase CreateLog()
|
||||
protected ConsoleBase CreateConsole()
|
||||
{
|
||||
if (!Directory.Exists(Util.logDir()))
|
||||
{
|
||||
Directory.CreateDirectory(Util.logDir());
|
||||
}
|
||||
|
||||
return new LogBase((Path.Combine(Util.logDir(), m_logFilename)), "ScriptServer", this, true);
|
||||
return new ConsoleBase("ScriptServer", this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user