Refactor log4net logger handling in script engine. (#3148)

GenericGridServerConcept
Jeff Ames 2009-02-22 01:26:18 +00:00
parent 99b051ccbe
commit 818af9d482
18 changed files with 141 additions and 133 deletions

View File

@ -34,6 +34,7 @@ using System.Security.Policy;
using System.Security.Permissions; using System.Security.Permissions;
using OpenSim.Region.ScriptEngine.Interfaces; using OpenSim.Region.ScriptEngine.Interfaces;
using OpenSim.Region.ScriptEngine.Shared.ScriptBase; using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
using log4net;
namespace OpenSim.Region.ScriptEngine.DotNetEngine 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 // 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; private int maxScriptsPerAppDomain = 1;
// Internal list of all AppDomains // Internal list of all AppDomains
@ -138,12 +141,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
AppDomain AD = AppDomain.CreateDomain("ScriptAppDomain_" + AppDomain AD = AppDomain.CreateDomain("ScriptAppDomain_" +
AppDomainNameCount, null, ads); AppDomainNameCount, null, ads);
m_scriptEngine.Log.Info("[" + m_scriptEngine.ScriptEngineName + m_log.Info("[" + m_scriptEngine.ScriptEngineName +
"]: AppDomain Loading: " + "]: AppDomain Loading: " +
AssemblyName.GetAssemblyName( AssemblyName.GetAssemblyName(
"OpenSim.Region.ScriptEngine.Shared.dll").ToString()); "OpenSim.Region.ScriptEngine.Shared.dll").ToString());
AD.Load(AssemblyName.GetAssemblyName( AD.Load(AssemblyName.GetAssemblyName(
"OpenSim.Region.ScriptEngine.Shared.dll")); "OpenSim.Region.ScriptEngine.Shared.dll"));
// Return the new AppDomain // Return the new AppDomain
return AD; return AD;

View File

@ -25,22 +25,27 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using System.Reflection;
using log4net;
namespace OpenSim.Region.ScriptEngine.DotNetEngine namespace OpenSim.Region.ScriptEngine.DotNetEngine
{ {
public static class Common public static class Common
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static ScriptEngine mySE; public static ScriptEngine mySE;
// This class just contains some static log stuff used for debugging. // This class just contains some static log stuff used for debugging.
public static void SendToDebug(string message) 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) public static void SendToLog(string message)
{ {
mySE.Log.Info("[" + mySE.ScriptEngineName + "]: LOG: " + message); m_log.Info("[" + mySE.ScriptEngineName + "]: LOG: " + message);
} }
} }
} }

View File

