diff options
author | onefang | 2021-08-26 06:21:19 +1000 |
---|---|---|
committer | onefang | 2021-08-26 06:21:19 +1000 |
commit | cdfbb899f1112dab44d5490838765e9bd73bc60e (patch) | |
tree | 52cddd0b76e7ad8544a0ada533f91bb5fc402025 /OpenSim/Framework/Console | |
parent | Still failing to reconnect for dbCount(), just set the fucking timeout to a y... (diff) | |
parent | Don't strip (OWNER) out of script error report. (diff) | |
download | opensim-SC-cdfbb899f1112dab44d5490838765e9bd73bc60e.zip opensim-SC-cdfbb899f1112dab44d5490838765e9bd73bc60e.tar.gz opensim-SC-cdfbb899f1112dab44d5490838765e9bd73bc60e.tar.bz2 opensim-SC-cdfbb899f1112dab44d5490838765e9bd73bc60e.tar.xz |
Merge branch 'switch' into Domme.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Console/CommandConsole.cs | 5 | ||||
-rw-r--r-- | OpenSim/Framework/Console/ConsoleBase.cs | 108 | ||||
-rw-r--r-- | OpenSim/Framework/Console/ConsoleUtil.cs | 20 | ||||
-rw-r--r-- | OpenSim/Framework/Console/LocalConsole.cs | 58 | ||||
-rw-r--r-- | OpenSim/Framework/Console/MockConsole.cs | 20 | ||||
-rw-r--r-- | OpenSim/Framework/Console/OpenSimAppender.cs | 4 | ||||
-rw-r--r-- | OpenSim/Framework/Console/RemoteConsole.cs | 44 |
7 files changed, 188 insertions, 71 deletions
diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index 52360b4..d2b6618 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs | |||
@@ -36,6 +36,7 @@ using System.Text.RegularExpressions; | |||
36 | using System.Threading; | 36 | using System.Threading; |
37 | using log4net; | 37 | using log4net; |
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using Nini.Config; | ||
39 | 40 | ||
40 | namespace OpenSim.Framework.Console | 41 | namespace OpenSim.Framework.Console |
41 | { | 42 | { |
@@ -789,5 +790,9 @@ namespace OpenSim.Framework.Console | |||
789 | } | 790 | } |
790 | return cmdinput; | 791 | return cmdinput; |
791 | } | 792 | } |
793 | |||
794 | public virtual void ReadConfig(IConfigSource configSource) | ||
795 | { | ||
796 | } | ||
792 | } | 797 | } |
793 | } | 798 | } |
diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs index 64cddea..8748b25 100644 --- a/OpenSim/Framework/Console/ConsoleBase.cs +++ b/OpenSim/Framework/Console/ConsoleBase.cs | |||
@@ -35,13 +35,39 @@ using log4net; | |||
35 | 35 | ||
36 | namespace OpenSim.Framework.Console | 36 | namespace OpenSim.Framework.Console |
37 | { | 37 | { |
38 | public class ConsoleBase | 38 | public class ConsoleLevel |
39 | { | ||
40 | public string m_string; | ||
41 | |||
42 | ConsoleLevel(string v) | ||
43 | { | ||
44 | m_string = v; | ||
45 | } | ||
46 | |||
47 | static public implicit operator ConsoleLevel(string s) | ||
48 | { | ||
49 | return new ConsoleLevel(s); | ||
50 | } | ||
51 | |||
52 | public static string ToString(ConsoleLevel s) | ||
53 | { | ||
54 | return s.m_string; | ||
55 | } | ||
56 | |||
57 | public override string ToString() | ||
58 | { | ||
59 | return m_string; | ||
60 | } | ||
61 | } | ||
62 | |||
63 | |||
64 | public class ConsoleBase : IConsole | ||
39 | { | 65 | { |
40 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 66 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
41 | 67 | ||
42 | protected string prompt = "# "; | 68 | protected string prompt = "# "; |
43 | 69 | ||
44 | public object ConsoleScene { get; set; } | 70 | public IScene ConsoleScene { get; set; } |
45 | 71 | ||
46 | public string DefaultPrompt { get; set; } | 72 | public string DefaultPrompt { get; set; } |
47 | 73 | ||
@@ -58,27 +84,47 @@ namespace OpenSim.Framework.Console | |||
58 | { | 84 | { |
59 | } | 85 | } |
60 | 86 | ||
61 | public virtual void Output(string text, string level) | 87 | public void Output(string format) |
62 | { | 88 | { |
63 | Output(text); | 89 | System.Console.WriteLine(format); |
64 | } | 90 | } |
65 | 91 | ||
66 | public virtual void Output(string text) | 92 | public virtual void Output(string format, params object[] components) |
67 | { | 93 | { |
68 | System.Console.WriteLine(text); | 94 | string level = null; |
69 | } | 95 | if (components != null && components.Length > 0) |
96 | { | ||
97 | if (components[0] == null || components[0] is ConsoleLevel) | ||
98 | { | ||
99 | if (components[0] is ConsoleLevel) | ||
100 | level = ((ConsoleLevel)components[0]).ToString(); | ||
70 | 101 | ||
71 | public virtual void OutputFormat(string format, params object[] components) | 102 | if (components.Length > 1) |
72 | { | 103 | { |
73 | Output(string.Format(format, components)); | 104 | object[] tmp = new object[components.Length - 1]; |
105 | Array.Copy(components, 1, tmp, 0, components.Length - 1); | ||
106 | components = tmp; | ||
107 | } | ||
108 | else | ||
109 | components = null; | ||
110 | } | ||
111 | |||
112 | } | ||
113 | string text; | ||
114 | if (components == null || components.Length == 0) | ||
115 | text = format; | ||
116 | else | ||
117 | text = String.Format(format, components); | ||
118 | |||
119 | System.Console.WriteLine(text); | ||
74 | } | 120 | } |
75 | 121 | ||
76 | public string CmdPrompt(string p) | 122 | public string Prompt(string p) |
77 | { | 123 | { |
78 | return ReadLine(String.Format("{0}: ", p), false, true); | 124 | return ReadLine(String.Format("{0}: ", p), false, true); |
79 | } | 125 | } |
80 | 126 | ||
81 | public string CmdPrompt(string p, string def) | 127 | public string Prompt(string p, string def) |
82 | { | 128 | { |
83 | string ret = ReadLine(String.Format("{0} [{1}]: ", p, def), false, true); | 129 | string ret = ReadLine(String.Format("{0} [{1}]: ", p, def), false, true); |
84 | if (ret == String.Empty) | 130 | if (ret == String.Empty) |
@@ -87,14 +133,14 @@ namespace OpenSim.Framework.Console | |||
87 | return ret; | 133 | return ret; |
88 | } | 134 | } |
89 | 135 | ||
90 | public string CmdPrompt(string p, List<char> excludedCharacters) | 136 | public string Prompt(string p, List<char> excludedCharacters) |
91 | { | 137 | { |
92 | bool itisdone = false; | 138 | bool itisdone = false; |
93 | string ret = String.Empty; | 139 | string ret = String.Empty; |
94 | while (!itisdone) | 140 | while (!itisdone) |
95 | { | 141 | { |
96 | itisdone = true; | 142 | itisdone = true; |
97 | ret = CmdPrompt(p); | 143 | ret = Prompt(p); |
98 | 144 | ||
99 | foreach (char c in excludedCharacters) | 145 | foreach (char c in excludedCharacters) |
100 | { | 146 | { |
@@ -109,27 +155,34 @@ namespace OpenSim.Framework.Console | |||
109 | return ret; | 155 | return ret; |
110 | } | 156 | } |
111 | 157 | ||
112 | public string CmdPrompt(string p, string def, List<char> excludedCharacters) | 158 | public virtual string Prompt(string p, string def, List<char> excludedCharacters, bool echo = true) |
113 | { | 159 | { |
114 | bool itisdone = false; | 160 | bool itisdone = false; |
115 | string ret = String.Empty; | 161 | string ret = String.Empty; |
116 | while (!itisdone) | 162 | while (!itisdone) |
117 | { | 163 | { |
118 | itisdone = true; | 164 | itisdone = true; |
119 | ret = CmdPrompt(p, def); | ||
120 | 165 | ||
121 | if (ret == String.Empty) | 166 | if (def == null) |
167 | ret = ReadLine(String.Format("{0}: ", p), false, echo); | ||
168 | else | ||
169 | ret = ReadLine(String.Format("{0} [{1}]: ", p, def), false, echo); | ||
170 | |||
171 | if (ret == String.Empty && def != null) | ||
122 | { | 172 | { |
123 | ret = def; | 173 | ret = def; |
124 | } | 174 | } |
125 | else | 175 | else |
126 | { | 176 | { |
127 | foreach (char c in excludedCharacters) | 177 | if (excludedCharacters != null) |
128 | { | 178 | { |
129 | if (ret.Contains(c.ToString())) | 179 | foreach (char c in excludedCharacters) |
130 | { | 180 | { |
131 | System.Console.WriteLine("The character \"" + c.ToString() + "\" is not permitted."); | 181 | if (ret.Contains(c.ToString())) |
132 | itisdone = false; | 182 | { |
183 | System.Console.WriteLine("The character \"" + c.ToString() + "\" is not permitted."); | ||
184 | itisdone = false; | ||
185 | } | ||
133 | } | 186 | } |
134 | } | 187 | } |
135 | } | 188 | } |
@@ -139,14 +192,14 @@ namespace OpenSim.Framework.Console | |||
139 | } | 192 | } |
140 | 193 | ||
141 | // Displays a command prompt and returns a default value, user may only enter 1 of 2 options | 194 | // Displays a command prompt and returns a default value, user may only enter 1 of 2 options |
142 | public string CmdPrompt(string prompt, string defaultresponse, List<string> options) | 195 | public virtual string Prompt(string prompt, string defaultresponse, List<string> options) |
143 | { | 196 | { |
144 | bool itisdone = false; | 197 | bool itisdone = false; |
145 | string optstr = String.Empty; | 198 | string optstr = String.Empty; |
146 | foreach (string s in options) | 199 | foreach (string s in options) |
147 | optstr += " " + s; | 200 | optstr += " " + s; |
148 | 201 | ||
149 | string temp = CmdPrompt(prompt, defaultresponse); | 202 | string temp = Prompt(prompt, defaultresponse); |
150 | while (itisdone == false) | 203 | while (itisdone == false) |
151 | { | 204 | { |
152 | if (options.Contains(temp)) | 205 | if (options.Contains(temp)) |
@@ -156,19 +209,12 @@ namespace OpenSim.Framework.Console | |||
156 | else | 209 | else |
157 | { | 210 | { |
158 | System.Console.WriteLine("Valid options are" + optstr); | 211 | System.Console.WriteLine("Valid options are" + optstr); |
159 | temp = CmdPrompt(prompt, defaultresponse); | 212 | temp = Prompt(prompt, defaultresponse); |
160 | } | 213 | } |
161 | } | 214 | } |
162 | return temp; | 215 | return temp; |
163 | } | 216 | } |
164 | 217 | ||
165 | // Displays a prompt and waits for the user to enter a string, then returns that string | ||
166 | // (Done with no echo and suitable for passwords) | ||
167 | public string PasswdPrompt(string p) | ||
168 | { | ||
169 | return ReadLine(String.Format("{0}: ", p), false, false); | ||
170 | } | ||
171 | |||
172 | public virtual string ReadLine(string p, bool isCommand, bool e) | 218 | public virtual string ReadLine(string p, bool isCommand, bool e) |
173 | { | 219 | { |
174 | System.Console.Write("{0}", p); | 220 | System.Console.Write("{0}", p); |
diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs index bfa05a2..2f73a8d 100644 --- a/OpenSim/Framework/Console/ConsoleUtil.cs +++ b/OpenSim/Framework/Console/ConsoleUtil.cs | |||
@@ -75,7 +75,7 @@ namespace OpenSim.Framework.Console | |||
75 | { | 75 | { |
76 | if (File.Exists(path)) | 76 | if (File.Exists(path)) |
77 | { | 77 | { |
78 | console.OutputFormat("File {0} already exists. Please move or remove it.", path); | 78 | console.Output("File {0} already exists. Please move or remove it.", path); |
79 | return false; | 79 | return false; |
80 | } | 80 | } |
81 | 81 | ||
@@ -97,7 +97,7 @@ namespace OpenSim.Framework.Console | |||
97 | if (!UUID.TryParse(rawUuid, out uuid)) | 97 | if (!UUID.TryParse(rawUuid, out uuid)) |
98 | { | 98 | { |
99 | if (console != null) | 99 | if (console != null) |
100 | console.OutputFormat("ERROR: {0} is not a valid uuid", rawUuid); | 100 | console.Output("ERROR: {0} is not a valid uuid", rawUuid); |
101 | 101 | ||
102 | return false; | 102 | return false; |
103 | } | 103 | } |
@@ -110,7 +110,7 @@ namespace OpenSim.Framework.Console | |||
110 | if (!uint.TryParse(rawLocalId, out localId)) | 110 | if (!uint.TryParse(rawLocalId, out localId)) |
111 | { | 111 | { |
112 | if (console != null) | 112 | if (console != null) |
113 | console.OutputFormat("ERROR: {0} is not a valid local id", localId); | 113 | console.Output("ERROR: {0} is not a valid local id", localId); |
114 | 114 | ||
115 | return false; | 115 | return false; |
116 | } | 116 | } |
@@ -118,7 +118,7 @@ namespace OpenSim.Framework.Console | |||
118 | if (localId == 0) | 118 | if (localId == 0) |
119 | { | 119 | { |
120 | if (console != null) | 120 | if (console != null) |
121 | console.OutputFormat("ERROR: {0} is not a valid local id - it must be greater than 0", localId); | 121 | console.Output("ERROR: {0} is not a valid local id - it must be greater than 0", localId); |
122 | 122 | ||
123 | return false; | 123 | return false; |
124 | } | 124 | } |
@@ -150,7 +150,7 @@ namespace OpenSim.Framework.Console | |||
150 | } | 150 | } |
151 | 151 | ||
152 | if (console != null) | 152 | if (console != null) |
153 | console.OutputFormat("ERROR: {0} is not a valid UUID or local id", rawId); | 153 | console.Output("ERROR: {0} is not a valid UUID or local id", rawId); |
154 | 154 | ||
155 | return false; | 155 | return false; |
156 | } | 156 | } |
@@ -167,7 +167,7 @@ namespace OpenSim.Framework.Console | |||
167 | if (!bool.TryParse(rawConsoleString, out b)) | 167 | if (!bool.TryParse(rawConsoleString, out b)) |
168 | { | 168 | { |
169 | if (console != null) | 169 | if (console != null) |
170 | console.OutputFormat("ERROR: {0} is not a true or false value", rawConsoleString); | 170 | console.Output("ERROR: {0} is not a true or false value", rawConsoleString); |
171 | 171 | ||
172 | return false; | 172 | return false; |
173 | } | 173 | } |
@@ -187,7 +187,7 @@ namespace OpenSim.Framework.Console | |||
187 | if (!int.TryParse(rawConsoleInt, out i)) | 187 | if (!int.TryParse(rawConsoleInt, out i)) |
188 | { | 188 | { |
189 | if (console != null) | 189 | if (console != null) |
190 | console.OutputFormat("ERROR: {0} is not a valid integer", rawConsoleInt); | 190 | console.Output("ERROR: {0} is not a valid integer", rawConsoleInt); |
191 | 191 | ||
192 | return false; | 192 | return false; |
193 | } | 193 | } |
@@ -207,7 +207,7 @@ namespace OpenSim.Framework.Console | |||
207 | if (!float.TryParse(rawConsoleInput, out i)) | 207 | if (!float.TryParse(rawConsoleInput, out i)) |
208 | { | 208 | { |
209 | if (console != null) | 209 | if (console != null) |
210 | console.OutputFormat("ERROR: {0} is not a valid float", rawConsoleInput); | 210 | console.Output("ERROR: {0} is not a valid float", rawConsoleInput); |
211 | 211 | ||
212 | return false; | 212 | return false; |
213 | } | 213 | } |
@@ -227,7 +227,7 @@ namespace OpenSim.Framework.Console | |||
227 | if (!double.TryParse(rawConsoleInput, out i)) | 227 | if (!double.TryParse(rawConsoleInput, out i)) |
228 | { | 228 | { |
229 | if (console != null) | 229 | if (console != null) |
230 | console.OutputFormat("ERROR: {0} is not a valid double", rawConsoleInput); | 230 | console.Output("ERROR: {0} is not a valid double", rawConsoleInput); |
231 | 231 | ||
232 | return false; | 232 | return false; |
233 | } | 233 | } |
@@ -249,7 +249,7 @@ namespace OpenSim.Framework.Console | |||
249 | if (i < 0) | 249 | if (i < 0) |
250 | { | 250 | { |
251 | if (console != null) | 251 | if (console != null) |
252 | console.OutputFormat("ERROR: {0} is not a positive integer", rawConsoleInt); | 252 | console.Output("ERROR: {0} is not a positive integer", rawConsoleInt); |
253 | 253 | ||
254 | return false; | 254 | return false; |
255 | } | 255 | } |
diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index 476fc15..39351e1 100644 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs | |||
@@ -46,6 +46,7 @@ namespace OpenSim.Framework.Console | |||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | private string m_historyPath; | 47 | private string m_historyPath; |
48 | private bool m_historyEnable; | 48 | private bool m_historyEnable; |
49 | private bool m_historytimestamps; | ||
49 | 50 | ||
50 | // private readonly object m_syncRoot = new object(); | 51 | // private readonly object m_syncRoot = new object(); |
51 | private const string LOGLEVEL_NONE = "(none)"; | 52 | private const string LOGLEVEL_NONE = "(none)"; |
@@ -98,15 +99,30 @@ namespace OpenSim.Framework.Console | |||
98 | string m_historyFile = startupConfig.GetString("ConsoleHistoryFile", Path.Combine(Util.logsDir(), "OpenSimConsoleHistory.txt")); | 99 | string m_historyFile = startupConfig.GetString("ConsoleHistoryFile", Path.Combine(Util.logsDir(), "OpenSimConsoleHistory.txt")); |
99 | int m_historySize = startupConfig.GetInt("ConsoleHistoryFileLines", 100); | 100 | int m_historySize = startupConfig.GetInt("ConsoleHistoryFileLines", 100); |
100 | m_historyPath = Path.GetFullPath(m_historyFile); | 101 | m_historyPath = Path.GetFullPath(m_historyFile); |
101 | m_log.InfoFormat("[LOCAL CONSOLE]: Persistent command line history is Enabled, up to {0} lines from file {1}", m_historySize, m_historyPath); | 102 | m_historytimestamps = startupConfig.GetBoolean("ConsoleHistoryTimeStamp", false); |
103 | m_log.InfoFormat("[LOCAL CONSOLE]: Persistent command line history is Enabled, up to {0} lines from file {1} {2} timestamps", | ||
104 | m_historySize, m_historyPath, m_historytimestamps?"with":"without"); | ||
102 | 105 | ||
103 | if (File.Exists(m_historyPath)) | 106 | if (File.Exists(m_historyPath)) |
104 | { | 107 | { |
108 | List<string> originallines = new List<string>(); | ||
105 | using (StreamReader history_file = new StreamReader(m_historyPath)) | 109 | using (StreamReader history_file = new StreamReader(m_historyPath)) |
106 | { | 110 | { |
107 | string line; | 111 | string line; |
108 | while ((line = history_file.ReadLine()) != null) | 112 | while ((line = history_file.ReadLine()) != null) |
109 | { | 113 | { |
114 | originallines.Add(line); | ||
115 | if(line.StartsWith("[")) | ||
116 | { | ||
117 | int indx = line.IndexOf("]:> "); | ||
118 | if(indx > 0) | ||
119 | { | ||
120 | if(indx + 4 >= line.Length) | ||
121 | line = String.Empty; | ||
122 | else | ||
123 | line = line.Substring(indx + 4); | ||
124 | } | ||
125 | } | ||
110 | m_history.Add(line); | 126 | m_history.Add(line); |
111 | } | 127 | } |
112 | } | 128 | } |
@@ -114,11 +130,14 @@ namespace OpenSim.Framework.Console | |||
114 | if (m_history.Count > m_historySize) | 130 | if (m_history.Count > m_historySize) |
115 | { | 131 | { |
116 | while (m_history.Count > m_historySize) | 132 | while (m_history.Count > m_historySize) |
133 | { | ||
117 | m_history.RemoveAt(0); | 134 | m_history.RemoveAt(0); |
135 | originallines.RemoveAt(0); | ||
136 | } | ||
118 | 137 | ||
119 | using (StreamWriter history_file = new StreamWriter(m_historyPath)) | 138 | using (StreamWriter history_file = new StreamWriter(m_historyPath)) |
120 | { | 139 | { |
121 | foreach (string line in m_history) | 140 | foreach (string line in originallines) |
122 | { | 141 | { |
123 | history_file.WriteLine(line); | 142 | history_file.WriteLine(line); |
124 | } | 143 | } |
@@ -141,6 +160,8 @@ namespace OpenSim.Framework.Console | |||
141 | m_history.Add(text); | 160 | m_history.Add(text); |
142 | if (m_historyEnable) | 161 | if (m_historyEnable) |
143 | { | 162 | { |
163 | if (m_historytimestamps) | ||
164 | text = String.Format("[{0} {1}]:> {2}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), text); | ||
144 | File.AppendAllText(m_historyPath, text + Environment.NewLine); | 165 | File.AppendAllText(m_historyPath, text + Environment.NewLine); |
145 | } | 166 | } |
146 | } | 167 | } |
@@ -338,7 +359,7 @@ namespace OpenSim.Framework.Console | |||
338 | { | 359 | { |
339 | string outText = text; | 360 | string outText = text; |
340 | 361 | ||
341 | if (level != LOGLEVEL_NONE) | 362 | if (level != null) |
342 | { | 363 | { |
343 | MatchCollection matches = m_categoryRegex.Matches(text); | 364 | MatchCollection matches = m_categoryRegex.Matches(text); |
344 | 365 | ||
@@ -368,13 +389,33 @@ namespace OpenSim.Framework.Console | |||
368 | System.Console.WriteLine(); | 389 | System.Console.WriteLine(); |
369 | } | 390 | } |
370 | 391 | ||
371 | public override void Output(string text) | 392 | public override void Output(string format, params object[] components) |
372 | { | 393 | { |
373 | Output(text, LOGLEVEL_NONE); | 394 | string level = null; |
374 | } | 395 | if(components != null && components.Length > 0) |
396 | { | ||
397 | if(components[0] == null || components[0] is ConsoleLevel) | ||
398 | { | ||
399 | if(components[0] is ConsoleLevel) | ||
400 | level = ((ConsoleLevel)components[0]).ToString(); | ||
401 | |||
402 | if (components.Length > 1) | ||
403 | { | ||
404 | object[] tmp = new object[components.Length - 1]; | ||
405 | Array.Copy(components, 1, tmp, 0, components.Length - 1); | ||
406 | components = tmp; | ||
407 | } | ||
408 | else | ||
409 | components = null; | ||
410 | } | ||
411 | |||
412 | } | ||
413 | string text; | ||
414 | if (components == null || components.Length == 0) | ||
415 | text = format; | ||
416 | else | ||
417 | text = String.Format(format, components); | ||
375 | 418 | ||
376 | public override void Output(string text, string level) | ||
377 | { | ||
378 | FireOnOutput(text); | 419 | FireOnOutput(text); |
379 | 420 | ||
380 | lock (m_commandLine) | 421 | lock (m_commandLine) |
@@ -382,7 +423,6 @@ namespace OpenSim.Framework.Console | |||
382 | if (m_cursorYPosition == -1) | 423 | if (m_cursorYPosition == -1) |
383 | { | 424 | { |
384 | WriteLocalText(text, level); | 425 | WriteLocalText(text, level); |
385 | |||
386 | return; | 426 | return; |
387 | } | 427 | } |
388 | 428 | ||
diff --git a/OpenSim/Framework/Console/MockConsole.cs b/OpenSim/Framework/Console/MockConsole.cs index e1ff720..d314047 100644 --- a/OpenSim/Framework/Console/MockConsole.cs +++ b/OpenSim/Framework/Console/MockConsole.cs | |||
@@ -30,6 +30,7 @@ using System.Threading; | |||
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Text; | 31 | using System.Text; |
32 | using System.Xml; | 32 | using System.Xml; |
33 | using Nini.Config; | ||
33 | 34 | ||
34 | namespace OpenSim.Framework.Console | 35 | namespace OpenSim.Framework.Console |
35 | { | 36 | { |
@@ -56,23 +57,24 @@ namespace OpenSim.Framework.Console | |||
56 | 57 | ||
57 | public string ReadLine(string p, bool isCommand, bool e) { return ""; } | 58 | public string ReadLine(string p, bool isCommand, bool e) { return ""; } |
58 | 59 | ||
59 | public object ConsoleScene { | 60 | public IScene ConsoleScene { |
60 | get { return null; } | 61 | get { return null; } |
61 | set {} | 62 | set {} |
62 | } | 63 | } |
63 | 64 | ||
64 | public void Output(string text, string level) {} | 65 | public void Output(string format) { } |
65 | public void Output(string text) {} | 66 | public void Output(string format, params object[] components) { } |
66 | public void OutputFormat(string format, params object[] components) {} | ||
67 | 67 | ||
68 | public string CmdPrompt(string p) { return ""; } | 68 | public string Prompt(string p) { return ""; } |
69 | public string CmdPrompt(string p, string def) { return ""; } | 69 | public string Prompt(string p, string def) { return ""; } |
70 | public string CmdPrompt(string p, List<char> excludedCharacters) { return ""; } | 70 | public string Prompt(string p, List<char> excludedCharacters) { return ""; } |
71 | public string CmdPrompt(string p, string def, List<char> excludedCharacters) { return ""; } | 71 | public string Prompt(string p, string def, List<char> excludedCharacters, bool echo) { return ""; } |
72 | 72 | ||
73 | public string CmdPrompt(string prompt, string defaultresponse, List<string> options) { return ""; } | 73 | public string Prompt(string prompt, string defaultresponse, List<string> options) { return ""; } |
74 | 74 | ||
75 | public string PasswdPrompt(string p) { return ""; } | 75 | public string PasswdPrompt(string p) { return ""; } |
76 | |||
77 | public void ReadConfig(IConfigSource configSource) { } | ||
76 | } | 78 | } |
77 | 79 | ||
78 | public class MockCommands : ICommands | 80 | public class MockCommands : ICommands |
diff --git a/OpenSim/Framework/Console/OpenSimAppender.cs b/OpenSim/Framework/Console/OpenSimAppender.cs index 72a251e..39a550b 100644 --- a/OpenSim/Framework/Console/OpenSimAppender.cs +++ b/OpenSim/Framework/Console/OpenSimAppender.cs | |||
@@ -55,12 +55,14 @@ namespace OpenSim.Framework.Console | |||
55 | { | 55 | { |
56 | if (m_console != null) | 56 | if (m_console != null) |
57 | { | 57 | { |
58 | string level = "normal"; | 58 | ConsoleLevel level; |
59 | 59 | ||
60 | if (le.Level == Level.Error) | 60 | if (le.Level == Level.Error) |
61 | level = "error"; | 61 | level = "error"; |
62 | else if (le.Level == Level.Warn) | 62 | else if (le.Level == Level.Warn) |
63 | level = "warn"; | 63 | level = "warn"; |
64 | else | ||
65 | level = "normal"; | ||
64 | 66 | ||
65 | m_console.Output(loggingMessage, level); | 67 | m_console.Output(loggingMessage, level); |
66 | } | 68 | } |
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index f59c902..889df36 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs | |||
@@ -46,6 +46,8 @@ namespace OpenSim.Framework.Console | |||
46 | // | 46 | // |
47 | public class RemoteConsole : CommandConsole | 47 | public class RemoteConsole : CommandConsole |
48 | { | 48 | { |
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
49 | // Connection specific data, indexed by a session ID | 51 | // Connection specific data, indexed by a session ID |
50 | // we create when a client connects. | 52 | // we create when a client connects. |
51 | protected class ConsoleConnection | 53 | protected class ConsoleConnection |
@@ -153,7 +155,7 @@ namespace OpenSim.Framework.Console | |||
153 | m_expireTimer.Start(); | 155 | m_expireTimer.Start(); |
154 | } | 156 | } |
155 | 157 | ||
156 | public void ReadConfig(IConfigSource config) | 158 | public override void ReadConfig(IConfigSource config) |
157 | { | 159 | { |
158 | m_Config = config; | 160 | m_Config = config; |
159 | 161 | ||
@@ -188,13 +190,41 @@ namespace OpenSim.Framework.Console | |||
188 | m_Server.AddHTTPHandler("/SessionCommand/", HandleHttpSessionCommand); | 190 | m_Server.AddHTTPHandler("/SessionCommand/", HandleHttpSessionCommand); |
189 | } | 191 | } |
190 | 192 | ||
191 | public override void Output(string text, string level) | 193 | public override void Output(string format, params object[] components) |
192 | { | 194 | { |
195 | string level = null; | ||
196 | if (components != null && components.Length > 0) | ||
197 | { | ||
198 | if (components[0] == null || components[0] is ConsoleLevel) | ||
199 | { | ||
200 | if (components[0] is ConsoleLevel) | ||
201 | level = ((ConsoleLevel)components[0]).ToString(); | ||
202 | |||
203 | if (components.Length > 1) | ||
204 | { | ||
205 | object[] tmp = new object[components.Length - 1]; | ||
206 | Array.Copy(components, 1, tmp, 0, components.Length - 1); | ||
207 | components = tmp; | ||
208 | } | ||
209 | else | ||
210 | components = null; | ||
211 | } | ||
212 | } | ||
213 | |||
214 | string text; | ||
215 | if (components == null || components.Length == 0) | ||
216 | text = format; | ||
217 | else | ||
218 | text = String.Format(format, components); | ||
219 | |||
193 | Output(text, level, false, false, false); | 220 | Output(text, level, false, false, false); |
194 | } | 221 | } |
195 | 222 | ||
196 | protected void Output(string text, string level, bool isPrompt, bool isCommand, bool isInput) | 223 | protected void Output(string text, string level, bool isPrompt, bool isCommand, bool isInput) |
197 | { | 224 | { |
225 | if (level == null) | ||
226 | level = String.Empty; | ||
227 | |||
198 | // Increment the line number. It was 0 and they start at 1 | 228 | // Increment the line number. It was 0 and they start at 1 |
199 | // so we need to pre-increment. | 229 | // so we need to pre-increment. |
200 | m_lineNumber++; | 230 | m_lineNumber++; |
@@ -228,12 +258,6 @@ namespace OpenSim.Framework.Console | |||
228 | System.Console.WriteLine(text.Trim()); | 258 | System.Console.WriteLine(text.Trim()); |
229 | } | 259 | } |
230 | 260 | ||
231 | public override void Output(string text) | ||
232 | { | ||
233 | // Output plain (non-logging style) text. | ||
234 | Output(text, String.Empty, false, false, false); | ||
235 | } | ||
236 | |||
237 | public override string ReadLine(string p, bool isCommand, bool e) | 261 | public override string ReadLine(string p, bool isCommand, bool e) |
238 | { | 262 | { |
239 | // Output the prompt an prepare to wait. This | 263 | // Output the prompt an prepare to wait. This |
@@ -403,7 +427,7 @@ namespace OpenSim.Framework.Console | |||
403 | string uri = "/ReadResponses/" + sessionID.ToString() + "/"; | 427 | string uri = "/ReadResponses/" + sessionID.ToString() + "/"; |
404 | 428 | ||
405 | m_Server.AddPollServiceHTTPHandler( | 429 | m_Server.AddPollServiceHTTPHandler( |
406 | uri, new PollServiceEventArgs(null, uri, HasEvents, GetEvents, NoEvents, sessionID,25000)); // 25 secs timeout | 430 | uri, new PollServiceEventArgs(null, uri, HasEvents, GetEvents, NoEvents, null, sessionID,25000)); // 25 secs timeout |
407 | 431 | ||
408 | // Our reply is an XML document. | 432 | // Our reply is an XML document. |
409 | // TODO: Change this to Linq.Xml | 433 | // TODO: Change this to Linq.Xml |
@@ -687,7 +711,6 @@ namespace OpenSim.Framework.Console | |||
687 | result["int_response_code"] = 200; | 711 | result["int_response_code"] = 200; |
688 | result["content_type"] = "application/xml"; | 712 | result["content_type"] = "application/xml"; |
689 | result["keepalive"] = false; | 713 | result["keepalive"] = false; |
690 | result["reusecontext"] = false; | ||
691 | result = CheckOrigin(result); | 714 | result = CheckOrigin(result); |
692 | 715 | ||
693 | return result; | 716 | return result; |
@@ -713,7 +736,6 @@ namespace OpenSim.Framework.Console | |||
713 | result["int_response_code"] = 200; | 736 | result["int_response_code"] = 200; |
714 | result["content_type"] = "text/xml"; | 737 | result["content_type"] = "text/xml"; |
715 | result["keepalive"] = false; | 738 | result["keepalive"] = false; |
716 | result["reusecontext"] = false; | ||
717 | result = CheckOrigin(result); | 739 | result = CheckOrigin(result); |
718 | 740 | ||
719 | return result; | 741 | return result; |