From 54c6a920baa0ef02a9ea09e08cc1effcef3b0a3a Mon Sep 17 00:00:00 2001
From: Melanie Thielker
Date: Sat, 7 Feb 2009 12:25:39 +0000
Subject: Replace the console for all OpenSim apps with a new console featuring
command line editing, context sensitive help (press ? at any time), command
line history, a new plugin command system and new appender features thet let
you type while the console is scrolling. Seamlessly integrates the ICommander
interfaces.
---
OpenSim/Framework/Servers/BaseOpenSimServer.cs | 119 +++++++++++--------------
1 file changed, 54 insertions(+), 65 deletions(-)
(limited to 'OpenSim/Framework/Servers')
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
index 473991a..cc75df4 100644
--- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs
+++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
@@ -98,7 +98,45 @@ namespace OpenSim.Framework.Servers
///
/// Must be overriden by child classes for their own server specific startup behaviour.
///
- protected abstract void StartupSpecific();
+ protected virtual void StartupSpecific()
+ {
+ if (m_console != null)
+ {
+ SetConsoleLogLevel(new string[] { "ALL" });
+
+ m_console.Commands.AddCommand("base", "quit",
+ "quit",
+ "Quit the application", HandleQuit);
+
+ m_console.Commands.AddCommand("base", "shutdown",
+ "shutdown",
+ "Quit the application", HandleQuit);
+
+ m_console.Commands.AddCommand("base", "set log level",
+ "set log level ",
+ "Set the console logging level", HandleLogLevel);
+
+ m_console.Commands.AddCommand("base", "show info",
+ "show info",
+ "Show general information", HandleShow);
+
+ m_console.Commands.AddCommand("base", "show stats",
+ "show stats",
+ "Show statistics", HandleShow);
+
+ m_console.Commands.AddCommand("base", "show threads",
+ "show threads",
+ "Show thread status", HandleShow);
+
+ m_console.Commands.AddCommand("base", "show uptime",
+ "show uptime",
+ "Show server uptime", HandleShow);
+
+ m_console.Commands.AddCommand("base", "show version",
+ "show version",
+ "Show server version", HandleShow);
+ }
+ }
///
/// Should be overriden and referenced by descendents if they need to perform extra shutdown processing
@@ -212,6 +250,8 @@ namespace OpenSim.Framework.Servers
return;
}
+ consoleAppender.Console = m_console;
+
if (setParams.Length > 0)
{
Level consoleLevel = repository.LevelMap[setParams[0]];
@@ -261,56 +301,18 @@ namespace OpenSim.Framework.Servers
Environment.Exit(0);
}
- ///
- /// Runs commands issued by the server console from the operator
- ///
- /// The first argument of the parameter (the command)
- /// Additional arguments passed to the command
- public virtual void RunCmd(string command, string[] cmdparams)
+ private void HandleQuit(string module, string[] args)
{
- switch (command)
- {
- case "help":
- ShowHelp(cmdparams);
- Notice("");
- break;
-
- case "set":
- Set(cmdparams);
- break;
-
- case "show":
- if (cmdparams.Length > 0)
- {
- Show(cmdparams);
- }
- break;
-
- case "quit":
- case "shutdown":
- Shutdown();
- break;
- }
+ Shutdown();
}
- ///
- /// Set an OpenSim parameter
- ///
- ///
- /// The arguments given to the set command.
- ///
- public virtual void Set(string[] setArgs)
+ private void HandleLogLevel(string module, string[] cmd)
{
- // Temporary while we only have one command which takes at least two parameters
- if (setArgs.Length < 2)
- return;
-
- if (setArgs[0] == "log" && setArgs[1] == "level")
+ if (cmd.Length > 3)
{
- string[] setParams = new string[setArgs.Length - 2];
- Array.Copy(setArgs, 2, setParams, 0, setArgs.Length - 2);
+ string level = cmd[3];
- SetConsoleLogLevel(setParams);
+ SetConsoleLogLevel(new string[] { level });
}
}
@@ -324,18 +326,6 @@ namespace OpenSim.Framework.Servers
if (helpArgs.Length == 0)
{
- List helpTopics = GetHelpTopics();
-
- if (helpTopics.Count > 0)
- {
- Notice(
- "As well as the help information below, you can also type help to get more information on the following areas:");
- Notice(string.Format(" {0}", string.Join(", ", helpTopics.ToArray())));
- Notice("");
- }
-
- Notice("quit - equivalent to shutdown.");
-
Notice("set log level [level] - change the console logging level only. For example, off or debug.");
Notice("show info - show server information (e.g. startup path).");
@@ -345,21 +335,20 @@ namespace OpenSim.Framework.Servers
Notice("show threads - list tracked threads");
Notice("show uptime - show server startup time and uptime.");
Notice("show version - show server version.");
- Notice("shutdown - shutdown the server.");
Notice("");
return;
}
}
- ///
- /// Outputs to the console information about the region
- ///
- ///
- /// What information to display (valid arguments are "uptime", "users", ...)
- ///
- public virtual void Show(string[] showParams)
+ public virtual void HandleShow(string module, string[] cmd)
{
+ List args = new List(cmd);
+
+ args.RemoveAt(0);
+
+ string[] showParams = args.ToArray();
+
switch (showParams[0])
{
case "info":
--
cgit v1.1