@ -27,6 +27,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.CoreModules.Avatar.Currency.SampleMoney; using OpenSim.Region.CoreModules.Avatar.Currency.SampleMoney;
@ -35,6 +36,7 @@ using OpenSim.Region;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.ScriptEngine.Shared; using OpenSim.Region.ScriptEngine.Shared;
using log4net;
namespace OpenSim.Region.ScriptEngine.DotNetEngine namespace OpenSim.Region.ScriptEngine.DotNetEngine
{ {
@ -63,6 +65,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// verify what exact parameters are needed. // verify what exact parameters are needed.
// //
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private ScriptEngine myScriptEngine; private ScriptEngine myScriptEngine;
public EventManager(ScriptEngine _ScriptEngine, bool performHookUp) public EventManager(ScriptEngine _ScriptEngine, bool performHookUp)
@ -78,8 +82,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
public void HookUpEvents() public void HookUpEvents()
{ {
myScriptEngine.Log.Info("[" + myScriptEngine.ScriptEngineName + m_log.Info("[" + myScriptEngine.ScriptEngineName +
"]: Hooking up to server events"); "]: Hooking up to server events");
myScriptEngine.World.EventManager.OnObjectGrab += myScriptEngine.World.EventManager.OnObjectGrab +=
touch_start; touch_start;
@ -293,9 +297,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
if (engine != myScriptEngine.ScriptEngineName) if (engine != myScriptEngine.ScriptEngineName)
return; return;
myScriptEngine.Log.Debug("OnRezScript localID: " + localID + m_log.Debug("OnRezScript localID: " + localID +
" LLUID: " + itemID.ToString() + " Size: " + " LLUID: " + itemID.ToString() + " Size: " +
script.Length); script.Length);
myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script, myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script,
startParam, postOnRez); startParam, postOnRez);
@ -303,7 +307,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
public void OnRemoveScript(uint localID, UUID itemID) 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( myScriptEngine.m_ScriptManager.StopScript(
localID, localID,
itemID itemID

View File

@ -28,8 +28,10 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Region.ScriptEngine.Shared; using OpenSim.Region.ScriptEngine.Shared;
using log4net;
namespace OpenSim.Region.ScriptEngine.DotNetEngine namespace OpenSim.Region.ScriptEngine.DotNetEngine
{ {
@ -58,6 +60,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// Not noticeable unless server is under high load. // Not noticeable unless server is under high load.
// //
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public ScriptEngine m_ScriptEngine; public ScriptEngine m_ScriptEngine;
/// <summary> /// <summary>
@ -211,7 +215,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
{ {
EventQueueThreadClass eqtc = new EventQueueThreadClass(); EventQueueThreadClass eqtc = new EventQueueThreadClass();
eventQueueThreads.Add(eqtc); 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) private void AbortThreadClass(EventQueueThreadClass threadClass)
@ -225,10 +229,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
} }
catch (Exception) catch (Exception)
{ {
//m_ScriptEngine.Log.Error("[" + m_ScriptEngine.ScriptEngineName + ":EventQueueManager]: If you see this, could you please report it to Tedd:"); //m_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]: 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 #endregion
@ -346,8 +350,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
{ {
if (eventQueue.Count >= EventExecutionMaxQueueSize) 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_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 + "]: Event ignored: localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName);
return false; return false;
} }

View File

@ -47,6 +47,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
// within a class // within a class
public class EventQueueThreadClass public class EventQueueThreadClass
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// How many ms to sleep if queue is empty // How many ms to sleep if queue is empty
private static int nothingToDoSleepms;// = 50; private static int nothingToDoSleepms;// = 50;
private static ThreadPriority MyThreadPriority; private static ThreadPriority MyThreadPriority;
@ -110,11 +112,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
break; break;
default: default:
MyThreadPriority = ThreadPriority.BelowNormal; MyThreadPriority = ThreadPriority.BelowNormal;
m_ScriptEngine.Log.Error( m_log.Error(
"[ScriptEngine.DotNetEngine]: Unknown "+ "[ScriptEngine.DotNetEngine]: Unknown "+
"priority type \"" + pri + "priority type \"" + pri +
"\" in config file. Defaulting to "+ "\" in config file. Defaulting to "+
"\"BelowNormal\"."); "\"BelowNormal\".");
break; break;
} }
} }
@ -186,24 +188,22 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
} }
catch (ThreadAbortException) catch (ThreadAbortException)
{ {
if (lastScriptEngine != null) m_log.Info("[" + ScriptEngineName +
lastScriptEngine.Log.Info("[" + ScriptEngineName + "]: ThreadAbortException while executing "+
"]: ThreadAbortException while executing "+ "function.");
"function.");
} }
catch (SelfDeleteException) // Must delete SOG catch (SelfDeleteException) // Must delete SOG
{ {
SceneObjectPart part = SceneObjectPart part =
lastScriptEngine.World.GetSceneObjectPart( lastScriptEngine.World.GetSceneObjectPart(
lastLocalID); lastLocalID);
if (part != null && part.ParentGroup != null) if (part != null && part.ParentGroup != null)
lastScriptEngine.World.DeleteSceneObject( lastScriptEngine.World.DeleteSceneObject(
part.ParentGroup, false); part.ParentGroup, false);
} }
catch (Exception e) catch (Exception e)
{ {
if (lastScriptEngine != null) m_log.ErrorFormat("[{0}]: Exception {1} thrown", ScriptEngineName, e.GetType().ToString());
lastScriptEngine.Log.ErrorFormat("[{0}]: Exception {1} thrown", ScriptEngineName, e.GetType().ToString());
throw e; throw e;
} }
} }
@ -214,10 +214,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
catch (Exception e) catch (Exception e)
{ {
// TODO: Let users in the sim and those entering it and possibly an external watchdog know what has happened // TODO: Let users in the sim and those entering it and possibly an external watchdog know what has happened
if (lastScriptEngine != null) m_log.ErrorFormat(
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}",
"[{0}]: Event queue thread terminating with exception. PLEASE REBOOT YOUR SIM - SCRIPT EVENTS WILL NOT WORK UNTIL YOU DO. Exception is {1}", ScriptEngineName, e);
ScriptEngineName, e);
} }
} }
@ -342,11 +341,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
} }
catch (Exception) catch (Exception)
{ {
m_ScriptEngine.m_EventQueueManager. m_log.Error("[" +
m_ScriptEngine.Log.Error("[" + ScriptEngineName + "]: " +
ScriptEngineName + "]: " + "Unable to send text in-world:\r\n" +
"Unable to send text in-world:\r\n" + text);
text);
} }
finally finally
{ {

View File

@ -107,7 +107,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
private void StopMaintenanceThread() private void StopMaintenanceThread()
{ {
#if DEBUG #if DEBUG
//m_ScriptEngine.Log.Debug("[" + m_ScriptEngine.ScriptEngineName + "]: StopMaintenanceThread() called"); //m_log.Debug("[" + m_ScriptEngine.ScriptEngineName + "]: StopMaintenanceThread() called");
#endif #endif
//PleaseShutdown = true; //PleaseShutdown = true;
Thread.Sleep(100); Thread.Sleep(100);
@ -120,7 +120,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
} }
catch (Exception) 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() public void MaintenanceLoop()
{ {
//if (m_ScriptEngine.m_EventQueueManager.maxFunctionExecutionTimens < MaintenanceLoopms) //if (m_ScriptEngine.m_EventQueueManager.maxFunctionExecutionTimens < MaintenanceLoopms)
// m_ScriptEngine.Log.Warn("[" + m_ScriptEngine.ScriptEngineName + "]: " + // m_log.Warn("[" + m_ScriptEngine.ScriptEngineName + "]: " +
// "Configuration error: MaxEventExecutionTimeMs is less than MaintenanceLoopms. The Maintenance Loop will only check scripts once per run."); // "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_maxFunctionExecutionTimens = 0; // DateTime.Now.Ticks;
long Last_ReReadConfigFilens = DateTime.Now.Ticks; long Last_ReReadConfigFilens = DateTime.Now.Ticks;

View File

@ -98,11 +98,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
get { return "ScriptEngine.DotNetEngine"; } get { return "ScriptEngine.DotNetEngine"; }
} }
public ILog Log
{
get { return m_log; }
}
public ScriptEngine() public ScriptEngine()
{ {
// For logging, just need any instance, doesn't matter // For logging, just need any instance, doesn't matter

View File

@ -240,14 +240,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
} }
catch (Exception e2) // LEGIT: User Scripting catch (Exception e2) // LEGIT: User Scripting
{ {
m_scriptEngine.Log.Error("[" + m_log.Error("[" +
m_scriptEngine.ScriptEngineName + m_scriptEngine.ScriptEngineName +
"]: Error displaying error in-world: " + "]: Error displaying error in-world: " +
e2.ToString()); e2.ToString());
m_scriptEngine.Log.Error("[" + m_log.Error("[" +
m_scriptEngine.ScriptEngineName + "]: " + m_scriptEngine.ScriptEngineName + "]: " +
"Errormessage: Error compiling script:\r\n" + "Errormessage: Error compiling script:\r\n" +
e2.Message.ToString()); e2.Message.ToString());
} }
} }
} }
@ -258,8 +258,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
if (id == null) if (id == null)
return; return;
m_scriptEngine.Log.DebugFormat("[{0}]: Unloading script", m_log.DebugFormat("[{0}]: Unloading script",
m_scriptEngine.ScriptEngineName); m_scriptEngine.ScriptEngineName);
// Stop long command on script // Stop long command on script
AsyncCommandManager.RemoveScript(m_scriptEngine, localID, itemID); AsyncCommandManager.RemoveScript(m_scriptEngine, localID, itemID);
@ -280,11 +280,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
} }
catch (Exception e) // LEGIT: User Scripting catch (Exception e) // LEGIT: User Scripting
{ {
m_scriptEngine.Log.Error("[" + m_log.Error("[" +
m_scriptEngine.ScriptEngineName + m_scriptEngine.ScriptEngineName +
"]: Exception stopping script localID: " + "]: Exception stopping script localID: " +
localID + " LLUID: " + itemID.ToString() + localID + " LLUID: " + itemID.ToString() +
": " + e.ToString()); ": " + e.ToString());
} }
} }
@ -379,10 +379,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
} }
else if (item.Action == LUType.Load) else if (item.Action == LUType.Load)
{ {
m_scriptEngine.Log.DebugFormat("[{0}]: Loading script", m_log.DebugFormat("[{0}]: Loading script",
m_scriptEngine.ScriptEngineName); m_scriptEngine.ScriptEngineName);
_StartScript(item.localID, item.itemID, item.script, _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) if ((LUQueue.Count >= LoadUnloadMaxQueueSize) && m_started)
{ {
m_scriptEngine.Log.Error("[" + m_log.Error("[" +
m_scriptEngine.ScriptEngineName + m_scriptEngine.ScriptEngineName +
"]: ERROR: Load/unload queue item count is at " + "]: ERROR: Load/unload queue item count is at " +
LUQueue.Count + LUQueue.Count +
". Config variable \"LoadUnloadMaxQueueSize\" "+ ". Config variable \"LoadUnloadMaxQueueSize\" "+
"is set to " + LoadUnloadMaxQueueSize + "is set to " + LoadUnloadMaxQueueSize +
", so ignoring new script."); ", so ignoring new script.");
return; return;
} }

View File

@ -71,7 +71,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
void ResetScript(UUID itemID); void ResetScript(UUID itemID);
IConfig Config { get; } IConfig Config { get; }
string ScriptEngineName { get; } string ScriptEngineName { get; }
ILog Log { get; }
IScriptApi GetApi(UUID itemID, string name); IScriptApi GetApi(UUID itemID, string name);
} }
} }

