aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-11-22 04:11:03 +0000
committerJustin Clark-Casey (justincc)2012-11-22 04:11:03 +0000
commitcf03d6ea9223e71c27ca91633a30abcf1368ec58 (patch)
tree633becd54bea45479837debfeea41f73fabe4cda /OpenSim/Framework
parentfactor out common HandleShow code for "show uptime" (diff)
downloadopensim-SC_OLD-cf03d6ea9223e71c27ca91633a30abcf1368ec58.zip
opensim-SC_OLD-cf03d6ea9223e71c27ca91633a30abcf1368ec58.tar.gz
opensim-SC_OLD-cf03d6ea9223e71c27ca91633a30abcf1368ec58.tar.bz2
opensim-SC_OLD-cf03d6ea9223e71c27ca91633a30abcf1368ec58.tar.xz
Factor out common registration of "show uptime" command
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Servers/BaseOpenSimServer.cs130
-rw-r--r--OpenSim/Framework/Servers/ServerBase.cs12
2 files changed, 76 insertions, 66 deletions
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
index 4f9ac08..019b68b 100644
--- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs
+++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
@@ -118,78 +118,76 @@ namespace OpenSim.Framework.Servers
118 /// </summary> 118 /// </summary>
119 protected virtual void StartupSpecific() 119 protected virtual void StartupSpecific()
120 { 120 {
121 if (m_console != null) 121 if (m_console == null)
122 { 122 return;
123 ILoggerRepository repository = LogManager.GetRepository();
124 IAppender[] appenders = repository.GetAppenders();
125 123
126 foreach (IAppender appender in appenders) 124 ILoggerRepository repository = LogManager.GetRepository();
127 { 125 IAppender[] appenders = repository.GetAppenders();
128 if (appender.Name == "Console")
129 {
130 m_consoleAppender = (OpenSimAppender)appender;
131 break;
132 }
133 }
134 126
135 if (null == m_consoleAppender) 127 foreach (IAppender appender in appenders)
136 { 128 {
137 Notice("No appender named Console found (see the log4net config file for this executable)!"); 129 if (appender.Name == "Console")
138 }
139 else
140 { 130 {
141 // FIXME: This should be done through an interface rather than casting. 131 m_consoleAppender = (OpenSimAppender)appender;
142 m_consoleAppender.Console = (ConsoleBase)m_console; 132 break;
143
144 // If there is no threshold set then the threshold is effectively everything.
145 if (null == m_consoleAppender.Threshold)
146 m_consoleAppender.Threshold = Level.All;
147
148 Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold));
149 } 133 }
134 }
135
136 if (null == m_consoleAppender)
137 {
138 Notice("No appender named Console found (see the log4net config file for this executable)!");
139 }
140 else
141 {
142 // FIXME: This should be done through an interface rather than casting.
143 m_consoleAppender.Console = (ConsoleBase)m_console;
150 144
151 m_console.Commands.AddCommand("General", false, "quit", 145 // If there is no threshold set then the threshold is effectively everything.
152 "quit", 146 if (null == m_consoleAppender.Threshold)
153 "Quit the application", HandleQuit); 147 m_consoleAppender.Threshold = Level.All;
154 148
155 m_console.Commands.AddCommand("General", false, "shutdown", 149 Notice(String.Format("Console log level is {0}", m_consoleAppender.Threshold));
156 "shutdown",
157 "Quit the application", HandleQuit);
158
159 m_console.Commands.AddCommand("General", false, "set log level",
160 "set log level <level>",
161 "Set the console logging level", HandleLogLevel);
162
163 m_console.Commands.AddCommand("General", false, "show info",
164 "show info",
165 "Show general information about the server", HandleShow);
166
167 m_console.Commands.AddCommand("General", false, "show threads",
168 "show threads",
169 "Show thread status", HandleShow);
170
171 m_console.Commands.AddCommand("General", false, "show uptime",
172 "show uptime",
173 "Show server uptime", HandleShow);
174
175 m_console.Commands.AddCommand("General", false, "show version",
176 "show version",
177 "Show server version", HandleShow);
178
179 m_console.Commands.AddCommand("General", false, "threads abort",
180 "threads abort <thread-id>",
181 "Abort a managed thread. Use \"show threads\" to find possible threads.", HandleThreadsAbort);
182
183 m_console.Commands.AddCommand("General", false, "threads show",
184 "threads show",
185 "Show thread status. Synonym for \"show threads\"",
186 (string module, string[] args) => Notice(GetThreadsReport()));
187
188 m_console.Commands.AddCommand("General", false, "force gc",
189 "force gc",
190 "Manually invoke runtime garbage collection. For debugging purposes",
191 HandleForceGc);
192 } 150 }
151
152 RegisterCommonCommands();
153
154 m_console.Commands.AddCommand("General", false, "quit",
155 "quit",
156 "Quit the application", HandleQuit);
157
158 m_console.Commands.AddCommand("General", false, "shutdown",
159 "shutdown",
160 "Quit the application", HandleQuit);
161
162 m_console.Commands.AddCommand("General", false, "set log level",
163 "set log level <level>",
164 "Set the console logging level", HandleLogLevel);
165
166 m_console.Commands.AddCommand("General", false, "show info",
167 "show info",
168 "Show general information about the server", HandleShow);
169
170 m_console.Commands.AddCommand("General", false, "show threads",
171 "show threads",
172 "Show thread status", HandleShow);
173
174 m_console.Commands.AddCommand("General", false, "show version",
175 "show version",
176 "Show server version", HandleShow);
177
178 m_console.Commands.AddCommand("General", false, "threads abort",
179 "threads abort <thread-id>",
180 "Abort a managed thread. Use \"show threads\" to find possible threads.", HandleThreadsAbort);
181
182 m_console.Commands.AddCommand("General", false, "threads show",
183 "threads show",
184 "Show thread status. Synonym for \"show threads\"",
185 (string module, string[] args) => Notice(GetThreadsReport()));
186
187 m_console.Commands.AddCommand("General", false, "force gc",
188 "force gc",
189 "Manually invoke runtime garbage collection. For debugging purposes",
190 HandleForceGc);
193 } 191 }
194 192
195 private void HandleForceGc(string module, string[] args) 193 private void HandleForceGc(string module, string[] args)
diff --git a/OpenSim/Framework/Servers/ServerBase.cs b/OpenSim/Framework/Servers/ServerBase.cs
index afe1f73..0835aad 100644
--- a/OpenSim/Framework/Servers/ServerBase.cs
+++ b/OpenSim/Framework/Servers/ServerBase.cs
@@ -49,6 +49,18 @@ namespace OpenSim.Framework.Servers
49 m_startuptime = DateTime.Now; 49 m_startuptime = DateTime.Now;
50 } 50 }
51 51
52 /// <summary>
53 /// Register common commands once m_console has been set if it is going to be set
54 /// </summary>
55 public void RegisterCommonCommands()
56 {
57 if (m_console == null)
58 return;
59
60 m_console.Commands.AddCommand(
61 "General", false, "show uptime", "show uptime", "Show server uptime", HandleShow);
62 }
63
52 public virtual void HandleShow(string module, string[] cmd) 64 public virtual void HandleShow(string module, string[] cmd)
53 { 65 {
54 List<string> args = new List<string>(cmd); 66 List<string> args = new List<string>(cmd);