aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Console
diff options
context:
space:
mode:
authorAdam Frisby2007-07-20 01:21:39 +0000
committerAdam Frisby2007-07-20 01:21:39 +0000
commitf5b24b66799c4f31a792b70e2eb246f0e58b5254 (patch)
treeb3c14d34d2ec7eb536fb5f7223eed2e0bfac23e3 /OpenSim/Framework/Console
parent*Added new config files into share -- cut down to 256 for practicality reasons (diff)
downloadopensim-SC-f5b24b66799c4f31a792b70e2eb246f0e58b5254.zip
opensim-SC-f5b24b66799c4f31a792b70e2eb246f0e58b5254.tar.gz
opensim-SC-f5b24b66799c4f31a792b70e2eb246f0e58b5254.tar.bz2
opensim-SC-f5b24b66799c4f31a792b70e2eb246f0e58b5254.tar.xz
* New log functions which include the module name as an argument.
Diffstat (limited to 'OpenSim/Framework/Console')
-rw-r--r--OpenSim/Framework/Console/LogBase.cs134
1 files changed, 134 insertions, 0 deletions
diff --git a/OpenSim/Framework/Console/LogBase.cs b/OpenSim/Framework/Console/LogBase.cs
index 1eb6ff0..db76861 100644
--- a/OpenSim/Framework/Console/LogBase.cs
+++ b/OpenSim/Framework/Console/LogBase.cs
@@ -90,36 +90,142 @@ namespace OpenSim.Framework.Console
90 return; 90 return;
91 } 91 }
92 92
93 /// <summary>
94 /// Sends a warning to the current log output
95 /// </summary>
96 /// <param name="format">The message to send</param>
97 /// <param name="args">WriteLine-style message arguments</param>
93 public void Warn(string format, params object[] args) 98 public void Warn(string format, params object[] args)
94 { 99 {
95 WriteNewLine(ConsoleColor.Yellow, format, args); 100 WriteNewLine(ConsoleColor.Yellow, format, args);
96 return; 101 return;
97 } 102 }
98 103
104 /// <summary>
105 /// Sends a warning to the current log 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 Warn(string sender, string format, params object[] args)
111 {
112 int colIdx = (sender.GetHashCode() % 6) + 9;
113 ConsoleColor col = (ConsoleColor)colIdx;
114
115 WritePrefixLine(col, sender);
116 WriteNewLine(ConsoleColor.Yellow, format, args);
117 return;
118 }
119
120 /// <summary>
121 /// Sends a notice to the current log output
122 /// </summary>
123 /// <param name="format">The message to send</param>
124 /// <param name="args">WriteLine-style message arguments</param>
99 public void Notice(string format, params object[] args) 125 public void Notice(string format, params object[] args)
100 { 126 {
101 WriteNewLine(ConsoleColor.White, format, args); 127 WriteNewLine(ConsoleColor.White, format, args);
102 return; 128 return;
103 } 129 }
104 130
131 /// <summary>
132 /// Sends a notice to the current log output
133 /// </summary>
134 /// <param name="sender">The module that sent this message</param>
135 /// <param name="format">The message to send</param>
136 /// <param name="args">WriteLine-style message arguments</param>
137 public void Notice(string sender, string format, params object[] args)
138 {
139 int colIdx = (sender.GetHashCode() % 6) + 9;
140 ConsoleColor col = (ConsoleColor)colIdx;
141
142 WritePrefixLine(col, sender);
143 WriteNewLine(ConsoleColor.White, format, args);
144 return;
145 }
146
147 /// <summary>
148 /// Sends an error to the current log output
149 /// </summary>
150 /// <param name="format">The message to send</param>
151 /// <param name="args">WriteLine-style message arguments</param>
105 public void Error(string format, params object[] args) 152 public void Error(string format, params object[] args)
106 { 153 {
107 WriteNewLine(ConsoleColor.Red, format, args); 154 WriteNewLine(ConsoleColor.Red, format, args);
108 return; 155 return;
109 } 156 }
110 157
158 /// <summary>
159 /// Sends an error to the current log output
160 /// </summary>
161 /// <param name="sender">The module that sent this message</param>
162 /// <param name="format">The message to send</param>
163 /// <param name="args">WriteLine-style message arguments</param>
164 public void Error(string sender, string format, params object[] args)
165 {
166 int colIdx = (sender.GetHashCode() % 6) + 9;
167 ConsoleColor col = (ConsoleColor)colIdx;
168
169 WritePrefixLine(col, sender);
170 WriteNewLine(ConsoleColor.Red, format, args);
171 return;
172 }
173
174 /// <summary>
175 /// Sends a informational message to the current log output
176 /// </summary>
177 /// <param name="format">The message to send</param>
178 /// <param name="args">WriteLine-style message arguments</param>
111 public void Verbose(string format, params object[] args) 179 public void Verbose(string format, params object[] args)
112 { 180 {
113 WriteNewLine(ConsoleColor.Gray, format, args); 181 WriteNewLine(ConsoleColor.Gray, format, args);
114 return; 182 return;
115 } 183 }
116 184
185 /// <summary>
186 /// Sends an informational message to the current log output
187 /// </summary>
188 /// <param name="sender">The module that sent this message</param>
189 /// <param name="format">The message to send</param>
190 /// <param name="args">WriteLine-style message arguments</param>
191 public void Verbose(string sender, string format, params object[] args)
192 {
193 int colIdx = (sender.GetHashCode() % 6) + 9;
194 ConsoleColor col = (ConsoleColor)colIdx;
195
196 WritePrefixLine(col, sender);
197 WriteNewLine(ConsoleColor.Gray, format, args);
198 return;
199 }
200
201 /// <summary>
202 /// Sends a status message to the current log output
203 /// </summary>
204 /// <param name="format">The message to send</param>
205 /// <param name="args">WriteLine-style message arguments</param>
117 public void Status(string format, params object[] args) 206 public void Status(string format, params object[] args)
118 { 207 {
119 WriteNewLine(ConsoleColor.Blue, format, args); 208 WriteNewLine(ConsoleColor.Blue, format, args);
120 return; 209 return;
121 } 210 }
122 211
212 /// <summary>
213 /// Sends a status message to the current log output
214 /// </summary>
215 /// <param name="sender">The module that sent this message</param>
216 /// <param name="format">The message to send</param>
217 /// <param name="args">WriteLine-style message arguments</param>
218 public void Status(string sender, string format, params object[] args)
219 {
220 int colIdx = (sender.GetHashCode() % 6) + 9;
221 ConsoleColor col = (ConsoleColor)colIdx;
222
223 WritePrefixLine(col, sender);
224 WriteNewLine(ConsoleColor.Blue, format, args);
225 return;
226 }
227
228
123 private void WriteNewLine(ConsoleColor color, string format, params object[] args) 229 private void WriteNewLine(ConsoleColor color, string format, params object[] args)
124 { 230 {
125 Log.WriteLine(format, args); 231 Log.WriteLine(format, args);
@@ -141,6 +247,34 @@ namespace OpenSim.Framework.Console
141 return; 247 return;
142 } 248 }
143 249
250 private void WritePrefixLine(ConsoleColor color, string sender)
251 {
252 Log.WriteLine("[" + sender + "] ");
253 Log.Flush();
254
255 System.Console.Write("[");
256
257 if (!m_silent)
258 {
259 try
260 {
261 System.Console.ForegroundColor = color;
262 System.Console.Write(sender);
263 System.Console.ResetColor();
264 }
265 catch (ArgumentNullException)
266 {
267 // Some older systems dont support coloured text.
268 System.Console.WriteLine(sender);
269 }
270 }
271
272 System.Console.Write("] ");
273
274 return;
275 }
276
277
144 public string ReadLine() 278 public string ReadLine()
145 { 279 {
146 string TempStr = System.Console.ReadLine(); 280 string TempStr = System.Console.ReadLine();