Add "debug script log" command to allow setting a numeric debug level on individual IScriptInstances for debugging purposes.
Current, state changes and event fires can be logged for individual scripts. See command help for more details.0.7.4-extended
parent
48486b137a
commit
e6f475735f
|
@ -78,7 +78,7 @@ namespace OpenSim.Framework.Console
|
||||||
if (!UUID.TryParse(rawUuid, out uuid))
|
if (!UUID.TryParse(rawUuid, out uuid))
|
||||||
{
|
{
|
||||||
if (console != null)
|
if (console != null)
|
||||||
console.OutputFormat("{0} is not a valid uuid", rawUuid);
|
console.OutputFormat("ERROR: {0} is not a valid uuid", rawUuid);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ namespace OpenSim.Framework.Console
|
||||||
if (!uint.TryParse(rawLocalId, out localId))
|
if (!uint.TryParse(rawLocalId, out localId))
|
||||||
{
|
{
|
||||||
if (console != null)
|
if (console != null)
|
||||||
console.OutputFormat("{0} is not a valid local id", localId);
|
console.OutputFormat("ERROR: {0} is not a valid local id", localId);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ namespace OpenSim.Framework.Console
|
||||||
if (localId == 0)
|
if (localId == 0)
|
||||||
{
|
{
|
||||||
if (console != null)
|
if (console != null)
|
||||||
console.OutputFormat("{0} is not a valid local id - it must be greater than 0", localId);
|
console.OutputFormat("ERROR: {0} is not a valid local id - it must be greater than 0", localId);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -131,11 +131,31 @@ namespace OpenSim.Framework.Console
|
||||||
}
|
}
|
||||||
|
|
||||||
if (console != null)
|
if (console != null)
|
||||||
console.OutputFormat("{0} is not a valid UUID or local id", rawId);
|
console.OutputFormat("ERROR: {0} is not a valid UUID or local id", rawId);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Convert a minimum vector input from the console to an OpenMetaverse.Vector3
|
||||||
|
/// </summary>
|
||||||
|
/// <param name='console'>Can be null if no console is available.</param>
|
||||||
|
/// <param name='rawConsoleVector'>/param>
|
||||||
|
/// <param name='vector'></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool TryParseConsoleInt(ICommandConsole console, string rawConsoleInt, out int i)
|
||||||
|
{
|
||||||
|
if (!int.TryParse(rawConsoleInt, out i))
|
||||||
|
{
|
||||||
|
if (console != null)
|
||||||
|
console.OutputFormat("ERROR: {0} is not a valid integer", rawConsoleInt);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Convert a minimum vector input from the console to an OpenMetaverse.Vector3
|
/// Convert a minimum vector input from the console to an OpenMetaverse.Vector3
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -58,6 +58,18 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IScriptInstance
|
public interface IScriptInstance
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Debug level for this script instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Level == 0, no extra data is logged.
|
||||||
|
/// Level >= 1, state changes are logged.
|
||||||
|
/// Level >= 2, event firing is logged.
|
||||||
|
/// <value>
|
||||||
|
/// The debug level.
|
||||||
|
/// </value>
|
||||||
|
int DebugLevel { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Is the script currently running?
|
/// Is the script currently running?
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -93,6 +93,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||||
private UUID m_CurrentStateHash;
|
private UUID m_CurrentStateHash;
|
||||||
private UUID m_RegionID;
|
private UUID m_RegionID;
|
||||||
|
|
||||||
|
public int DebugLevel { get; set; }
|
||||||
|
|
||||||
public Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> LineMap { get; set; }
|
public Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> LineMap { get; set; }
|
||||||
|
|
||||||
private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>();
|
private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>();
|
||||||
|
@ -704,20 +706,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||||
m_CollisionInQueue = false;
|
m_CollisionInQueue = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this);
|
SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
|
||||||
|
|
||||||
|
if (DebugLevel >= 2)
|
||||||
|
m_log.DebugFormat(
|
||||||
|
"[SCRIPT INSTANCE]: Processing event {0} for {1}/{2}({3})/{4}({5}) @ {6}/{7}",
|
||||||
|
data.EventName,
|
||||||
|
ScriptName,
|
||||||
|
part.Name,
|
||||||
|
part.LocalId,
|
||||||
|
part.ParentGroup.Name,
|
||||||
|
part.ParentGroup.UUID,
|
||||||
|
part.AbsolutePosition,
|
||||||
|
part.ParentGroup.Scene.Name);
|
||||||
|
|
||||||
m_DetectParams = data.DetectParams;
|
m_DetectParams = data.DetectParams;
|
||||||
|
|
||||||
if (data.EventName == "state") // Hardcoded state change
|
if (data.EventName == "state") // Hardcoded state change
|
||||||
{
|
{
|
||||||
// m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}",
|
|
||||||
// PrimName, ScriptName, data.Params[0].ToString());
|
|
||||||
State = data.Params[0].ToString();
|
State = data.Params[0].ToString();
|
||||||
|
|
||||||
|
if (DebugLevel >= 1)
|
||||||
|
m_log.DebugFormat(
|
||||||
|
"[SCRIPT INSTANCE]: Changing state to {0} for {1}/{2}({3})/{4}({5}) @ {6}/{7}",
|
||||||
|
State,
|
||||||
|
ScriptName,
|
||||||
|
part.Name,
|
||||||
|
part.LocalId,
|
||||||
|
part.ParentGroup.Name,
|
||||||
|
part.ParentGroup.UUID,
|
||||||
|
part.AbsolutePosition,
|
||||||
|
part.ParentGroup.Scene.Name);
|
||||||
|
|
||||||
AsyncCommandManager.RemoveScript(Engine,
|
AsyncCommandManager.RemoveScript(Engine,
|
||||||
LocalID, ItemID);
|
LocalID, ItemID);
|
||||||
|
|
||||||
SceneObjectPart part = Engine.World.GetSceneObjectPart(
|
|
||||||
LocalID);
|
|
||||||
if (part != null)
|
if (part != null)
|
||||||
{
|
{
|
||||||
part.SetScriptEvents(ItemID,
|
part.SetScriptEvents(ItemID,
|
||||||
|
@ -729,8 +752,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||||
if (Engine.World.PipeEventsForScript(LocalID) ||
|
if (Engine.World.PipeEventsForScript(LocalID) ||
|
||||||
data.EventName == "control") // Don't freeze avies!
|
data.EventName == "control") // Don't freeze avies!
|
||||||
{
|
{
|
||||||
SceneObjectPart part = Engine.World.GetSceneObjectPart(
|
|
||||||
LocalID);
|
|
||||||
// m_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}",
|
||||||
// PrimName, ScriptName, data.EventName, State);
|
// PrimName, ScriptName, data.EventName, State);
|
||||||
|
|
||||||
|
|
|
@ -304,7 +304,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
|
|
||||||
MainConsole.Instance.Commands.AddCommand(
|
MainConsole.Instance.Commands.AddCommand(
|
||||||
"Scripts", false, "scripts show", "scripts show [<script-item-uuid>]", "Show script information",
|
"Scripts", false, "scripts show", "scripts show [<script-item-uuid>]", "Show script information",
|
||||||
"Show information on all scripts known to the script engine."
|
"Show information on all scripts known to the script engine.\n"
|
||||||
+ "If a <script-item-uuid> is given then only information on that script will be shown.",
|
+ "If a <script-item-uuid> is given then only information on that script will be shown.",
|
||||||
HandleShowScripts);
|
HandleShowScripts);
|
||||||
|
|
||||||
|
@ -323,22 +323,30 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
MainConsole.Instance.Commands.AddCommand(
|
MainConsole.Instance.Commands.AddCommand(
|
||||||
"Scripts", false, "scripts resume", "scripts resume [<script-item-uuid>]", "Resumes all suspended scripts",
|
"Scripts", false, "scripts resume", "scripts resume [<script-item-uuid>]", "Resumes all suspended scripts",
|
||||||
"Resumes all currently suspended scripts.\n"
|
"Resumes all currently suspended scripts.\n"
|
||||||
+ "Resumed scripts will process all events accumulated whilst suspended."
|
+ "Resumed scripts will process all events accumulated whilst suspended.\n"
|
||||||
+ "If a <script-item-uuid> is given then only that script will be resumed. Otherwise, all suitable scripts are resumed.",
|
+ "If a <script-item-uuid> is given then only that script will be resumed. Otherwise, all suitable scripts are resumed.",
|
||||||
(module, cmdparams) => HandleScriptsAction(cmdparams, HandleResumeScript));
|
(module, cmdparams) => HandleScriptsAction(cmdparams, HandleResumeScript));
|
||||||
|
|
||||||
MainConsole.Instance.Commands.AddCommand(
|
MainConsole.Instance.Commands.AddCommand(
|
||||||
"Scripts", false, "scripts stop", "scripts stop [<script-item-uuid>]", "Stops all running scripts",
|
"Scripts", false, "scripts stop", "scripts stop [<script-item-uuid>]", "Stops all running scripts",
|
||||||
"Stops all running scripts."
|
"Stops all running scripts.\n"
|
||||||
+ "If a <script-item-uuid> is given then only that script will be stopped. Otherwise, all suitable scripts are stopped.",
|
+ "If a <script-item-uuid> is given then only that script will be stopped. Otherwise, all suitable scripts are stopped.",
|
||||||
(module, cmdparams) => HandleScriptsAction(cmdparams, HandleStopScript));
|
(module, cmdparams) => HandleScriptsAction(cmdparams, HandleStopScript));
|
||||||
|
|
||||||
MainConsole.Instance.Commands.AddCommand(
|
MainConsole.Instance.Commands.AddCommand(
|
||||||
"Scripts", false, "scripts start", "scripts start [<script-item-uuid>]", "Starts all stopped scripts",
|
"Scripts", false, "scripts start", "scripts start [<script-item-uuid>]", "Starts all stopped scripts",
|
||||||
"Starts all stopped scripts."
|
"Starts all stopped scripts.\n"
|
||||||
+ "If a <script-item-uuid> is given then only that script will be started. Otherwise, all suitable scripts are started.",
|
+ "If a <script-item-uuid> is given then only that script will be started. Otherwise, all suitable scripts are started.",
|
||||||
(module, cmdparams) => HandleScriptsAction(cmdparams, HandleStartScript));
|
(module, cmdparams) => HandleScriptsAction(cmdparams, HandleStartScript));
|
||||||
|
|
||||||
|
MainConsole.Instance.Commands.AddCommand(
|
||||||
|
"Scripts", false, "debug script log", "debug scripts log <item-id> <log-level>", "Extra debug logging for a script",
|
||||||
|
"Activates or deactivates extra debug logging for the given script.\n"
|
||||||
|
+ "Level == 0, deactivate extra debug logging.\n"
|
||||||
|
+ "Level >= 1, log state changes.\n"
|
||||||
|
+ "Level >= 2, log event invocations.\n",
|
||||||
|
HandleDebugScriptLogCommand);
|
||||||
|
|
||||||
// MainConsole.Instance.Commands.AddCommand(
|
// MainConsole.Instance.Commands.AddCommand(
|
||||||
// "Debug", false, "debug xengine", "debug xengine [<level>]",
|
// "Debug", false, "debug xengine", "debug xengine [<level>]",
|
||||||
// "Turn on detailed xengine debugging.",
|
// "Turn on detailed xengine debugging.",
|
||||||
|
@ -347,6 +355,41 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
// HandleDebugLevelCommand);
|
// HandleDebugLevelCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HandleDebugScriptLogCommand(string module, string[] args)
|
||||||
|
{
|
||||||
|
if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (args.Length != 5)
|
||||||
|
{
|
||||||
|
MainConsole.Instance.Output("Usage: debug script log <item-id> <log-level>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID itemId;
|
||||||
|
|
||||||
|
if (!ConsoleUtil.TryParseConsoleUuid(MainConsole.Instance, args[3], out itemId))
|
||||||
|
return;
|
||||||
|
|
||||||
|
int newLevel;
|
||||||
|
|
||||||
|
if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, args[4], out newLevel))
|
||||||
|
return;
|
||||||
|
|
||||||
|
IScriptInstance si;
|
||||||
|
|
||||||
|
lock (m_Scripts)
|
||||||
|
{
|
||||||
|
// XXX: We can't give the user feedback on a bad item id because this may apply to a different script
|
||||||
|
// engine
|
||||||
|
if (!m_Scripts.TryGetValue(itemId, out si))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
si.DebugLevel = newLevel;
|
||||||
|
MainConsole.Instance.OutputFormat("Set debug level of {0} {1} to {2}", si.ScriptName, si.ItemID, newLevel);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Change debug level
|
/// Change debug level
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -418,7 +461,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
|
|
||||||
if (!UUID.TryParse(rawItemId, out itemId))
|
if (!UUID.TryParse(rawItemId, out itemId))
|
||||||
{
|
{
|
||||||
MainConsole.Instance.OutputFormat("Error - {0} is not a valid UUID", rawItemId);
|
MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid UUID", rawItemId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue