diff options
author | Melanie Thielker | 2009-05-20 13:50:33 +0000 |
---|---|---|
committer | Melanie Thielker | 2009-05-20 13:50:33 +0000 |
commit | 4065ebff15e228d7227500f3a2275025f5d16966 (patch) | |
tree | 3ffddea94c9fab8218289c5bc4e188e9f52a53c2 /OpenSim/Framework/Console | |
parent | refactoring instantiation of Location object: moving it out of the for (diff) | |
download | opensim-SC-4065ebff15e228d7227500f3a2275025f5d16966.zip opensim-SC-4065ebff15e228d7227500f3a2275025f5d16966.tar.gz opensim-SC-4065ebff15e228d7227500f3a2275025f5d16966.tar.bz2 opensim-SC-4065ebff15e228d7227500f3a2275025f5d16966.tar.xz |
Remove the pre-log4net, discrete output methods from the consoles
Diffstat (limited to 'OpenSim/Framework/Console')
-rw-r--r-- | OpenSim/Framework/Console/ConsoleBase.cs | 148 | ||||
-rw-r--r-- | OpenSim/Framework/Console/ConsolePluginCommand.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Console/LocalConsole.cs | 124 |
3 files changed, 1 insertions, 273 deletions
diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs index dd3c145..0747ae5 100644 --- a/OpenSim/Framework/Console/ConsoleBase.cs +++ b/OpenSim/Framework/Console/ConsoleBase.cs | |||
@@ -58,154 +58,6 @@ namespace OpenSim.Framework.Console | |||
58 | DefaultPrompt = defaultPrompt; | 58 | DefaultPrompt = defaultPrompt; |
59 | } | 59 | } |
60 | 60 | ||
61 | /// <summary> | ||
62 | /// derive an ansi color from a string, ignoring the darker colors. | ||
63 | /// This is used to help automatically bin component tags with colors | ||
64 | /// in various print functions. | ||
65 | /// </summary> | ||
66 | /// <param name="input">arbitrary string for input</param> | ||
67 | /// <returns>an ansii color</returns> | ||
68 | protected virtual ConsoleColor DeriveColor(string input) | ||
69 | { | ||
70 | return ConsoleColor.White; | ||
71 | } | ||
72 | |||
73 | /// <summary> | ||
74 | /// Sends a warning to the current console output | ||
75 | /// </summary> | ||
76 | /// <param name="format">The message to send</param> | ||
77 | /// <param name="args">WriteLine-style message arguments</param> | ||
78 | public void Warn(string format, params object[] args) | ||
79 | { | ||
80 | WriteNewLine(ConsoleColor.Yellow, format, args); | ||
81 | } | ||
82 | |||
83 | /// <summary> | ||
84 | /// Sends a warning to the current console output | ||
85 | /// </summary> | ||
86 | /// <param name="sender">The module that sent this message</param> | ||
87 | /// <param name="format">The message to send</param> | ||
88 | /// <param name="args">WriteLine-style message arguments</param> | ||
89 | public void Warn(string sender, string format, params object[] args) | ||
90 | { | ||
91 | WriteNewLine(DeriveColor(sender), sender, ConsoleColor.Yellow, format, args); | ||
92 | } | ||
93 | |||
94 | /// <summary> | ||
95 | /// Sends a notice to the current console output | ||
96 | /// </summary> | ||
97 | /// <param name="format">The message to send</param> | ||
98 | /// <param name="args">WriteLine-style message arguments</param> | ||
99 | public void Notice(string format, params object[] args) | ||
100 | { | ||
101 | WriteNewLine(ConsoleColor.White, format, args); | ||
102 | } | ||
103 | |||
104 | /// <summary> | ||
105 | /// Sends a notice to the current console output | ||
106 | /// </summary> | ||
107 | /// <param name="sender">The module that sent this message</param> | ||
108 | /// <param name="format">The message to send</param> | ||
109 | /// <param name="args">WriteLine-style message arguments</param> | ||
110 | public void Notice(string sender, string format, params object[] args) | ||
111 | { | ||
112 | WriteNewLine(DeriveColor(sender), sender, ConsoleColor.White, format, args); | ||
113 | } | ||
114 | /// <summary> | ||
115 | /// Sends an error to the current console output | ||
116 | /// </summary> | ||
117 | /// <param name="format">The message to send</param> | ||
118 | /// <param name="args">WriteLine-style message arguments</param> | ||
119 | public void Error(string format, params object[] args) | ||
120 | { | ||
121 | WriteNewLine(ConsoleColor.Red, format, args); | ||
122 | } | ||
123 | |||
124 | /// <summary> | ||
125 | /// Sends an error to the current console output | ||
126 | /// </summary> | ||
127 | /// <param name="sender">The module that sent this message</param> | ||
128 | /// <param name="format">The message to send</param> | ||
129 | /// <param name="args">WriteLine-style message arguments</param> | ||
130 | public void Error(string sender, string format, params object[] args) | ||
131 | { | ||
132 | WriteNewLine(DeriveColor(sender), sender, ConsoleColor.Red, format, args); | ||
133 | } | ||
134 | |||
135 | /// <summary> | ||
136 | /// Sends a status message to the current console output | ||
137 | /// </summary> | ||
138 | /// <param name="format">The message to send</param> | ||
139 | /// <param name="args">WriteLine-style message arguments</param> | ||
140 | public void Status(string format, params object[] args) | ||
141 | { | ||
142 | WriteNewLine(ConsoleColor.Blue, format, args); | ||
143 | } | ||
144 | |||
145 | /// <summary> | ||
146 | /// Sends a status message to the current console output | ||
147 | /// </summary> | ||
148 | /// <param name="sender">The module that sent this message</param> | ||
149 | /// <param name="format">The message to send</param> | ||
150 | /// <param name="args">WriteLine-style message arguments</param> | ||
151 | public void Status(string sender, string format, params object[] args) | ||
152 | { | ||
153 | WriteNewLine(DeriveColor(sender), sender, ConsoleColor.Blue, format, args); | ||
154 | } | ||
155 | |||
156 | [Conditional("DEBUG")] | ||
157 | public void Debug(string format, params object[] args) | ||
158 | { | ||
159 | WriteNewLine(ConsoleColor.Gray, format, args); | ||
160 | } | ||
161 | |||
162 | [Conditional("DEBUG")] | ||
163 | public void Debug(string sender, string format, params object[] args) | ||
164 | { | ||
165 | WriteNewLine(DeriveColor(sender), sender, ConsoleColor.Gray, format, args); | ||
166 | } | ||
167 | |||
168 | protected virtual void WriteNewLine(ConsoleColor senderColor, string sender, ConsoleColor color, string format, params object[] args) | ||
169 | { | ||
170 | WritePrefixLine(senderColor, sender); | ||
171 | WriteConsoleLine(color, format, args); | ||
172 | } | ||
173 | |||
174 | protected virtual void WriteNewLine(ConsoleColor color, string format, params object[] args) | ||
175 | { | ||
176 | WriteConsoleLine(color, format, args); | ||
177 | } | ||
178 | |||
179 | protected virtual void WriteConsoleLine(ConsoleColor color, string format, params object[] args) | ||
180 | { | ||
181 | try | ||
182 | { | ||
183 | System.Console.WriteLine(format, args); | ||
184 | } | ||
185 | catch (ObjectDisposedException) | ||
186 | { | ||
187 | } | ||
188 | } | ||
189 | |||
190 | protected virtual void WritePrefixLine(ConsoleColor color, string sender) | ||
191 | { | ||
192 | try | ||
193 | { | ||
194 | sender = sender.ToUpper(); | ||
195 | |||
196 | System.Console.WriteLine("[" + sender + "] "); | ||
197 | |||
198 | System.Console.Write("["); | ||
199 | |||
200 | System.Console.Write(sender); | ||
201 | |||
202 | System.Console.Write("] \t"); | ||
203 | } | ||
204 | catch (ObjectDisposedException) | ||
205 | { | ||
206 | } | ||
207 | } | ||
208 | |||
209 | public virtual void LockOutput() | 61 | public virtual void LockOutput() |
210 | { | 62 | { |
211 | } | 63 | } |
diff --git a/OpenSim/Framework/Console/ConsolePluginCommand.cs b/OpenSim/Framework/Console/ConsolePluginCommand.cs index bf70645..8b87239 100644 --- a/OpenSim/Framework/Console/ConsolePluginCommand.cs +++ b/OpenSim/Framework/Console/ConsolePluginCommand.cs | |||
@@ -124,7 +124,7 @@ namespace OpenSim.Framework.Console | |||
124 | /// </summary> | 124 | /// </summary> |
125 | public void ShowHelp(ConsoleBase console) | 125 | public void ShowHelp(ConsoleBase console) |
126 | { | 126 | { |
127 | console.Notice(String.Join(" ", m_cmdText) + " - " + m_helpText); | 127 | console.Output(String.Join(" ", m_cmdText) + " - " + m_helpText); |
128 | } | 128 | } |
129 | 129 | ||
130 | /// <summary> | 130 | /// <summary> |
diff --git a/OpenSim/Framework/Console/LocalConsole.cs b/OpenSim/Framework/Console/LocalConsole.cs index 22f10fc..ca57bd6 100644 --- a/OpenSim/Framework/Console/LocalConsole.cs +++ b/OpenSim/Framework/Console/LocalConsole.cs | |||
@@ -62,19 +62,6 @@ namespace OpenSim.Framework.Console | |||
62 | history.Add(text); | 62 | history.Add(text); |
63 | } | 63 | } |
64 | 64 | ||
65 | /// <summary> | ||
66 | /// derive an ansi color from a string, ignoring the darker colors. | ||
67 | /// This is used to help automatically bin component tags with colors | ||
68 | /// in various print functions. | ||
69 | /// </summary> | ||
70 | /// <param name="input">arbitrary string for input</param> | ||
71 | /// <returns>an ansii color</returns> | ||
72 | protected override ConsoleColor DeriveColor(string input) | ||
73 | { | ||
74 | int colIdx = (input.ToUpper().GetHashCode() % 6) + 9; | ||
75 | return (ConsoleColor) colIdx; | ||
76 | } | ||
77 | |||
78 | private int SetCursorTop(int top) | 65 | private int SetCursorTop(int top) |
79 | { | 66 | { |
80 | if (top >= 0 && top < System.Console.BufferHeight) | 67 | if (top >= 0 && top < System.Console.BufferHeight) |
@@ -101,117 +88,6 @@ namespace OpenSim.Framework.Console | |||
101 | } | 88 | } |
102 | } | 89 | } |
103 | 90 | ||
104 | protected override void WriteNewLine(ConsoleColor senderColor, string sender, ConsoleColor color, string format, params object[] args) | ||
105 | { | ||
106 | lock (cmdline) | ||
107 | { | ||
108 | if (y != -1) | ||
109 | { | ||
110 | y=SetCursorTop(y); | ||
111 | System.Console.CursorLeft = 0; | ||
112 | |||
113 | int count = cmdline.Length; | ||
114 | |||
115 | System.Console.Write(" "); | ||
116 | while (count-- > 0) | ||
117 | System.Console.Write(" "); | ||
118 | |||
119 | y=SetCursorTop(y); | ||
120 | System.Console.CursorLeft = 0; | ||
121 | } | ||
122 | WritePrefixLine(senderColor, sender); | ||
123 | WriteConsoleLine(color, format, args); | ||
124 | if (y != -1) | ||
125 | y = System.Console.CursorTop; | ||
126 | } | ||
127 | } | ||
128 | |||
129 | protected override void WriteNewLine(ConsoleColor color, string format, params object[] args) | ||
130 | { | ||
131 | lock (cmdline) | ||
132 | { | ||
133 | if (y != -1) | ||
134 | { | ||
135 | y=SetCursorTop(y); | ||
136 | System.Console.CursorLeft = 0; | ||
137 | |||
138 | int count = cmdline.Length; | ||
139 | |||
140 | System.Console.Write(" "); | ||
141 | while (count-- > 0) | ||
142 | System.Console.Write(" "); | ||
143 | |||
144 | y=SetCursorTop(y); | ||
145 | System.Console.CursorLeft = 0; | ||
146 | } | ||
147 | WriteConsoleLine(color, format, args); | ||
148 | if (y != -1) | ||
149 | y = System.Console.CursorTop; | ||
150 | } | ||
151 | } | ||
152 | |||
153 | protected override void WriteConsoleLine(ConsoleColor color, string format, params object[] args) | ||
154 | { | ||
155 | try | ||
156 | { | ||
157 | lock (m_syncRoot) | ||
158 | { | ||
159 | try | ||
160 | { | ||
161 | if (color != ConsoleColor.White) | ||
162 | System.Console.ForegroundColor = color; | ||
163 | |||
164 | System.Console.WriteLine(format, args); | ||
165 | System.Console.ResetColor(); | ||
166 | } | ||
167 | catch (ArgumentNullException) | ||
168 | { | ||
169 | // Some older systems dont support coloured text. | ||
170 | System.Console.WriteLine(format, args); | ||
171 | } | ||
172 | catch (FormatException) | ||
173 | { | ||
174 | System.Console.WriteLine(args); | ||
175 | } | ||
176 | } | ||
177 | } | ||
178 | catch (ObjectDisposedException) | ||
179 | { | ||
180 | } | ||
181 | } | ||
182 | |||
183 | protected override void WritePrefixLine(ConsoleColor color, string sender) | ||
184 | { | ||
185 | try | ||
186 | { | ||
187 | lock (m_syncRoot) | ||
188 | { | ||
189 | sender = sender.ToUpper(); | ||
190 | |||
191 | System.Console.WriteLine("[" + sender + "] "); | ||
192 | |||
193 | System.Console.Write("["); | ||
194 | |||
195 | try | ||
196 | { | ||
197 | System.Console.ForegroundColor = color; | ||
198 | System.Console.Write(sender); | ||
199 | System.Console.ResetColor(); | ||
200 | } | ||
201 | catch (ArgumentNullException) | ||
202 | { | ||
203 | // Some older systems dont support coloured text. | ||
204 | System.Console.WriteLine(sender); | ||
205 | } | ||
206 | |||
207 | System.Console.Write("] \t"); | ||
208 | } | ||
209 | } | ||
210 | catch (ObjectDisposedException) | ||
211 | { | ||
212 | } | ||
213 | } | ||
214 | |||
215 | private void Show() | 91 | private void Show() |
216 | { | 92 | { |
217 | lock (cmdline) | 93 | lock (cmdline) |