From ba142c04108b4204df4f8c6dd1d9ee0546af0c87 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Tue, 5 Feb 2008 02:10:01 +0000 Subject: * Fixing the console write on shutdown where the object is already disposed. --- OpenSim/Framework/Console/LogBase.cs | 109 ++++++++++++++++++++--------------- 1 file changed, 63 insertions(+), 46 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/LogBase.cs b/OpenSim/Framework/Console/LogBase.cs index f7d0d1f..a2c4b3a 100644 --- a/OpenSim/Framework/Console/LogBase.cs +++ b/OpenSim/Framework/Console/LogBase.cs @@ -232,68 +232,85 @@ namespace OpenSim.Framework.Console private void WriteNewLine(ConsoleColor color, string format, params object[] args) { - lock (m_syncRoot) + try { - string now = DateTime.Now.ToString("[MM-dd HH:mm:ss] "); - Log.Write(now); - try + lock (m_syncRoot) { - Log.WriteLine(format, args); - Log.Flush(); - } + string now = DateTime.Now.ToString("[MM-dd HH:mm:ss] "); + Log.Write(now); + try + { + Log.WriteLine(format, args); + Log.Flush(); + } - catch (FormatException) - { - System.Console.WriteLine(args); - } - System.Console.Write(now); - try - { - if (color != ConsoleColor.White) - System.Console.ForegroundColor = color; + catch (FormatException) + { + System.Console.WriteLine(args); + } + System.Console.Write(now); + try + { + if (color != ConsoleColor.White) + System.Console.ForegroundColor = color; - System.Console.WriteLine(format, args); - System.Console.ResetColor(); - } - catch (ArgumentNullException) - { - // Some older systems dont support coloured text. - System.Console.WriteLine(format, args); - } - catch (FormatException) - { - // Some older systems dont support coloured text. - System.Console.WriteLine(args); - } + System.Console.WriteLine(format, args); + System.Console.ResetColor(); + } + catch (ArgumentNullException) + { + // Some older systems dont support coloured text. + System.Console.WriteLine(format, args); + } + catch (FormatException) + { + // Some older systems dont support coloured text. + System.Console.WriteLine(args); + } + return; + } + } + catch (ObjectDisposedException) + { return; } } private void WritePrefixLine(ConsoleColor color, string sender) { - lock (m_syncRoot) + try { - sender = sender.ToUpper(); - Log.WriteLine("[" + sender + "] "); - Log.Flush(); + lock (m_syncRoot) + { + sender = sender.ToUpper(); - System.Console.Write("["); + Log.WriteLine("[" + sender + "] "); - try - { - System.Console.ForegroundColor = color; - System.Console.Write(sender); - System.Console.ResetColor(); - } - catch (ArgumentNullException) - { - // Some older systems dont support coloured text. - System.Console.WriteLine(sender); - } - System.Console.Write("] \t"); + Log.Flush(); + + System.Console.Write("["); + try + { + System.Console.ForegroundColor = color; + System.Console.Write(sender); + System.Console.ResetColor(); + } + catch (ArgumentNullException) + { + // Some older systems dont support coloured text. + System.Console.WriteLine(sender); + } + + System.Console.Write("] \t"); + + return; + } + } + catch (ObjectDisposedException) + { return; } } -- cgit v1.1