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.
This commit is contained in:
Justin Clark-Casey (justincc)
2012-12-12 23:13:34 +00:00
parent 418c0cb01d
commit 047270bdc8
4 changed files with 113 additions and 17 deletions

View File

@@ -304,7 +304,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
MainConsole.Instance.Commands.AddCommand(
"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.",
HandleShowScripts);
@@ -323,22 +323,30 @@ namespace OpenSim.Region.ScriptEngine.XEngine
MainConsole.Instance.Commands.AddCommand(
"Scripts", false, "scripts resume", "scripts resume [<script-item-uuid>]", "Resumes all suspended scripts",
"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.",
(module, cmdparams) => HandleScriptsAction(cmdparams, HandleResumeScript));
MainConsole.Instance.Commands.AddCommand(
"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.",
(module, cmdparams) => HandleScriptsAction(cmdparams, HandleStopScript));
MainConsole.Instance.Commands.AddCommand(
"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.",
(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(
// "Debug", false, "debug xengine", "debug xengine [<level>]",
// "Turn on detailed xengine debugging.",
@@ -347,6 +355,41 @@ namespace OpenSim.Region.ScriptEngine.XEngine
// 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>
/// Change debug level
/// </summary>
@@ -418,7 +461,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
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;
}