aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/BaseOpenSimServer.cs
diff options
context:
space:
mode:
authorMelanie Thielker2009-02-07 12:25:39 +0000
committerMelanie Thielker2009-02-07 12:25:39 +0000
commit54c6a920baa0ef02a9ea09e08cc1effcef3b0a3a (patch)
treef606cbdbc383ec21fee28f0a1454140a1c714278 /OpenSim/Framework/Servers/BaseOpenSimServer.cs
parentThank you dslake for a patch that: (diff)
downloadopensim-SC-54c6a920baa0ef02a9ea09e08cc1effcef3b0a3a.zip
opensim-SC-54c6a920baa0ef02a9ea09e08cc1effcef3b0a3a.tar.gz
opensim-SC-54c6a920baa0ef02a9ea09e08cc1effcef3b0a3a.tar.bz2
opensim-SC-54c6a920baa0ef02a9ea09e08cc1effcef3b0a3a.tar.xz
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.
Diffstat (limited to 'OpenSim/Framework/Servers/BaseOpenSimServer.cs')
-rw-r--r--OpenSim/Framework/Servers/BaseOpenSimServer.cs119
1 files changed, 54 insertions, 65 deletions
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
98 /// <summary> 98 /// <summary>
99 /// Must be overriden by child classes for their own server specific startup behaviour. 99 /// Must be overriden by child classes for their own server specific startup behaviour.
100 /// </summary> 100 /// </summary>
101 protected abstract void StartupSpecific(); 101 protected virtual void StartupSpecific()
102 {
103 if (m_console != null)
104 {
105 SetConsoleLogLevel(new string[] { "ALL" });
106
107 m_console.Commands.AddCommand("base", "quit",
108 "quit",
109 "Quit the application", HandleQuit);
110
111 m_console.Commands.AddCommand("base", "shutdown",
112 "shutdown",
113 "Quit the application", HandleQuit);
114
115 m_console.Commands.AddCommand("base", "set log level",
116 "set log level <level>",
117 "Set the console logging level", HandleLogLevel);
118
119 m_console.Commands.AddCommand("base", "show info",
120 "show info",
121 "Show general information", HandleShow);
122
123 m_console.Commands.AddCommand("base", "show stats",
124 "show stats",
125 "Show statistics", HandleShow);
126
127 m_console.Commands.AddCommand("base", "show threads",
128 "show threads",
129 "Show thread status", HandleShow);
130
131 m_console.Commands.AddCommand("base", "show uptime",
132 "show uptime",
133 "Show server uptime", HandleShow);
134
135 m_console.Commands.AddCommand("base", "show version",
136 "show version",
137 "Show server version", HandleShow);
138 }
139 }
102 140
103 /// <summary> 141 /// <summary>
104 /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing 142 /// Should be overriden and referenced by descendents if they need to perform extra shutdown processing
@@ -212,6 +250,8 @@ namespace OpenSim.Framework.Servers
212 return; 250 return;
213 } 251 }
214 252
253 consoleAppender.Console = m_console;
254
215 if (setParams.Length > 0) 255 if (setParams.Length > 0)
216 { 256 {
217 Level consoleLevel = repository.LevelMap[setParams[0]]; 257 Level consoleLevel = repository.LevelMap[setParams[0]];
@@ -261,56 +301,18 @@ namespace OpenSim.Framework.Servers
261 Environment.Exit(0); 301 Environment.Exit(0);
262 } 302 }
263 303
264 /// <summary> 304 private void HandleQuit(string module, string[] args)
265 /// Runs commands issued by the server console from the operator
266 /// </summary>
267 /// <param name="command">The first argument of the parameter (the command)</param>
268 /// <param name="cmdparams">Additional arguments passed to the command</param>
269 public virtual void RunCmd(string command, string[] cmdparams)
270 { 305 {
271 switch (command) 306 Shutdown();
272 {
273 case "help":
274 ShowHelp(cmdparams);
275 Notice("");
276 break;
277
278 case "set":
279 Set(cmdparams);
280 break;
281
282 case "show":
283 if (cmdparams.Length > 0)
284 {
285 Show(cmdparams);
286 }
287 break;
288
289 case "quit":
290 case "shutdown":
291 Shutdown();
292 break;
293 }
294 } 307 }
295 308
296 /// <summary> 309 private void HandleLogLevel(string module, string[] cmd)
297 /// Set an OpenSim parameter
298 /// </summary>
299 /// <param name="setArgs">
300 /// The arguments given to the set command.
301 /// </param>
302 public virtual void Set(string[] setArgs)
303 { 310 {
304 // Temporary while we only have one command which takes at least two parameters 311 if (cmd.Length > 3)
305 if (setArgs.Length < 2)
306 return;
307
308 if (setArgs[0] == "log" && setArgs[1] == "level")
309 { 312 {
310 string[] setParams = new string[setArgs.Length - 2]; 313 string level = cmd[3];
311 Array.Copy(setArgs, 2, setParams, 0, setArgs.Length - 2);
312 314
313 SetConsoleLogLevel(setParams); 315 SetConsoleLogLevel(new string[] { level });
314 } 316 }
315 } 317 }
316 318
@@ -324,18 +326,6 @@ namespace OpenSim.Framework.Servers
324 326
325 if (helpArgs.Length == 0) 327 if (helpArgs.Length == 0)
326 { 328 {
327 List<string> helpTopics = GetHelpTopics();
328
329 if (helpTopics.Count > 0)
330 {
331 Notice(
332 "As well as the help information below, you can also type help <topic> to get more information on the following areas:");
333 Notice(string.Format(" {0}", string.Join(", ", helpTopics.ToArray())));
334 Notice("");
335 }
336
337 Notice("quit - equivalent to shutdown.");
338
339 Notice("set log level [level] - change the console logging level only. For example, off or debug."); 329 Notice("set log level [level] - change the console logging level only. For example, off or debug.");
340 Notice("show info - show server information (e.g. startup path)."); 330 Notice("show info - show server information (e.g. startup path).");
341 331
@@ -345,21 +335,20 @@ namespace OpenSim.Framework.Servers
345 Notice("show threads - list tracked threads"); 335 Notice("show threads - list tracked threads");
346 Notice("show uptime - show server startup time and uptime."); 336 Notice("show uptime - show server startup time and uptime.");
347 Notice("show version - show server version."); 337 Notice("show version - show server version.");
348 Notice("shutdown - shutdown the server.");
349 Notice(""); 338 Notice("");
350 339
351 return; 340 return;
352 } 341 }
353 } 342 }
354 343
355 /// <summary> 344 public virtual void HandleShow(string module, string[] cmd)
356 /// Outputs to the console information about the region
357 /// </summary>
358 /// <param name="showParams">
359 /// What information to display (valid arguments are "uptime", "users", ...)
360 /// </param>
361 public virtual void Show(string[] showParams)
362 { 345 {
346 List<string> args = new List<string>(cmd);
347
348 args.RemoveAt(0);
349
350 string[] showParams = args.ToArray();
351
363 switch (showParams[0]) 352 switch (showParams[0])
364 { 353 {
365 case "info": 354 case "info":