From 2507f38d07bed79ce523f759d8fdf6e786a724a0 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 1 Aug 2007 20:23:08 +0000 Subject: factor out the common DeriveColor function just for good house keeping --- OpenSim/Framework/Console/LogBase.cs | 43 +++++++++++++++--------------------- 1 file changed, 18 insertions(+), 25 deletions(-) (limited to 'OpenSim/Framework/Console') diff --git a/OpenSim/Framework/Console/LogBase.cs b/OpenSim/Framework/Console/LogBase.cs index 6b6c056..a088af8 100644 --- a/OpenSim/Framework/Console/LogBase.cs +++ b/OpenSim/Framework/Console/LogBase.cs @@ -96,6 +96,19 @@ namespace OpenSim.Framework.Console } /// + /// derive an ansi color from a string, ignoring the darker colors. + /// This is used to help automatically bin component tags with colors + /// in various print functions. + /// + /// arbitrary string for input + /// an ansii color + private ConsoleColor DeriveColor(string input) + { + int colIdx = (input.ToUpper().GetHashCode() % 6) + 9; + return (ConsoleColor)colIdx; + } + + /// /// Sends a warning to the current log output /// /// The message to send @@ -114,11 +127,7 @@ namespace OpenSim.Framework.Console /// WriteLine-style message arguments public void Warn(string sender, string format, params object[] args) { - sender = sender.ToUpper(); - int colIdx = (sender.GetHashCode() % 6) + 9; - ConsoleColor col = (ConsoleColor)colIdx; - - WritePrefixLine(col, sender); + WritePrefixLine(DeriveColor(sender), sender); WriteNewLine(ConsoleColor.Yellow, format, args); return; } @@ -142,11 +151,7 @@ namespace OpenSim.Framework.Console /// WriteLine-style message arguments public void Notice(string sender, string format, params object[] args) { - sender = sender.ToUpper(); - int colIdx = (sender.GetHashCode() % 6) + 9; - ConsoleColor col = (ConsoleColor)colIdx; - - WritePrefixLine(col, sender); + WritePrefixLine(DeriveColor(sender), sender); WriteNewLine(ConsoleColor.White, format, args); return; } @@ -170,11 +175,7 @@ namespace OpenSim.Framework.Console /// WriteLine-style message arguments public void Error(string sender, string format, params object[] args) { - sender = sender.ToUpper(); - int colIdx = (sender.GetHashCode() % 6) + 9; - ConsoleColor col = (ConsoleColor)colIdx; - - WritePrefixLine(col, sender); + WritePrefixLine(DeriveColor(sender), sender); WriteNewLine(ConsoleColor.Red, format, args); return; } @@ -198,11 +199,7 @@ namespace OpenSim.Framework.Console /// WriteLine-style message arguments public void Verbose(string sender, string format, params object[] args) { - sender = sender.ToUpper(); - int colIdx = (sender.GetHashCode() % 6) + 9; - ConsoleColor col = (ConsoleColor)colIdx; - - WritePrefixLine(col, sender); + WritePrefixLine(DeriveColor(sender), sender); WriteNewLine(ConsoleColor.Gray, format, args); return; } @@ -226,11 +223,7 @@ namespace OpenSim.Framework.Console /// WriteLine-style message arguments public void Status(string sender, string format, params object[] args) { - sender = sender.ToUpper(); - int colIdx = (sender.GetHashCode() % 6) + 9; - ConsoleColor col = (ConsoleColor)colIdx; - - WritePrefixLine(col, sender); + WritePrefixLine(DeriveColor(sender), sender); WriteNewLine(ConsoleColor.Blue, format, args); return; } -- cgit v1.1