Remove the pre-log4net, discrete output methods from the consoles

This commit is contained in:
Melanie Thielker
2009-05-20 13:50:33 +00:00
parent 4c7da1421f
commit 4065ebff15
17 changed files with 73 additions and 337 deletions

View File

@@ -58,154 +58,6 @@ namespace OpenSim.Framework.Console
DefaultPrompt = defaultPrompt;
}
/// <summary>
/// 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.
/// </summary>
/// <param name="input">arbitrary string for input</param>
/// <returns>an ansii color</returns>
protected virtual ConsoleColor DeriveColor(string input)
{
return ConsoleColor.White;
}
/// <summary>
/// Sends a warning to the current console output
/// </summary>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Warn(string format, params object[] args)
{
WriteNewLine(ConsoleColor.Yellow, format, args);
}
/// <summary>
/// Sends a warning to the current console output
/// </summary>
/// <param name="sender">The module that sent this message</param>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Warn(string sender, string format, params object[] args)
{
WriteNewLine(DeriveColor(sender), sender, ConsoleColor.Yellow, format, args);
}
/// <summary>
/// Sends a notice to the current console output
/// </summary>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Notice(string format, params object[] args)
{
WriteNewLine(ConsoleColor.White, format, args);
}
/// <summary>
/// Sends a notice to the current console output
/// </summary>
/// <param name="sender">The module that sent this message</param>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Notice(string sender, string format, params object[] args)
{
WriteNewLine(DeriveColor(sender), sender, ConsoleColor.White, format, args);
}
/// <summary>
/// Sends an error to the current console output
/// </summary>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Error(string format, params object[] args)
{
WriteNewLine(ConsoleColor.Red, format, args);
}
/// <summary>
/// Sends an error to the current console output
/// </summary>
/// <param name="sender">The module that sent this message</param>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Error(string sender, string format, params object[] args)
{
WriteNewLine(DeriveColor(sender), sender, ConsoleColor.Red, format, args);
}
/// <summary>
/// Sends a status message to the current console output
/// </summary>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Status(string format, params object[] args)
{
WriteNewLine(ConsoleColor.Blue, format, args);
}
/// <summary>
/// Sends a status message to the current console output
/// </summary>
/// <param name="sender">The module that sent this message</param>
/// <param name="format">The message to send</param>
/// <param name="args">WriteLine-style message arguments</param>
public void Status(string sender, string format, params object[] args)
{
WriteNewLine(DeriveColor(sender), sender, ConsoleColor.Blue, format, args);
}
[Conditional("DEBUG")]
public void Debug(string format, params object[] args)
{
WriteNewLine(ConsoleColor.Gray, format, args);
}
[Conditional("DEBUG")]
public void Debug(string sender, string format, params object[] args)
{
WriteNewLine(DeriveColor(sender), sender, ConsoleColor.Gray, format, args);
}
protected virtual void WriteNewLine(ConsoleColor senderColor, string sender, ConsoleColor color, string format, params object[] args)
{
WritePrefixLine(senderColor, sender);
WriteConsoleLine(color, format, args);
}
protected virtual void WriteNewLine(ConsoleColor color, string format, params object[] args)
{
WriteConsoleLine(color, format, args);
}
protected virtual void WriteConsoleLine(ConsoleColor color, string format, params object[] args)
{
try
{
System.Console.WriteLine(format, args);
}
catch (ObjectDisposedException)
{
}
}
protected virtual void WritePrefixLine(ConsoleColor color, string sender)
{
try
{
sender = sender.ToUpper();
System.Console.WriteLine("[" + sender + "] ");
System.Console.Write("[");
System.Console.Write(sender);
System.Console.Write("] \t");
}
catch (ObjectDisposedException)
{
}
}
public virtual void LockOutput()
{
}

View File

@@ -124,7 +124,7 @@ namespace OpenSim.Framework.Console
/// </summary>
public void ShowHelp(ConsoleBase console)
{
console.Notice(String.Join(" ", m_cmdText) + " - " + m_helpText);
console.Output(String.Join(" ", m_cmdText) + " - " + m_helpText);
}
/// <summary>

View File

@@ -62,19 +62,6 @@ namespace OpenSim.Framework.Console
history.Add(text);
}
/// <summary>
/// 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.
/// </summary>
/// <param name="input">arbitrary string for input</param>
/// <returns>an ansii color</returns>
protected override ConsoleColor DeriveColor(string input)
{
int colIdx = (input.ToUpper().GetHashCode() % 6) + 9;
return (ConsoleColor) colIdx;
}
private int SetCursorTop(int top)
{
if (top >= 0 && top < System.Console.BufferHeight)
@@ -101,117 +88,6 @@ namespace OpenSim.Framework.Console
}
}
protected override void WriteNewLine(ConsoleColor senderColor, string sender, ConsoleColor color, string format, params object[] args)
{
lock (cmdline)
{
if (y != -1)
{
y=SetCursorTop(y);
System.Console.CursorLeft = 0;
int count = cmdline.Length;
System.Console.Write(" ");
while (count-- > 0)
System.Console.Write(" ");
y=SetCursorTop(y);
System.Console.CursorLeft = 0;
}
WritePrefixLine(senderColor, sender);
WriteConsoleLine(color, format, args);
if (y != -1)
y = System.Console.CursorTop;
}
}
protected override void WriteNewLine(ConsoleColor color, string format, params object[] args)
{
lock (cmdline)
{
if (y != -1)
{
y=SetCursorTop(y);
System.Console.CursorLeft = 0;
int count = cmdline.Length;
System.Console.Write(" ");
while (count-- > 0)
System.Console.Write(" ");
y=SetCursorTop(y);
System.Console.CursorLeft = 0;
}
WriteConsoleLine(color, format, args);
if (y != -1)
y = System.Console.CursorTop;
}
}
protected override void WriteConsoleLine(ConsoleColor color, string format, params object[] args)
{
try
{
lock (m_syncRoot)
{
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)
{
System.Console.WriteLine(args);
}
}
}
catch (ObjectDisposedException)
{
}
}
protected override void WritePrefixLine(ConsoleColor color, string sender)
{
try
{
lock (m_syncRoot)
{
sender = sender.ToUpper();
System.Console.WriteLine("[" + sender + "] ");
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");
}
}
catch (ObjectDisposedException)
{
}
}
private void Show()
{
lock (cmdline)