mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 06:06:06 +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:
@@ -26,10 +26,13 @@
|
||||
*
|
||||
*/
|
||||
/* Original code: Tedd Hansen */
|
||||
|
||||
namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||
{
|
||||
public static class Common
|
||||
{
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public static bool debug = true;
|
||||
public static ScriptEngine mySE;
|
||||
|
||||
@@ -41,14 +44,14 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||
public static void SendToDebug(string Message)
|
||||
{
|
||||
//if (Debug == true)
|
||||
mySE.Log.Verbose("ScriptEngine", "Debug: " + Message);
|
||||
mySE.m_log.Info("[ScriptEngine]: Debug: " + Message);
|
||||
//SendToDebugEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message);
|
||||
}
|
||||
|
||||
public static void SendToLog(string Message)
|
||||
{
|
||||
//if (Debug == true)
|
||||
mySE.Log.Verbose("ScriptEngine", "LOG: " + Message);
|
||||
mySE.m_log.Info("[ScriptEngine]: LOG: " + Message);
|
||||
//SendToLogEvent("\r\n" + DateTime.Now.ToString("[HH:mm:ss] ") + Message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL
|
||||
//[Serializable]
|
||||
public class LSL_BaseClass : MarshalByRefObject, LSL_BuiltIn_Commands_Interface, IScript
|
||||
{
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
// Object never expires
|
||||
public override Object InitializeLifetimeService()
|
||||
{
|
||||
@@ -87,7 +89,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSL
|
||||
{
|
||||
m_LSL_Functions = LSL_Functions;
|
||||
|
||||
//MainLog.Instance.Notice("ScriptEngine", "LSL_BaseClass.Start() called.");
|
||||
//m_log.Info("[ScriptEngine]: LSL_BaseClass.Start() called.");
|
||||
|
||||
// Get this AppDomain's settings and display some of them.
|
||||
AppDomainSetup ads = AppDomain.CurrentDomain.SetupInformation;
|
||||
|
||||
@@ -52,6 +52,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler
|
||||
/// </summary>
|
||||
public class LSL_BuiltIn_Commands : MarshalByRefObject, LSL_BuiltIn_Commands_Interface
|
||||
{
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private ASCIIEncoding enc = new ASCIIEncoding();
|
||||
private ScriptEngine m_ScriptEngine;
|
||||
private SceneObjectPart m_host;
|
||||
@@ -68,7 +70,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler
|
||||
m_itemID = itemID;
|
||||
|
||||
|
||||
//MainLog.Instance.Notice("ScriptEngine", "LSL_BaseClass.Start() called. Hosted by [" + m_host.Name + ":" + m_host.UUID + "@" + m_host.AbsolutePosition + "]");
|
||||
//m_log.Info("[ScriptEngine]: LSL_BaseClass.Start() called. Hosted by [" + m_host.Name + ":" + m_host.UUID + "@" + m_host.AbsolutePosition + "]");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -38,17 +38,19 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||
[Serializable]
|
||||
internal class EventManager
|
||||
{
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private ScriptEngine myScriptEngine;
|
||||
//public IScriptHost TEMP_OBJECT_ID;
|
||||
public EventManager(ScriptEngine _ScriptEngine)
|
||||
{
|
||||
myScriptEngine = _ScriptEngine;
|
||||
// TODO: HOOK EVENTS UP TO SERVER!
|
||||
//myScriptEngine.m_logger.Verbose("ScriptEngine", "EventManager Start");
|
||||
//myScriptEngine.m_log.Info("[ScriptEngine]: EventManager Start");
|
||||
// TODO: ADD SERVER HOOK TO LOAD A SCRIPT THROUGH myScriptEngine.ScriptManager
|
||||
|
||||
// Hook up a test event to our test form
|
||||
myScriptEngine.Log.Verbose("ScriptEngine", "Hooking up to server events");
|
||||
myScriptEngine.m_log.Info("[ScriptEngine]: Hooking up to server events");
|
||||
myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
|
||||
myScriptEngine.World.EventManager.OnRezScript += OnRezScript;
|
||||
myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript;
|
||||
@@ -57,7 +59,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||
public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)
|
||||
{
|
||||
// Add to queue for all scripts in ObjectID object
|
||||
//myScriptEngine.m_logger.Verbose("ScriptEngine", "EventManager Event: touch_start");
|
||||
//myScriptEngine.m_log.Info("[ScriptEngine]: EventManager Event: touch_start");
|
||||
//Console.WriteLine("touch_start localID: " + localID);
|
||||
myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", new object[] {(int) 1});
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||
[Serializable]
|
||||
internal class EventQueueManager
|
||||
{
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
/// <summary>
|
||||
/// List of threads processing event queue
|
||||
/// </summary>
|
||||
@@ -118,7 +120,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//myScriptEngine.Log.Verbose("ScriptEngine", "EventQueueManager Exception killing worker thread: " + e.ToString());
|
||||
//myScriptEngine.m_log.Info("[ScriptEngine]: EventQueueManager Exception killing worker thread: " + e.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -132,7 +134,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||
/// </summary>
|
||||
private void EventQueueThreadLoop()
|
||||
{
|
||||
//myScriptEngine.m_logger.Verbose("ScriptEngine", "EventQueueManager Worker thread spawned");
|
||||
//myScriptEngine.m_log.Info("[ScriptEngine]: EventQueueManager Worker thread spawned");
|
||||
try
|
||||
{
|
||||
QueueItemStruct BlankQIS = new QueueItemStruct();
|
||||
@@ -151,7 +153,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||
else
|
||||
{
|
||||
// Something in queue, process
|
||||
//myScriptEngine.m_logger.Verbose("ScriptEngine", "Processing event for localID: " + QIS.localID + ", itemID: " + QIS.itemID + ", FunctionName: " + QIS.FunctionName);
|
||||
//myScriptEngine.m_log.Info("[ScriptEngine]: Processing event for localID: " + QIS.localID + ", itemID: " + QIS.itemID + ", FunctionName: " + QIS.FunctionName);
|
||||
|
||||
// OBJECT BASED LOCK - TWO THREADS WORKING ON SAME OBJECT IS NOT GOOD
|
||||
lock (queueLock)
|
||||
@@ -237,7 +239,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||
} // try
|
||||
catch (ThreadAbortException)
|
||||
{
|
||||
//myScriptEngine.Log.Verbose("ScriptEngine", "EventQueueManager Worker thread killed: " + tae.Message);
|
||||
//myScriptEngine.m_log.Info("[ScriptEngine]: EventQueueManager Worker thread killed: " + tae.Message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,7 +289,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||
public void AddToObjectQueue(uint localID, string FunctionName, object[] param)
|
||||
{
|
||||
// Determine all scripts in Object and add to their queue
|
||||
//myScriptEngine.m_logger.Verbose("ScriptEngine", "EventQueueManager Adding localID: " + localID + ", FunctionName: " + FunctionName);
|
||||
//myScriptEngine.m_log.Info("[ScriptEngine]: EventQueueManager Adding localID: " + localID + ", FunctionName: " + FunctionName);
|
||||
|
||||
|
||||
// Do we have any scripts in this object at all? If not, return
|
||||
|
||||
@@ -40,6 +40,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||
[Serializable]
|
||||
public class ScriptEngine : IRegionModule
|
||||
{
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
internal Scene World;
|
||||
internal EventManager m_EventManager; // Handles and queues incoming events from OpenSim
|
||||
internal EventQueueManager m_EventQueueManager; // Executes events
|
||||
@@ -47,7 +49,6 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||
internal AppDomainManager m_AppDomainManager;
|
||||
internal LSLLongCmdHandler m_LSLLongCmdHandler;
|
||||
|
||||
private LogBase m_log;
|
||||
|
||||
public ScriptEngine()
|
||||
{
|
||||
@@ -55,19 +56,13 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||
Common.mySE = this;
|
||||
}
|
||||
|
||||
public LogBase Log
|
||||
{
|
||||
get { return m_log; }
|
||||
}
|
||||
|
||||
public void InitializeEngine(Scene Sceneworld, LogBase logger)
|
||||
public void InitializeEngine(Scene Sceneworld)
|
||||
{
|
||||
World = Sceneworld;
|
||||
m_log = logger;
|
||||
|
||||
Log.Verbose("ScriptEngine", "DotNet & LSL ScriptEngine initializing");
|
||||
m_log.Info("[ScriptEngine]: DotNet & LSL ScriptEngine initializing");
|
||||
|
||||
//m_logger.Status("ScriptEngine", "InitializeEngine");
|
||||
//m_log.Info("[ScriptEngine]: InitializeEngine");
|
||||
|
||||
// Create all objects we'll be using
|
||||
m_EventQueueManager = new EventQueueManager(this);
|
||||
@@ -90,7 +85,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||
//public void StartScript(string ScriptID, IScriptHost ObjectID)
|
||||
//{
|
||||
// this.myEventManager.TEMP_OBJECT_ID = ObjectID;
|
||||
// Log.Status("ScriptEngine", "DEBUG FUNCTION: StartScript: " + ScriptID);
|
||||
// m_log.Info("[ScriptEngine]: DEBUG FUNCTION: StartScript: " + ScriptID);
|
||||
// myScriptManager.StartScript(ScriptID, ObjectID);
|
||||
//}
|
||||
|
||||
@@ -98,7 +93,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||
|
||||
public void Initialise(Scene scene, IConfigSource config)
|
||||
{
|
||||
InitializeEngine(scene, MainLog.Instance);
|
||||
InitializeEngine(scene);
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
|
||||
@@ -48,6 +48,8 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||
[Serializable]
|
||||
public class ScriptManager
|
||||
{
|
||||
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
#region Declares
|
||||
|
||||
private Thread scriptLoadUnloadThread;
|
||||
@@ -312,7 +314,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//m_scriptEngine.Log.Error("ScriptEngine", "Error compiling script: " + e.ToString());
|
||||
//m_scriptEngine.m_log.Error("[ScriptEngine]: Error compiling script: " + e.ToString());
|
||||
try
|
||||
{
|
||||
// DISPLAY ERROR INWORLD
|
||||
@@ -323,7 +325,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||
}
|
||||
catch (Exception e2)
|
||||
{
|
||||
m_scriptEngine.Log.Error("ScriptEngine", "Error displaying error in-world: " + e2.ToString());
|
||||
m_scriptEngine.m_log.Error("[ScriptEngine]: Error displaying error in-world: " + e2.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -384,7 +386,7 @@ namespace OpenSim.Grid.ScriptEngine.DotNetEngine
|
||||
internal void ExecuteEvent(uint localID, LLUUID itemID, string FunctionName, object[] args)
|
||||
{
|
||||
// Execute a function in the script
|
||||
//m_scriptEngine.Log.Verbose("ScriptEngine", "Executing Function localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName);
|
||||
//m_scriptEngine.m_log.Info("[ScriptEngine]: Executing Function localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName);
|
||||
LSL_BaseClass Script = m_scriptEngine.m_ScriptManager.GetScript(localID, itemID);
|
||||
if (Script == null)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user