From 818af9d4827ea66358abbc3929d20e09861c7306 Mon Sep 17 00:00:00 2001
From: Jeff Ames
Date: Sun, 22 Feb 2009 01:26:18 +0000
Subject: Refactor log4net logger handling in script engine. (#3148)
---
.../ScriptEngine/DotNetEngine/AppDomainManager.cs | 13 +++---
OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs | 9 +++-
.../ScriptEngine/DotNetEngine/EventManager.cs | 16 ++++---
.../ScriptEngine/DotNetEngine/EventQueueManager.cs | 16 ++++---
.../DotNetEngine/EventQueueThreadClass.cs | 42 +++++++++---------
.../ScriptEngine/DotNetEngine/MaintenanceThread.cs | 8 ++--
.../ScriptEngine/DotNetEngine/ScriptEngine.cs | 5 ---
.../ScriptEngine/DotNetEngine/ScriptManager.cs | 51 +++++++++++-----------
.../ScriptEngine/Interfaces/IScriptEngine.cs | 1 -
.../Shared/Api/Implementation/LSL_Api.cs | 3 +-
.../Shared/Api/Implementation/Plugins/Listener.cs | 3 +-
.../ScriptEngine/Shared/CodeTools/Compiler.cs | 44 +++++++++----------
.../ScriptEngine/Shared/Instance/ScriptInstance.cs | 36 +++++++--------
.../Region/ScriptEngine/XEngine/EventManager.cs | 6 ++-
OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 7 +--
15 files changed, 134 insertions(+), 126 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs
index eeca143..d35e585 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/AppDomainManager.cs
@@ -34,6 +34,7 @@ using System.Security.Policy;
using System.Security.Permissions;
using OpenSim.Region.ScriptEngine.Interfaces;
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
+using log4net;
namespace OpenSim.Region.ScriptEngine.DotNetEngine
{
@@ -51,6 +52,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// 4. Unload AppDomain completely when all scripts in it has stopped
//
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
private int maxScriptsPerAppDomain = 1;
// Internal list of all AppDomains
@@ -138,12 +141,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
AppDomain AD = AppDomain.CreateDomain("ScriptAppDomain_" +
AppDomainNameCount, null, ads);
- m_scriptEngine.Log.Info("[" + m_scriptEngine.ScriptEngineName +
- "]: AppDomain Loading: " +
- AssemblyName.GetAssemblyName(
- "OpenSim.Region.ScriptEngine.Shared.dll").ToString());
+ m_log.Info("[" + m_scriptEngine.ScriptEngineName +
+ "]: AppDomain Loading: " +
+ AssemblyName.GetAssemblyName(
+ "OpenSim.Region.ScriptEngine.Shared.dll").ToString());
AD.Load(AssemblyName.GetAssemblyName(
- "OpenSim.Region.ScriptEngine.Shared.dll"));
+ "OpenSim.Region.ScriptEngine.Shared.dll"));
// Return the new AppDomain
return AD;
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs
index 56b4c8e..f10722b 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Common.cs
@@ -25,22 +25,27 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+using System.Reflection;
+using log4net;
+
namespace OpenSim.Region.ScriptEngine.DotNetEngine
{
public static class Common
{
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
public static ScriptEngine mySE;
// This class just contains some static log stuff used for debugging.
public static void SendToDebug(string message)
{
- mySE.Log.Info("[" + mySE.ScriptEngineName + "]: Debug: " + message);
+ m_log.Info("[" + mySE.ScriptEngineName + "]: Debug: " + message);
}
public static void SendToLog(string message)
{
- mySE.Log.Info("[" + mySE.ScriptEngineName + "]: LOG: " + message);
+ m_log.Info("[" + mySE.ScriptEngineName + "]: LOG: " + message);
}
}
}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
index cc78b51..e55abb7 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
@@ -27,6 +27,7 @@
using System;
using System.Collections.Generic;
+using System.Reflection;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.CoreModules.Avatar.Currency.SampleMoney;
@@ -35,6 +36,7 @@ using OpenSim.Region;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.ScriptEngine.Shared;
+using log4net;
namespace OpenSim.Region.ScriptEngine.DotNetEngine
{
@@ -63,6 +65,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// verify what exact parameters are needed.
//
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
private ScriptEngine myScriptEngine;
public EventManager(ScriptEngine _ScriptEngine, bool performHookUp)
@@ -78,8 +82,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
public void HookUpEvents()
{
- myScriptEngine.Log.Info("[" + myScriptEngine.ScriptEngineName +
- "]: Hooking up to server events");
+ m_log.Info("[" + myScriptEngine.ScriptEngineName +
+ "]: Hooking up to server events");
myScriptEngine.World.EventManager.OnObjectGrab +=
touch_start;
@@ -293,9 +297,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
if (engine != myScriptEngine.ScriptEngineName)
return;
- myScriptEngine.Log.Debug("OnRezScript localID: " + localID +
- " LLUID: " + itemID.ToString() + " Size: " +
- script.Length);
+ m_log.Debug("OnRezScript localID: " + localID +
+ " LLUID: " + itemID.ToString() + " Size: " +
+ script.Length);
myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script,
startParam, postOnRez);
@@ -303,7 +307,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
public void OnRemoveScript(uint localID, UUID itemID)
{
- myScriptEngine.Log.Debug("OnRemoveScript localID: " + localID + " LLUID: " + itemID.ToString());
+ m_log.Debug("OnRemoveScript localID: " + localID + " LLUID: " + itemID.ToString());
myScriptEngine.m_ScriptManager.StopScript(
localID,
itemID
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs
index 4a094e2..31c0d4d 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueManager.cs
@@ -28,8 +28,10 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Reflection;
using OpenMetaverse;
using OpenSim.Region.ScriptEngine.Shared;
+using log4net;
namespace OpenSim.Region.ScriptEngine.DotNetEngine
{
@@ -58,6 +60,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// Not noticeable unless server is under high load.
//
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
public ScriptEngine m_ScriptEngine;
///
@@ -211,7 +215,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
{
EventQueueThreadClass eqtc = new EventQueueThreadClass();
eventQueueThreads.Add(eqtc);
- //m_ScriptEngine.Log.Debug("[" + m_ScriptEngine.ScriptEngineName + "]: Started new script execution thread. Current thread count: " + eventQueueThreads.Count);
+ //m_log.Debug("[" + m_ScriptEngine.ScriptEngineName + "]: Started new script execution thread. Current thread count: " + eventQueueThreads.Count);
}
private void AbortThreadClass(EventQueueThreadClass threadClass)
@@ -225,10 +229,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
}
catch (Exception)
{
- //m_ScriptEngine.Log.Error("[" + m_ScriptEngine.ScriptEngineName + ":EventQueueManager]: If you see this, could you please report it to Tedd:");
- //m_ScriptEngine.Log.Error("[" + m_ScriptEngine.ScriptEngineName + ":EventQueueManager]: Script thread execution timeout kill ended in exception: " + ex.ToString());
+ //m_log.Error("[" + m_ScriptEngine.ScriptEngineName + ":EventQueueManager]: If you see this, could you please report it to Tedd:");
+ //m_log.Error("[" + m_ScriptEngine.ScriptEngineName + ":EventQueueManager]: Script thread execution timeout kill ended in exception: " + ex.ToString());
}
- //m_ScriptEngine.Log.Debug("[" + m_ScriptEngine.ScriptEngineName + "]: Killed script execution thread. Remaining thread count: " + eventQueueThreads.Count);
+ //m_log.Debug("[" + m_ScriptEngine.ScriptEngineName + "]: Killed script execution thread. Remaining thread count: " + eventQueueThreads.Count);
}
#endregion
@@ -346,8 +350,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
{
if (eventQueue.Count >= EventExecutionMaxQueueSize)
{
- m_ScriptEngine.Log.Error("[" + m_ScriptEngine.ScriptEngineName + "]: ERROR: Event execution queue item count is at " + eventQueue.Count + ". Config variable \"EventExecutionMaxQueueSize\" is set to " + EventExecutionMaxQueueSize + ", so ignoring new event.");
- m_ScriptEngine.Log.Error("[" + m_ScriptEngine.ScriptEngineName + "]: Event ignored: localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName);
+ m_log.Error("[" + m_ScriptEngine.ScriptEngineName + "]: ERROR: Event execution queue item count is at " + eventQueue.Count + ". Config variable \"EventExecutionMaxQueueSize\" is set to " + EventExecutionMaxQueueSize + ", so ignoring new event.");
+ m_log.Error("[" + m_ScriptEngine.ScriptEngineName + "]: Event ignored: localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName);
return false;
}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs
index 01cbb72..5451df2 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventQueueThreadClass.cs
@@ -47,6 +47,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// within a class
public class EventQueueThreadClass
{
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
// How many ms to sleep if queue is empty
private static int nothingToDoSleepms;// = 50;
private static ThreadPriority MyThreadPriority;
@@ -110,11 +112,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
break;
default:
MyThreadPriority = ThreadPriority.BelowNormal;
- m_ScriptEngine.Log.Error(
- "[ScriptEngine.DotNetEngine]: Unknown "+
- "priority type \"" + pri +
- "\" in config file. Defaulting to "+
- "\"BelowNormal\".");
+ m_log.Error(
+ "[ScriptEngine.DotNetEngine]: Unknown "+
+ "priority type \"" + pri +
+ "\" in config file. Defaulting to "+
+ "\"BelowNormal\".");
break;
}
}
@@ -186,24 +188,22 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
}
catch (ThreadAbortException)
{
- if (lastScriptEngine != null)
- lastScriptEngine.Log.Info("[" + ScriptEngineName +
- "]: ThreadAbortException while executing "+
- "function.");
+ m_log.Info("[" + ScriptEngineName +
+ "]: ThreadAbortException while executing "+
+ "function.");
}
catch (SelfDeleteException) // Must delete SOG
{
SceneObjectPart part =
- lastScriptEngine.World.GetSceneObjectPart(
+ lastScriptEngine.World.GetSceneObjectPart(
lastLocalID);
if (part != null && part.ParentGroup != null)
lastScriptEngine.World.DeleteSceneObject(
- part.ParentGroup, false);
+ part.ParentGroup, false);
}
catch (Exception e)
{
- if (lastScriptEngine != null)
- lastScriptEngine.Log.ErrorFormat("[{0}]: Exception {1} thrown", ScriptEngineName, e.GetType().ToString());
+ m_log.ErrorFormat("[{0}]: Exception {1} thrown", ScriptEngineName, e.GetType().ToString());
throw e;
}
}
@@ -214,10 +214,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
catch (Exception e)
{
// TODO: Let users in the sim and those entering it and possibly an external watchdog know what has happened
- if (lastScriptEngine != null)
- lastScriptEngine.Log.ErrorFormat(
- "[{0}]: Event queue thread terminating with exception. PLEASE REBOOT YOUR SIM - SCRIPT EVENTS WILL NOT WORK UNTIL YOU DO. Exception is {1}",
- ScriptEngineName, e);
+ m_log.ErrorFormat(
+ "[{0}]: Event queue thread terminating with exception. PLEASE REBOOT YOUR SIM - SCRIPT EVENTS WILL NOT WORK UNTIL YOU DO. Exception is {1}",
+ ScriptEngineName, e);
}
}
@@ -342,11 +341,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
}
catch (Exception)
{
- m_ScriptEngine.m_EventQueueManager.
- m_ScriptEngine.Log.Error("[" +
- ScriptEngineName + "]: " +
- "Unable to send text in-world:\r\n" +
- text);
+ m_log.Error("[" +
+ ScriptEngineName + "]: " +
+ "Unable to send text in-world:\r\n" +
+ text);
}
finally
{
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs
index 49e87c0..c157509 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/MaintenanceThread.cs
@@ -107,7 +107,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
private void StopMaintenanceThread()
{
#if DEBUG
- //m_ScriptEngine.Log.Debug("[" + m_ScriptEngine.ScriptEngineName + "]: StopMaintenanceThread() called");
+ //m_log.Debug("[" + m_ScriptEngine.ScriptEngineName + "]: StopMaintenanceThread() called");
#endif
//PleaseShutdown = true;
Thread.Sleep(100);
@@ -120,7 +120,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
}
catch (Exception)
{
- //m_ScriptEngine.Log.Error("[" + m_ScriptEngine.ScriptEngineName + "]: Exception stopping maintenence thread: " + ex.ToString());
+ //m_log.Error("[" + m_ScriptEngine.ScriptEngineName + "]: Exception stopping maintenence thread: " + ex.ToString());
}
}
@@ -131,8 +131,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
public void MaintenanceLoop()
{
//if (m_ScriptEngine.m_EventQueueManager.maxFunctionExecutionTimens < MaintenanceLoopms)
- // m_ScriptEngine.Log.Warn("[" + m_ScriptEngine.ScriptEngineName + "]: " +
- // "Configuration error: MaxEventExecutionTimeMs is less than MaintenanceLoopms. The Maintenance Loop will only check scripts once per run.");
+ // m_log.Warn("[" + m_ScriptEngine.ScriptEngineName + "]: " +
+ // "Configuration error: MaxEventExecutionTimeMs is less than MaintenanceLoopms. The Maintenance Loop will only check scripts once per run.");
long Last_maxFunctionExecutionTimens = 0; // DateTime.Now.Ticks;
long Last_ReReadConfigFilens = DateTime.Now.Ticks;
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
index dc7716e..c1902ba 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptEngine.cs
@@ -98,11 +98,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
get { return "ScriptEngine.DotNetEngine"; }
}
- public ILog Log
- {
- get { return m_log; }
- }
-
public ScriptEngine()
{
// For logging, just need any instance, doesn't matter
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
index 0c06630..4ede7f1 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs
@@ -240,14 +240,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
}
catch (Exception e2) // LEGIT: User Scripting
{
- m_scriptEngine.Log.Error("[" +
- m_scriptEngine.ScriptEngineName +
- "]: Error displaying error in-world: " +
- e2.ToString());
- m_scriptEngine.Log.Error("[" +
- m_scriptEngine.ScriptEngineName + "]: " +
- "Errormessage: Error compiling script:\r\n" +
- e2.Message.ToString());
+ m_log.Error("[" +
+ m_scriptEngine.ScriptEngineName +
+ "]: Error displaying error in-world: " +
+ e2.ToString());
+ m_log.Error("[" +
+ m_scriptEngine.ScriptEngineName + "]: " +
+ "Errormessage: Error compiling script:\r\n" +
+ e2.Message.ToString());
}
}
}
@@ -258,8 +258,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
if (id == null)
return;
- m_scriptEngine.Log.DebugFormat("[{0}]: Unloading script",
- m_scriptEngine.ScriptEngineName);
+ m_log.DebugFormat("[{0}]: Unloading script",
+ m_scriptEngine.ScriptEngineName);
// Stop long command on script
AsyncCommandManager.RemoveScript(m_scriptEngine, localID, itemID);
@@ -280,11 +280,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
}
catch (Exception e) // LEGIT: User Scripting
{
- m_scriptEngine.Log.Error("[" +
- m_scriptEngine.ScriptEngineName +
- "]: Exception stopping script localID: " +
- localID + " LLUID: " + itemID.ToString() +
- ": " + e.ToString());
+ m_log.Error("[" +
+ m_scriptEngine.ScriptEngineName +
+ "]: Exception stopping script localID: " +
+ localID + " LLUID: " + itemID.ToString() +
+ ": " + e.ToString());
}
}
@@ -379,10 +379,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
}
else if (item.Action == LUType.Load)
{
- m_scriptEngine.Log.DebugFormat("[{0}]: Loading script",
- m_scriptEngine.ScriptEngineName);
+ m_log.DebugFormat("[{0}]: Loading script",
+ m_scriptEngine.ScriptEngineName);
_StartScript(item.localID, item.itemID, item.script,
- item.startParam, item.postOnRez);
+ item.startParam, item.postOnRez);
}
}
}
@@ -414,13 +414,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
{
if ((LUQueue.Count >= LoadUnloadMaxQueueSize) && m_started)
{
- m_scriptEngine.Log.Error("[" +
- m_scriptEngine.ScriptEngineName +
- "]: ERROR: Load/unload queue item count is at " +
- LUQueue.Count +
- ". Config variable \"LoadUnloadMaxQueueSize\" "+
- "is set to " + LoadUnloadMaxQueueSize +
- ", so ignoring new script.");
+ m_log.Error("[" +
+ m_scriptEngine.ScriptEngineName +
+ "]: ERROR: Load/unload queue item count is at " +
+ LUQueue.Count +
+ ". Config variable \"LoadUnloadMaxQueueSize\" "+
+ "is set to " + LoadUnloadMaxQueueSize +
+ ", so ignoring new script.");
+
return;
}
diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs
index 84baa64..95a8530 100644
--- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs
+++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptEngine.cs
@@ -71,7 +71,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
void ResetScript(UUID itemID);
IConfig Config { get; }
string ScriptEngineName { get; }
- ILog Log { get; }
IScriptApi GetApi(UUID itemID, string name);
}
}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 6282b16..5455b53 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -32,6 +32,7 @@ using System.Runtime.Remoting.Lifetime;
using System.Text;
using System.Threading;
using Nini.Config;
+using log4net;
using OpenMetaverse;
using OpenMetaverse.Packets;
using OpenSim;
@@ -80,7 +81,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
private bool m_automaticLinkPermission=false;
private IMessageTransferModule m_TransferModule = null;
- //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
+ //private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
{
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs
index 5c95c66..5e5a922 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs
@@ -26,6 +26,7 @@
*/
using System;
+using log4net;
using OpenMetaverse;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.CoreModules.Scripting.WorldComm;
@@ -37,7 +38,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
{
public class Listener
{
- // private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
+ // private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public AsyncCommandManager m_CmdManager;
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
index 5b3dce7..03b2ab3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
@@ -29,10 +29,12 @@ using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Globalization;
+using System.Reflection;
using System.IO;
using Microsoft.CSharp;
using Microsoft.JScript;
using Microsoft.VisualBasic;
+using log4net;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.ScriptEngine.Interfaces;
@@ -40,8 +42,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
{
public class Compiler : ICompiler
{
- // private static readonly log4net.ILog m_log
- // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// * Uses "LSL2Converter" to convert LSL to C# if necessary.
// * Compiles C#-code into an assembly
@@ -126,7 +127,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
AllowedCompilers.Clear();
#if DEBUG
- m_scriptEngine.Log.Debug("[Compiler]: Allowed languages: " + allowComp);
+ m_log.Debug("[Compiler]: Allowed languages: " + allowComp);
#endif
@@ -135,18 +136,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
string strlan = strl.Trim(" \t".ToCharArray()).ToLower();
if (!LanguageMapping.ContainsKey(strlan))
{
- m_scriptEngine.Log.Error("[Compiler]: Config error. Compiler is unable to recognize language type \"" + strlan + "\" specified in \"AllowedCompilers\".");
+ m_log.Error("[Compiler]: Config error. Compiler is unable to recognize language type \"" + strlan + "\" specified in \"AllowedCompilers\".");
}
else
{
#if DEBUG
- //m_scriptEngine.Log.Debug("[Compiler]: Config OK. Compiler recognized language type \"" + strlan + "\" specified in \"AllowedCompilers\".");
+ //m_log.Debug("[Compiler]: Config OK. Compiler recognized language type \"" + strlan + "\" specified in \"AllowedCompilers\".");
#endif
}
AllowedCompilers.Add(strlan, true);
}
if (AllowedCompilers.Count == 0)
- m_scriptEngine.Log.Error("[Compiler]: Config error. Compiler could not recognize any language in \"AllowedCompilers\". Scripts will not be executed!");
+ m_log.Error("[Compiler]: Config error. Compiler could not recognize any language in \"AllowedCompilers\". Scripts will not be executed!");
// Default language
string defaultCompileLanguage = m_scriptEngine.Config.GetString("DefaultCompileLanguage", "lsl").ToLower();
@@ -154,7 +155,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
// Is this language recognized at all?
if (!LanguageMapping.ContainsKey(defaultCompileLanguage))
{
- m_scriptEngine.Log.Error("[Compiler]: " +
+ m_log.Error("[Compiler]: " +
"Config error. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is not recognized as a valid language. Changing default to: \"lsl\".");
defaultCompileLanguage = "lsl";
}
@@ -162,13 +163,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
// Is this language in allow-list?
if (!AllowedCompilers.ContainsKey(defaultCompileLanguage))
{
- m_scriptEngine.Log.Error("[Compiler]: " +
- "Config error. Default language \"" + defaultCompileLanguage + "\"specified in \"DefaultCompileLanguage\" is not in list of \"AllowedCompilers\". Scripts may not be executed!");
+ m_log.Error("[Compiler]: " +
+ "Config error. Default language \"" + defaultCompileLanguage + "\"specified in \"DefaultCompileLanguage\" is not in list of \"AllowedCompilers\". Scripts may not be executed!");
}
else
{
#if DEBUG
-// m_scriptEngine.Log.Debug("[Compiler]: " +
+// m_log.Debug("[Compiler]: " +
// "Config OK. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is recognized as a valid language.");
#endif
// LANGUAGE IS IN ALLOW-LIST
@@ -194,7 +195,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
}
catch (Exception ex)
{
- m_scriptEngine.Log.Error("[Compiler]: Exception trying to create ScriptEngine directory \"" + ScriptEnginesPath + "\": " + ex.ToString());
+ m_log.Error("[Compiler]: Exception trying to create ScriptEngine directory \"" + ScriptEnginesPath + "\": " + ex.ToString());
}
}
@@ -208,7 +209,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
}
catch (Exception ex)
{
- m_scriptEngine.Log.Error("[Compiler]: Exception trying to create ScriptEngine directory \"" + Path.Combine(ScriptEnginesPath,
+ m_log.Error("[Compiler]: Exception trying to create ScriptEngine directory \"" + Path.Combine(ScriptEnginesPath,
m_scriptEngine.World.RegionInfo.RegionID.ToString())+ "\": " + ex.ToString());
}
}
@@ -216,7 +217,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
foreach (string file in Directory.GetFiles(Path.Combine(ScriptEnginesPath,
m_scriptEngine.World.RegionInfo.RegionID.ToString())))
{
- //m_scriptEngine.Log.Error("[Compiler]: FILE FOUND: " + file);
+ //m_log.Error("[Compiler]: FILE FOUND: " + file);
if (file.ToLower().StartsWith(FilePrefix + "_compiled_") ||
file.ToLower().StartsWith(FilePrefix + "_source_"))
@@ -227,12 +228,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
}
catch (Exception ex)
{
- m_scriptEngine.Log.Error("[Compiler]: Exception trying delete old script file \"" + file + "\": " + ex.ToString());
+ m_log.Error("[Compiler]: Exception trying delete old script file \"" + file + "\": " + ex.ToString());
}
-
}
}
-
}
////private ICodeCompiler icc = codeProvider.CreateCompiler();
@@ -293,9 +292,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
if (Script == String.Empty)
{
if (File.Exists(OutFile))
-
{
-// m_scriptEngine.Log.DebugFormat("[Compiler] Returning existing assembly for {0}", asset);
+// m_log.DebugFormat("[Compiler] Returning existing assembly for {0}", asset);
return OutFile;
}
@@ -345,7 +343,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
//
if (File.Exists(OutFile) && File.Exists(OutFile+".text"))
{
-// m_scriptEngine.Log.DebugFormat("[Compiler] Returning existing assembly for {0}", asset);
+// m_log.DebugFormat("[Compiler] Returning existing assembly for {0}", asset);
return OutFile;
}
@@ -465,9 +463,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
}
catch (Exception ex) //NOTLEGIT - Should be just FileIOException
{
- m_scriptEngine.Log.Error("[Compiler]: Exception while "+
- "trying to write script source to file \"" +
- srcFileName + "\": " + ex.ToString());
+ m_log.Error("[Compiler]: Exception while "+
+ "trying to write script source to file \"" +
+ srcFileName + "\": " + ex.ToString());
}
}
@@ -577,7 +575,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
errtext += "No compile error. But not able to locate compiled file.";
throw new Exception(errtext);
}
-// m_scriptEngine.Log.DebugFormat("[Compiler] Compiled new assembly "+
+// m_log.DebugFormat("[Compiler] Compiled new assembly "+
// "for {0}", asset);
// Because windows likes to perform exclusive locks, we simply
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 20e70d0..c1d6f8e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -265,7 +265,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
}
catch (Exception e)
{
- m_Engine.Log.ErrorFormat("[Script] Error loading assembly {0}\n"+e.ToString(), assembly);
+ m_log.ErrorFormat("[Script] Error loading assembly {0}\n"+e.ToString(), assembly);
}
try
@@ -275,14 +275,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
m_Script.InitApi(kv.Key, kv.Value);
}
-// m_Engine.Log.Debug("[Script] Script instance created");
+// m_log.Debug("[Script] Script instance created");
part.SetScriptEvents(m_ItemID,
(int)m_Script.GetStateEventFlags(State));
}
catch (Exception e)
{
- m_Engine.Log.Error("[Script] Error loading script instance\n"+e.ToString());
+ m_log.Error("[Script] Error loading script instance\n"+e.ToString());
return;
}
@@ -317,7 +317,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
m_LocalID, m_ItemID, m_ObjectID,
PluginData);
-// m_Engine.Log.DebugFormat("[Script] Successfully retrieved state for script {0}.{1}", m_PrimName, m_ScriptName);
+// m_log.DebugFormat("[Script] Successfully retrieved state for script {0}.{1}", m_PrimName, m_ScriptName);
part.SetScriptEvents(m_ItemID,
(int)m_Script.GetStateEventFlags(State));
@@ -344,12 +344,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
}
else
{
- m_Engine.Log.Error("[Script] Unable to load script state: Memory limit exceeded");
+ m_log.Error("[Script] Unable to load script state: Memory limit exceeded");
}
}
catch (Exception e)
{
- m_Engine.Log.ErrorFormat("[Script] Unable to load script state from xml: {0}\n"+e.ToString(), xml);
+ m_log.ErrorFormat("[Script] Unable to load script state from xml: {0}\n"+e.ToString(), xml);
}
}
else
@@ -359,7 +359,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
if (presence != null && (!postOnRez))
presence.ControllingClient.SendAgentAlertMessage("Compile successful", false);
-// m_Engine.Log.ErrorFormat("[Script] Unable to load script state, file not found");
+// m_log.ErrorFormat("[Script] Unable to load script state, file not found");
}
}
@@ -378,7 +378,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
if (m_stateSource == StateSource.NewRez)
{
-// m_Engine.Log.Debug("[Script] Posted changed(CHANGED_REGION_RESTART) to script");
+// m_log.Debug("[Script] Posted changed(CHANGED_REGION_RESTART) to script");
PostEvent(new EventParams("changed",
new Object[] {new LSL_Types.LSLInteger(256)}, new DetectParams[0]));
}
@@ -473,7 +473,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
if (m_CurrentResult == null)
m_CurrentResult = m_Engine.QueueEventHandler(this);
else
- m_Engine.Log.Error("[Script] Tried to start a script that was already queued");
+ m_log.Error("[Script] Tried to start a script that was already queued");
}
}
}
@@ -545,7 +545,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
public void PostEvent(EventParams data)
{
-// m_Engine.Log.DebugFormat("[Script] Posted event {2} in state {3} to {0}.{1}",
+// m_log.DebugFormat("[Script] Posted event {2} in state {3} to {0}.{1}",
// m_PrimName, m_ScriptName, data.EventName, m_State);
if (!Running)
@@ -659,7 +659,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
if (data.EventName == "state") // Hardcoded state change
{
- // m_Engine.Log.DebugFormat("[Script] Script {0}.{1} state set to {2}",
+ // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}",
// m_PrimName, m_ScriptName, data.Params[0].ToString());
m_State=data.Params[0].ToString();
AsyncCommandManager.RemoveScript(m_Engine,
@@ -680,7 +680,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
{
SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
m_LocalID);
- // m_Engine.Log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}",
+ // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}",
// m_PrimName, m_ScriptName, data.EventName, m_State);
try
@@ -726,12 +726,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
}
catch (Exception e2) // LEGIT: User Scripting
{
- m_Engine.Log.Error("[Script]: "+
- "Error displaying error in-world: " +
- e2.ToString());
- m_Engine.Log.Error("[Script]: " +
- "Errormessage: Error compiling script:\r\n" +
- e.ToString());
+ m_log.Error("[Script]: "+
+ "Error displaying error in-world: " +
+ e2.ToString());
+ m_log.Error("[Script]: " +
+ "Errormessage: Error compiling script:\r\n" +
+ e.ToString());
}
}
else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException))
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
index 2632948..b1b82e5 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
@@ -28,6 +28,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Reflection;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.CoreModules.Avatar.Currency.SampleMoney;
@@ -35,6 +36,7 @@ using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.ScriptEngine.Shared;
using OpenSim.Region.ScriptEngine.Interfaces;
+using log4net;
namespace OpenSim.Region.ScriptEngine.XEngine
{
@@ -43,13 +45,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
///
public class EventManager
{
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
private XEngine myScriptEngine;
public EventManager(XEngine _ScriptEngine)
{
myScriptEngine = _ScriptEngine;
- myScriptEngine.Log.Info("[XEngine] Hooking up to server events");
+ m_log.Info("[XEngine] Hooking up to server events");
myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
myScriptEngine.World.EventManager.OnObjectDeGrab += touch_end;
myScriptEngine.World.EventManager.OnScriptChangedEvent += changed;
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 7a36bc2..75d0bec 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -125,11 +125,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
get { return m_Scene; }
}
- public ILog Log
- {
- get { return m_log; }
- }
-
public static List ScriptEngines
{
get { return m_ScriptEngines; }
@@ -483,7 +478,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
SceneObjectPart part = m_Scene.GetSceneObjectPart(localID);
if (part == null)
{
- Log.Error("[Script] SceneObjectPart unavailable. Script NOT started.");
+ m_log.Error("[Script] SceneObjectPart unavailable. Script NOT started.");
m_ScriptErrorMessage += "SceneObjectPart unavailable. Script NOT started.\n";
m_ScriptFailCount++;
return false;
--
cgit v1.1