From 741f753c5642b382d759e1e732de3e22045b9b56 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Thu, 14 Feb 2008 19:29:07 +0000 Subject: attempt to make our logging at least fail gracefully, we'll see if this helps --- OpenSim/Framework/Console/OpenSimAppender.cs | 59 ++++++++++++++++------------ 1 file changed, 33 insertions(+), 26 deletions(-) (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Console/OpenSimAppender.cs b/OpenSim/Framework/Console/OpenSimAppender.cs index 1835d18..32eab11 100644 --- a/OpenSim/Framework/Console/OpenSimAppender.cs +++ b/OpenSim/Framework/Console/OpenSimAppender.cs @@ -14,37 +14,44 @@ namespace OpenSim.Framework.Console { override protected void Append(LoggingEvent le) { - string loggingMessage = RenderLoggingEvent(le); - string regex = @"^(?.*?)\[(?[^\]]+)\]:?(?.*)"; - - 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); - System.Console.Write("]:"); + try { + string loggingMessage = RenderLoggingEvent(le); + string regex = @"^(?.*?)\[(?[^\]]+)\]:?(?.*)"; - if (le.Level == Level.Error) - { - WriteColorText(ConsoleColor.Red, matches[0].Groups["End"].Value); - } - else if (le.Level == Level.Warn) + + Regex RE = new Regex(regex, RegexOptions.Multiline); + MatchCollection matches = RE.Matches(loggingMessage); + // Get some direct matches $1 $4 is a + if (matches.Count == 1) { - WriteColorText(ConsoleColor.Yellow, matches[0].Groups["End"].Value); - } - else + System.Console.Write(matches[0].Groups["Front"].Value); + System.Console.Write("["); + + WriteColorText(DeriveColor(matches[0].Groups["Category"].Value), matches[0].Groups["Category"].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 { - 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()); } } -- cgit v1.1