View File

@ -32,6 +32,7 @@ using System.Runtime.Remoting.Lifetime;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using Nini.Config; using Nini.Config;
using log4net;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.Packets; using OpenMetaverse.Packets;
using OpenSim; using OpenSim;
@ -80,7 +81,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
private bool m_automaticLinkPermission=false; private bool m_automaticLinkPermission=false;
private IMessageTransferModule m_TransferModule = null; 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) public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
{ {

View File

@ -26,6 +26,7 @@
*/ */
using System; using System;
using log4net;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.CoreModules.Scripting.WorldComm; using OpenSim.Region.CoreModules.Scripting.WorldComm;
@ -37,7 +38,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
{ {
public class Listener 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; public AsyncCommandManager m_CmdManager;

View File

@ -29,10 +29,12 @@ using System;
using System.CodeDom.Compiler; using System.CodeDom.Compiler;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Reflection;
using System.IO; using System.IO;
using Microsoft.CSharp; using Microsoft.CSharp;
using Microsoft.JScript; using Microsoft.JScript;
using Microsoft.VisualBasic; using Microsoft.VisualBasic;
using log4net;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.ScriptEngine.Interfaces; using OpenSim.Region.ScriptEngine.Interfaces;
@ -40,8 +42,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
{ {
public class Compiler : ICompiler public class Compiler : ICompiler
{ {
// private static readonly log4net.ILog m_log private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// * Uses "LSL2Converter" to convert LSL to C# if necessary. // * Uses "LSL2Converter" to convert LSL to C# if necessary.
// * Compiles C#-code into an assembly // * Compiles C#-code into an assembly
@ -126,7 +127,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
AllowedCompilers.Clear(); AllowedCompilers.Clear();
#if DEBUG #if DEBUG
m_scriptEngine.Log.Debug("[Compiler]: Allowed languages: " + allowComp); m_log.Debug("[Compiler]: Allowed languages: " + allowComp);
#endif #endif
@ -135,18 +136,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
string strlan = strl.Trim(" \t".ToCharArray()).ToLower(); string strlan = strl.Trim(" \t".ToCharArray()).ToLower();
if (!LanguageMapping.ContainsKey(strlan)) 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 else
{ {
#if DEBUG #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 #endif
} }
AllowedCompilers.Add(strlan, true); AllowedCompilers.Add(strlan, true);
} }
if (AllowedCompilers.Count == 0) 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 // Default language
string defaultCompileLanguage = m_scriptEngine.Config.GetString("DefaultCompileLanguage", "lsl").ToLower(); 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? // Is this language recognized at all?
if (!LanguageMapping.ContainsKey(defaultCompileLanguage)) 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\"."); "Config error. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is not recognized as a valid language. Changing default to: \"lsl\".");
defaultCompileLanguage = "lsl"; defaultCompileLanguage = "lsl";
} }
@ -162,13 +163,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
// Is this language in allow-list? // Is this language in allow-list?
if (!AllowedCompilers.ContainsKey(defaultCompileLanguage)) if (!AllowedCompilers.ContainsKey(defaultCompileLanguage))
{ {
m_scriptEngine.Log.Error("[Compiler]: " + m_log.Error("[Compiler]: " +
"Config error. Default language \"" + defaultCompileLanguage + "\"specified in \"DefaultCompileLanguage\" is not in list of \"AllowedCompilers\". Scripts may not be executed!"); "Config error. Default language \"" + defaultCompileLanguage + "\"specified in \"DefaultCompileLanguage\" is not in list of \"AllowedCompilers\". Scripts may not be executed!");
} }
else else
{ {
#if DEBUG #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."); // "Config OK. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is recognized as a valid language.");
#endif #endif
// LANGUAGE IS IN ALLOW-LIST // LANGUAGE IS IN ALLOW-LIST
@ -194,7 +195,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
} }
catch (Exception ex) 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) 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()); 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, foreach (string file in Directory.GetFiles(Path.Combine(ScriptEnginesPath,
m_scriptEngine.World.RegionInfo.RegionID.ToString()))) 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_") || if (file.ToLower().StartsWith(FilePrefix + "_compiled_") ||
file.ToLower().StartsWith(FilePrefix + "_source_")) file.ToLower().StartsWith(FilePrefix + "_source_"))
@ -227,12 +228,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
} }
catch (Exception ex) 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(); ////private ICodeCompiler icc = codeProvider.CreateCompiler();
@ -293,9 +292,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
if (Script == String.Empty) if (Script == String.Empty)
{ {
if (File.Exists(OutFile)) 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; return OutFile;
} }
@ -345,7 +343,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
// //
if (File.Exists(OutFile) && File.Exists(OutFile+".text")) 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; return OutFile;
} }
@ -465,9 +463,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
} }
catch (Exception ex) //NOTLEGIT - Should be just FileIOException catch (Exception ex) //NOTLEGIT - Should be just FileIOException
{ {
m_scriptEngine.Log.Error("[Compiler]: Exception while "+ m_log.Error("[Compiler]: Exception while "+
"trying to write script source to file \"" + "trying to write script source to file \"" +
srcFileName + "\": " + ex.ToString()); srcFileName + "\": " + ex.ToString());
} }
} }
@ -577,7 +575,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
errtext += "No compile error. But not able to locate compiled file."; errtext += "No compile error. But not able to locate compiled file.";
throw new Exception(errtext); throw new Exception(errtext);
} }
// m_scriptEngine.Log.DebugFormat("[Compiler] Compiled new assembly "+ // m_log.DebugFormat("[Compiler] Compiled new assembly "+
// "for {0}", asset); // "for {0}", asset);
// Because windows likes to perform exclusive locks, we simply // Because windows likes to perform exclusive locks, we simply

