attempt to make our logging at least fail gracefully, we'll see if this helps
parent
980a926a4b
commit
741f753c56
|
@ -14,37 +14,44 @@ namespace OpenSim.Framework.Console
|
||||||
{
|
{
|
||||||
override protected void Append(LoggingEvent le)
|
override protected void Append(LoggingEvent le)
|
||||||
{
|
{
|
||||||
string loggingMessage = RenderLoggingEvent(le);
|
try {
|
||||||
string regex = @"^(?<Front>.*?)\[(?<Category>[^\]]+)\]:?(?<End>.*)";
|
string loggingMessage = RenderLoggingEvent(le);
|
||||||
|
string regex = @"^(?<Front>.*?)\[(?<Category>[^\]]+)\]:?(?<End>.*)";
|
||||||
|
|
||||||
Regex RE = new Regex(regex, RegexOptions.Multiline);
|
|
||||||
MatchCollection matches = RE.Matches(loggingMessage);
|
|
||||||
// Get some direct matches $1 $4 is a
|
|
||||||
if (matches.Count == 1)
|
|
||||||
{
|
|
||||||
System.Console.Write(matches[0].Groups["Front"].Value);
|
|
||||||
System.Console.Write("[");
|
|
||||||
|
|
||||||
WriteColorText(DeriveColor(matches[0].Groups["Category"].Value), matches[0].Groups["Category"].Value);
|
Regex RE = new Regex(regex, RegexOptions.Multiline);
|
||||||
System.Console.Write("]:");
|
MatchCollection matches = RE.Matches(loggingMessage);
|
||||||
|
// Get some direct matches $1 $4 is a
|
||||||
if (le.Level == Level.Error)
|
if (matches.Count == 1)
|
||||||
{
|
{
|
||||||
WriteColorText(ConsoleColor.Red, matches[0].Groups["End"].Value);
|
System.Console.Write(matches[0].Groups["Front"].Value);
|
||||||
}
|
System.Console.Write("[");
|
||||||
else if (le.Level == Level.Warn)
|
|
||||||
{
|
WriteColorText(DeriveColor(matches[0].Groups["Category"].Value), matches[0].Groups["Category"].Value);
|
||||||
WriteColorText(ConsoleColor.Yellow, matches[0].Groups["End"].Value);
|
System.Console.Write("]:");
|
||||||
|
|
||||||
|
if (le.Level == Level.Error)
|
||||||
|
{
|
||||||
|
WriteColorText(ConsoleColor.Red, matches[0].Groups["End"].Value);
|
||||||
|
}
|
||||||
|
else if (le.Level == Level.Warn)
|
||||||
|
{
|
||||||
|
WriteColorText(ConsoleColor.Yellow, matches[0].Groups["End"].Value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.Console.Write(matches[0].Groups["End"].Value);
|
||||||
|
}
|
||||||
|
System.Console.WriteLine();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
System.Console.Write(matches[0].Groups["End"].Value);
|
System.Console.Write(loggingMessage);
|
||||||
}
|
}
|
||||||
System.Console.WriteLine();
|
|
||||||
}
|
}
|
||||||
else
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
System.Console.Write(loggingMessage);
|
System.Console.WriteLine("Couldn't write out log message", e.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue