Limit formatting of local console output to actual logging messages.

The formatting of lines with the help of a regular expression match will be done only for output with an explicitly given logging level.
This fixes the issue of colons being added to help texts on the local console.
viewer-2-initial-appearance
Marck 2010-09-19 13:26:06 +02:00 committed by Justin Clark-Casey (justincc)
parent 4a0911bdbd
commit 211ea5d521
1 changed files with 17 additions and 13 deletions

View File

@ -44,6 +44,7 @@ namespace OpenSim.Framework.Console
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// private readonly object m_syncRoot = new object(); // private readonly object m_syncRoot = new object();
private const string LOGLEVEL_NONE = "(none)";
private int y = -1; private int y = -1;
private int cp = 0; private int cp = 0;
@ -277,14 +278,16 @@ namespace OpenSim.Framework.Console
} }
private void WriteLocalText(string text, string level) private void WriteLocalText(string text, string level)
{
string outText = text;
if (level != LOGLEVEL_NONE)
{ {
string regex = @"^(?<Front>.*?)\[(?<Category>[^\]]+)\]:?(?<End>.*)"; string regex = @"^(?<Front>.*?)\[(?<Category>[^\]]+)\]:?(?<End>.*)";
Regex RE = new Regex(regex, RegexOptions.Multiline); Regex RE = new Regex(regex, RegexOptions.Multiline);
MatchCollection matches = RE.Matches(text); MatchCollection matches = RE.Matches(text);
string outText = text;
if (matches.Count == 1) if (matches.Count == 1)
{ {
outText = matches[0].Groups["End"].Value; outText = matches[0].Groups["End"].Value;
@ -295,6 +298,7 @@ namespace OpenSim.Framework.Console
matches[0].Groups["Category"].Value); matches[0].Groups["Category"].Value);
System.Console.Write("]:"); System.Console.Write("]:");
} }
}
if (level == "error") if (level == "error")
WriteColorText(ConsoleColor.Red, outText); WriteColorText(ConsoleColor.Red, outText);
@ -308,7 +312,7 @@ namespace OpenSim.Framework.Console
public override void Output(string text) public override void Output(string text)
{ {
Output(text, "normal"); Output(text, LOGLEVEL_NONE);
} }
public override void Output(string text, string level) public override void Output(string text, string level)