View File

@ -265,7 +265,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
} }
catch (Exception e) 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 try
@ -275,14 +275,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
m_Script.InitApi(kv.Key, kv.Value); 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, part.SetScriptEvents(m_ItemID,
(int)m_Script.GetStateEventFlags(State)); (int)m_Script.GetStateEventFlags(State));
} }
catch (Exception e) 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; return;
} }
@ -317,7 +317,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
m_LocalID, m_ItemID, m_ObjectID, m_LocalID, m_ItemID, m_ObjectID,
PluginData); 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, part.SetScriptEvents(m_ItemID,
(int)m_Script.GetStateEventFlags(State)); (int)m_Script.GetStateEventFlags(State));
@ -344,12 +344,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
} }
else 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) 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 else
@ -359,7 +359,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
if (presence != null && (!postOnRez)) if (presence != null && (!postOnRez))
presence.ControllingClient.SendAgentAlertMessage("Compile successful", false); 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) 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", PostEvent(new EventParams("changed",
new Object[] {new LSL_Types.LSLInteger(256)}, new DetectParams[0])); new Object[] {new LSL_Types.LSLInteger(256)}, new DetectParams[0]));
} }
@ -473,7 +473,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
if (m_CurrentResult == null) if (m_CurrentResult == null)
m_CurrentResult = m_Engine.QueueEventHandler(this); m_CurrentResult = m_Engine.QueueEventHandler(this);
else 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) 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); // m_PrimName, m_ScriptName, data.EventName, m_State);
if (!Running) if (!Running)
@ -659,7 +659,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
if (data.EventName == "state") // Hardcoded state change 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_PrimName, m_ScriptName, data.Params[0].ToString());
m_State=data.Params[0].ToString(); m_State=data.Params[0].ToString();
AsyncCommandManager.RemoveScript(m_Engine, AsyncCommandManager.RemoveScript(m_Engine,
@ -680,7 +680,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
{ {
SceneObjectPart part = m_Engine.World.GetSceneObjectPart( SceneObjectPart part = m_Engine.World.GetSceneObjectPart(
m_LocalID); 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); // m_PrimName, m_ScriptName, data.EventName, m_State);
try try
@ -726,12 +726,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
} }
catch (Exception e2) // LEGIT: User Scripting catch (Exception e2) // LEGIT: User Scripting
{ {
m_Engine.Log.Error("[Script]: "+ m_log.Error("[Script]: "+
"Error displaying error in-world: " + "Error displaying error in-world: " +
e2.ToString()); e2.ToString());
m_Engine.Log.Error("[Script]: " + m_log.Error("[Script]: " +
"Errormessage: Error compiling script:\r\n" + "Errormessage: Error compiling script:\r\n" +
e.ToString()); e.ToString());
} }
} }
else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException)) else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException))

View File

@ -28,6 +28,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.CoreModules.Avatar.Currency.SampleMoney; using OpenSim.Region.CoreModules.Avatar.Currency.SampleMoney;
@ -35,6 +36,7 @@ using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.ScriptEngine.Shared; using OpenSim.Region.ScriptEngine.Shared;
using OpenSim.Region.ScriptEngine.Interfaces; using OpenSim.Region.ScriptEngine.Interfaces;
using log4net;
namespace OpenSim.Region.ScriptEngine.XEngine namespace OpenSim.Region.ScriptEngine.XEngine
{ {
@ -43,13 +45,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
/// </summary> /// </summary>
public class EventManager public class EventManager
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private XEngine myScriptEngine; private XEngine myScriptEngine;
public EventManager(XEngine _ScriptEngine) public EventManager(XEngine _ScriptEngine)
{ {
myScriptEngine = _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.OnObjectGrab += touch_start;
myScriptEngine.World.EventManager.OnObjectDeGrab += touch_end; myScriptEngine.World.EventManager.OnObjectDeGrab += touch_end;
myScriptEngine.World.EventManager.OnScriptChangedEvent += changed; myScriptEngine.World.EventManager.OnScriptChangedEvent += changed;

View File

@ -125,11 +125,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
get { return m_Scene; } get { return m_Scene; }
} }
public ILog Log
{
get { return m_log; }
}
public static List<XEngine> ScriptEngines public static List<XEngine> ScriptEngines
{ {
get { return m_ScriptEngines; } get { return m_ScriptEngines; }
@ -483,7 +478,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
SceneObjectPart part = m_Scene.GetSceneObjectPart(localID); SceneObjectPart part = m_Scene.GetSceneObjectPart(localID);
if (part == null) 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_ScriptErrorMessage += "SceneObjectPart unavailable. Script NOT started.\n";
m_ScriptFailCount++; m_ScriptFailCount++;
return false; return false;

View File

@ -96,7 +96,6 @@ namespace OpenSim.ScriptEngine.Engines.DotNetEngine
RegionInfo.Executors = new Dictionary<string, IScriptExecutor>(); RegionInfo.Executors = new Dictionary<string, IScriptExecutor>();
RegionInfo.CommandProviders = new Dictionary<string, IScriptCommandProvider>(); RegionInfo.CommandProviders = new Dictionary<string, IScriptCommandProvider>();
RegionInfo.EventProviders = new Dictionary<string, IScriptEventProvider>(); RegionInfo.EventProviders = new Dictionary<string, IScriptEventProvider>();
RegionInfo.Logger = LogManager.GetLogger("SECS.DotNetEngine.RegionInfo");
} }
public void Initialise(Scene scene, IConfigSource source) public void Initialise(Scene scene, IConfigSource source)

View File

@ -48,7 +48,6 @@ namespace OpenSim.ScriptEngine.Shared
public Dictionary<string, IScriptCompiler> Compilers; public Dictionary<string, IScriptCompiler> Compilers;
public Dictionary<string, IScriptScheduler> Schedulers; public Dictionary<string, IScriptScheduler> Schedulers;
public Dictionary<string, IScriptCommandProvider> CommandProviders; public Dictionary<string, IScriptCommandProvider> CommandProviders;
public ILog Logger;
public void Executors_Execute(EventParams p) public void Executors_Execute(EventParams p)
{ {

View File

@ -29,6 +29,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
using log4net;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Region.ScriptEngine.Interfaces; using OpenSim.Region.ScriptEngine.Interfaces;
using OpenSim.Region.ScriptEngine.Shared.ScriptBase; using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
@ -38,6 +39,8 @@ namespace OpenSim.ScriptEngine.Shared
{ {
public struct ScriptStructure public struct ScriptStructure
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public RegionInfoStructure RegionInfo; public RegionInfoStructure RegionInfo;
public ScriptMetaData ScriptMetaData; public ScriptMetaData ScriptMetaData;
@ -91,8 +94,7 @@ namespace OpenSim.ScriptEngine.Shared
if (!InternalFunctions.ContainsKey(FunctionName)) if (!InternalFunctions.ContainsKey(FunctionName))
{ {
// TODO: Send message in-world // TODO: Send message in-world
//RegionInfo.Scene. m_log.ErrorFormat("[{0}] Script function \"{1}\" was not found.", Name, FunctionName);
RegionInfo.Logger.ErrorFormat("[{0}] Script function \"{1}\" was not found.", Name, FunctionName);
return; return;
} }
@ -103,7 +105,7 @@ namespace OpenSim.ScriptEngine.Shared
} }
catch (Exception e) catch (Exception e)
{ {
RegionInfo.Logger.ErrorFormat("[{0}] Execute \"{1}\" failed: {2}", Name, FunctionName, e.ToString()); m_log.ErrorFormat("[{0}] Execute \"{1}\" failed: {2}", Name, FunctionName, e.ToString());
} }
} }
} }
@ -126,8 +128,8 @@ namespace OpenSim.ScriptEngine.Shared
if (!InternalFunctions.ContainsKey(mi.Name)) if (!InternalFunctions.ContainsKey(mi.Name))
InternalFunctions.Add(mi.Name, Delegate.CreateDelegate(scriptObjectType, ScriptObject, mi)); InternalFunctions.Add(mi.Name, Delegate.CreateDelegate(scriptObjectType, ScriptObject, mi));
else else
RegionInfo.Logger.ErrorFormat("[{0}] Error: Script function \"{1}\" is already added. We do not support overloading.", m_log.ErrorFormat("[{0}] Error: Script function \"{1}\" is already added. We do not support overloading.",
Name, mi.Name); Name, mi.Name);
} }
} }
} }