+2002-01-04 John R. Hicks <angryjohn69@nc.rr.com>
+ * Moved TraceListener, TextWriterTraceListener, and
+ DefaultTraceListener to System assembly....oops.
+
2002-01-04 John R. Hicks <angryjohn69@nc.rr.com>
* Added TextWriterTraceListener.cs, TraceListener.cs, and
+++ /dev/null
-//\r
-// System.Diagnostics.DefaultTraceListener.cs\r
-//\r
-// Author:\r
-// John R. Hicks (angryjohn69@nc.rr.com)\r
-//\r
-// (C) 2001\r
-//\r
-using System;\r
-\r
-namespace System.Diagnostics\r
-{\r
- /// <summary>\r
- /// Provides the default output methods and behavior for tracing.\r
- /// </summary>\r
- /// <remarks>\r
- /// Since there is no debugging API ala Win32 on Mono, <see cref="System.Console.Out">\r
- /// Console.Out</see> is being used as the default output method.\r
- /// </remarks>\r
- public class DefaultTraceListener : TraceListener\r
- { \r
- private string logFileName;\r
- \r
- public DefaultTraceListener() : base("Default")\r
- {\r
- logFileName = "";\r
- }\r
- \r
- /// <summary>\r
- /// Gets or sets name of a log file to write trace or debug messages to.\r
- /// </summary>\r
- /// <value>\r
- /// The name of a log file to write trace or debug messages to.\r
- /// </value>\r
- public String LogFileName\r
- {\r
- get\r
- {\r
- return logFileName;\r
- }\r
- set\r
- {\r
- logFileName = value;\r
- }\r
- }\r
- \r
- /// <summary>\r
- /// Emits or displays a message and a stack trace for an assertion that \r
- /// always fails.\r
- /// </summary>\r
- /// <param name="message">\r
- /// The message to emit or display.\r
- /// </param>\r
- public override void Fail(string message)\r
- {\r
- Console.Out.WriteLine(message);\r
- new StackTrace().ToString();\r
- }\r
- \r
- /// <summary>\r
- /// Emits or displays detailed messages and a stack trace\r
- /// for an assertion that always fails.\r
- /// </summary>\r
- /// <param name="message">\r
- /// The message to emit or display\r
- /// </param>\r
- /// <param name="detailMessage">\r
- /// The detailed message to emit or display.\r
- /// </param>\r
- public override void Fail(string message, string detailMessage)\r
- {\r
- Console.Out.WriteLine(message + ": " + detailMessage);\r
- new StackTrace().ToString();\r
- }\r
- \r
- /// <summary>\r
- /// Writes the output to the Console\r
- /// </summary>\r
- /// <param name="message">\r
- /// The message to write\r
- /// </param>\r
- public override void Write(string message)\r
- {\r
- Console.Out.Write(message);\r
- }\r
- \r
- /// <summary>\r
- /// Writes the output to the Console, followed by a newline\r
- /// </summary>\r
- /// <param name="message">\r
- /// The message to write\r
- /// </param>\r
- public override void WriteLine(string message)\r
- {\r
- Console.Out.WriteLine(message);\r
- }\r
- }\r
-}\r
+++ /dev/null
-//\r
-// System.Diagnostics.TextWriterTraceListener.cs\r
-//\r
-// Author:\r
-// John R. Hicks (angryjohn69@nc.rr.com)\r
-//\r
-// (C) 2001\r
-//\r
-namespace System.Diagnostics\r
-{\r
- using System;\r
- using System.IO;\r
- using System.Text;\r
- \r
- /// <summary>\r
- /// Directs tracing or debugging output to a <see cref="System.IO.TextWriter">\r
- /// TextWriter</see> or to a <see cref="System.IO.Stream">Stream</see>,\r
- /// such as <see cref="System.Console.Out">Console.Out</see> or\r
- /// <see cref="System.IO.FileStream">FileStream</see>.\r
- /// </summary>\r
- public class TextWriterTraceListener : TraceListener\r
- { \r
- \r
- private TextWriter writer;\r
- \r
- /// <summary>\r
- /// Initializes a new instance of the <see cref="TextWriterTraceListener">\r
- /// TextWriterTraceListener</see> class with <see cref="System.IO.TextWriter">\r
- /// TextWriter</see> as the output recipient.\r
- /// </summary>\r
- public TextWriterTraceListener() : base("TextWriter")\r
- {\r
- writer = Console.Out;\r
- }\r
- \r
- /// <summary>\r
- /// Initializes a new instance of the <see cref="TextWriterTraceListener">\r
- /// TextWriterTraceListener</see> class, using the stream as the output\r
- /// recipient of the debugging and tracing output.\r
- /// </summary>\r
- /// <param name="stream">\r
- /// A <see cref="System.IO.Stream">Stream</see> that represents the stream the\r
- /// <see cref="TextWriterTraceListener">TextWriterTraceListener</see> writes to.\r
- /// </param>\r
- /// <exception cref="System.ArgumentNullException">\r
- /// The stream is a null reference.\r
- /// </exception>\r
- public TextWriterTraceListener(Stream stream) : base("")\r
- {\r
- if(stream == null)\r
- throw new ArgumentNullException("Stream is null");\r
- \r
- writer = new StreamWriter(stream);\r
- }\r
- \r
- /// <summary>\r
- /// Initializes a new instance of the <see cref="TextWriterTraceListener">\r
- /// TextWriterTraceListener</see> class, using the file as the recipient\r
- /// of the debugging and tracing output.\r
- /// </summary>\r
- /// <param name="fileName">\r
- /// The name of the file the <see cref="TextWriterTraceListener">\r
- /// TextWriterTraceListener</see> writes to.\r
- /// </param>\r
- /// <exception cref="System.ArgumentNullException">\r
- /// The fileName is null.\r
- /// </exception>\r
- public TextWriterTraceListener(string fileName) : base("")\r
- {\r
- if(fileName == null)\r
- throw new ArgumentNullException("Filename is null");\r
- \r
- FileStream fileStream = new FileStream(fileName, FileMode.Create);\r
- writer = new StreamWriter(fileStream);\r
- }\r
- \r
- /// <summary>\r
- /// Initializes a new instance of the <see cref="TextWriterTraceListener">\r
- /// TextWriterTraceListener</see> class using the specified writer as the\r
- /// recipient of the tracing or debugging output.\r
- /// </summary>\r
- /// <param name="writer">\r
- /// A <see cref="System.IO.TextWriter">TextWriter</see> that receives output\r
- /// from the <see cref="TextWriterTraceListener">TextWriterTraceListener</see>.\r
- /// </param>\r
- /// <exception cref="System.ArgumentNullException">\r
- /// The writer is a null reference\r
- /// </exception>\r
- public TextWriterTraceListener(TextWriter writer) : base("")\r
- {\r
- if(writer == null)\r
- throw new ArgumentNullException("Given TextWriter is null");\r
- this.writer = writer;\r
- }\r
- \r
- /// <summary>\r
- /// Initializes a new instance of the <see cref="TextWriterTraceListener">\r
- /// TextWriterTraceListener</see> class with the specified name, using the\r
- /// stream as the recipient of the tracing or debugging output.\r
- /// </summary>\r
- /// <param name="stream">\r
- /// A <see cref="System.IO.Stream">Stream</see> that represents the stream the\r
- /// <see cref="TextWriterTraceListener">TextWriterTraceListener</see>\r
- /// writes to.\r
- /// </param>\r
- /// <param name="name">\r
- /// The name of the new instance\r
- /// </param>\r
- /// <exception cref="System.ArgumentNullException">\r
- /// The stream is a null reference\r
- /// </exception>\r
- public TextWriterTraceListener(Stream stream, string name) : base(name)\r
- {\r
- if(stream == null)\r
- throw new ArgumentNullException("Supplied Stream is null");\r
- writer = new StreamWriter(stream);\r
- }\r
- \r
- /// <summary>\r
- /// Initializes a new instance of the <see cref="TextWriterTraceListener">\r
- /// TextWriterTraceListener</see> class with the specified name, using the\r
- /// file as the recipient of the tracing or debugging output.\r
- /// </summary>\r
- /// <param name="fileName">\r
- /// The name of the file the <see cref="TextWriterTraceListener">\r
- /// TextWriterTraceListener</see> writes to.\r
- /// </param>\r
- /// <param name="name">\r
- /// The name of the new instance\r
- /// </param>\r
- /// <exception cref="System.ArgumentNullException">\r
- /// The file is a null reference.\r
- /// </exception>\r
- public TextWriterTraceListener(string fileName, string name) : base(name)\r
- {\r
- if(fileName == null)\r
- throw new ArgumentNullException("Supplied file name is null");\r
- FileStream fileStream = new FileStream(fileName, FileMode.Create);\r
- writer = new StreamWriter(fileStream);\r
- }\r
- \r
- /// <summary>\r
- /// Initializes a new instance of the <see cref="TextWriterTraceListener">\r
- /// TextWriterTraceListener</see> class with the specified name, using\r
- /// the specified writer as the recipient of the tracing or debugging output.\r
- /// </summary>\r
- /// <param name="writer">\r
- /// A <see cref="System.IO.TextWriter">TextWriter</see> that receives the output\r
- /// from the <see cref="TextWriterTraceListener">TextWriterTraceListener</see>.\r
- /// </param>\r
- /// <param name="name">\r
- /// The name of the new instance.\r
- /// </param>\r
- /// <exception cref="System.ArgumentNullException">\r
- /// The writer is a null reference.\r
- /// </exception>\r
- public TextWriterTraceListener(TextWriter writer, string name) : base(name)\r
- {\r
- if(writer == null)\r
- throw new ArgumentNullException("The supplied writer is null");\r
- this.writer = writer;\r
- }\r
- \r
- /// <summary>\r
- /// Gets or sets the writer that receives the debugging or tracing output.\r
- /// </summary>\r
- /// <value>\r
- /// A <see cref="System.IO.TextWriter">TextWriter</see> that represents the writer\r
- /// that receives the tracing or debugging output.\r
- /// </value>\r
- public TextWriter Writer\r
- {\r
- get\r
- {\r
- return writer;\r
- }\r
- set\r
- {\r
- writer = value;\r
- }\r
- }\r
- \r
- /// <summary>\r
- /// Closes the <see cref="System.IO.Writer">Writer</see> so that it no longer\r
- /// receives tracing or debugging output.\r
- /// </summary>\r
- public override void Close()\r
- {\r
- writer.Close();\r
- }\r
- \r
- /// <summary>\r
- /// Flushes the output buffer for the <see cref="System.IO.Writer">Writer</see>.\r
- /// </summary>\r
- public override void Flush()\r
- {\r
- writer.Flush();\r
- }\r
- \r
- /// <summary>\r
- /// Writes a message to this instance's <see cref="System.IO.Writer">Writer</see>.\r
- /// </summary>\r
- /// <param name="message">\r
- /// A message to write.\r
- /// </param>\r
- public override void Write(string message)\r
- {\r
- Console.Error.WriteLine("We should be getting output here");\r
- writer.Write(message);\r
- \r
- }\r
- \r
- /// <summary>\r
- /// Writes a message to this instance's <see cref="System.IO.Writer">Writer</see>\r
- /// followed by a line terminator.\r
- /// </summary>\r
- /// <param name="message">\r
- /// A message to write.\r
- /// </param>\r
- public override void WriteLine(string message)\r
- {\r
- Console.Error.WriteLine("We should be getting output here, too"); \r
- writer.WriteLine(message);\r
- \r
- }\r
- }\r
-}\r
+++ /dev/null
-//\r
-// System.Diagnostics.TraceListener.cs\r
-//\r
-// Author:\r
-// John R. Hicks (angryjohn69@nc.rr.com)\r
-//\r
-// (C) 2001\r
-//\r
-namespace System.Diagnostics\r
-{\r
- using System;\r
- using System.IO;\r
- using System.Text;\r
- \r
- /// <summary>\r
- /// Provides the abstract base class for the listeners who monitor\r
- /// trace and debug output\r
- /// </summary>\r
- public abstract class TraceListener : MarshalByRefObject, IDisposable\r
- {\r
- private int indentLevel;\r
- private int indentSize;\r
- private string name;\r
- private bool needIndent;\r
- \r
- /// <summary>\r
- /// Initializes a new instance of the <see cref="TraceListener">\r
- /// TraceListener</see> class.\r
- /// </summary>\r
- protected TraceListener()\r
- {\r
- indentLevel = 0;\r
- indentSize = 4;\r
- needIndent = false;\r
- name = "";\r
- }\r
- \r
- /// <summary>\r
- /// Initializes a new instance of the <see cref="TraceListener">\r
- /// TraceListener</see> class using the specified name as the listener.\r
- /// </summary>\r
- protected TraceListener(string name) : this()\r
- {\r
- if(name == null)\r
- this.name = "";\r
- this.name = name;\r
- }\r
- \r
- /// <summary>\r
- /// Gets or sets the indent level.\r
- /// </summary>\r
- /// <value>\r
- /// The indent level. The default is zero.\r
- /// </value>\r
- public int IndentLevel\r
- {\r
- get\r
- {\r
- return indentLevel;\r
- }\r
- set\r
- {\r
- indentLevel = value;\r
- }\r
- }\r
- \r
- /// <summary>\r
- /// Gets or sets the number of spaces in an indent.\r
- /// </summary>\r
- /// <value>\r
- /// The number of spaces in an indent. The default is four spaces.\r
- /// </value>\r
- public int IndentSize\r
- {\r
- get\r
- {\r
- return indentSize;\r
- }\r
- set\r
- {\r
- indentSize = value;\r
- }\r
- }\r
- \r
- /// <summary>\r
- /// Gets or sets a name for this <see cref="TraceListener">TraceListener</see>.\r
- /// </summary>\r
- /// <value>\r
- /// A name for this <see cref="TraceListener">TraceListener</see>.\r
- /// The default is the empty string ("")\r
- /// </value>\r
- public string Name\r
- {\r
- get\r
- {\r
- return name;\r
- }\r
- set\r
- {\r
- name = value;\r
- }\r
- }\r
- \r
- /// <summary>\r
- /// Gets or sets a value indicating whether to indent the output.\r
- /// </summary>\r
- /// <value>\r
- /// <b>true</b> if the output should be indented; otherwise <b>false</b>.\r
- /// </value>\r
- protected bool NeedIndent\r
- {\r
- get\r
- {\r
- return needIndent;\r
- }\r
- set\r
- {\r
- needIndent = value;\r
- }\r
- }\r
- \r
- /// <summary>\r
- /// When overridden in a derived class, closes the output stream so it no longer\r
- /// receives tracing or debugging output.\r
- /// </summary>\r
- public virtual void Close() {}\r
- \r
- /// <summary>\r
- /// Releases all resources used by the <see cref="TraceListener">TraceListener</see>.\r
- /// </summary>\r
- public virtual void Dispose() {}\r
- \r
- /// <summary>\r
- /// Releases the unmanaged resources used by the \r
- /// <see cref="TraceListener">TraceListener</see> and optionally releases the\r
- /// managed resources.\r
- /// </summary>\r
- /// <param name="disposing">\r
- /// <b>true</b> to release both managed and unmanaged resources;\r
- /// <b>false</b> to release only unmanaged resources.\r
- /// </param>\r
- protected virtual void Dispose(bool disposing) {}\r
- \r
- /// <summary>\r
- /// Emits an error message to the listener you create when you \r
- /// implement the <see cref="TraceListener">TraceListener</see> class.\r
- /// </summary>\r
- /// <param name="message">\r
- /// A message to emit.\r
- /// </param>\r
- public virtual void Fail(string message)\r
- {\r
- \r
- }\r
- \r
- /// <summary>\r
- /// Emits an error message, and a detailed error message to the listener\r
- /// you create when you implement the <see cref="TraceListener">TraceListener</see>\r
- /// class.\r
- /// </summary>\r
- /// <param name="message">\r
- /// A message to emit.\r
- /// </param>\r
- /// <param name="detailMessage">\r
- /// A detailed message to emit.\r
- /// </param>\r
- public virtual void Fail(string message, string detailMessage)\r
- {\r
- \r
- }\r
- \r
- /// <summary>\r
- /// When overridden in a derived class, flushes the output buffer.\r
- /// </summary>\r
- public virtual void Flush() {}\r
- \r
- /// <summary>\r
- /// Writes the value of the object's <see cref="System.Object.ToString">ToString</see>\r
- /// method to the listener you create when you implement the\r
- /// <see cref="TraceListener">TraceListener</see> class.\r
- /// </summary>\r
- /// <param name="o">\r
- /// An <see cref="System.Object">Object</see> whose fully qualified\r
- /// class name you want to write.\r
- /// </param>\r
- public virtual void Write(object o) \r
- {\r
- \r
- }\r
- \r
- /// <summary>\r
- /// When overridden in a derived class, writes the specified message to \r
- /// the listener you create in the derived class.\r
- /// </summary>\r
- /// <param name="message">\r
- /// A message to write.\r
- /// </param>\r
- public abstract void Write(string message);\r
- \r
- /// <summary>\r
- /// Writes a category name and the value of the object's \r
- /// <see cref="System.Object.ToString">ToString</see>\r
- /// method to the listener you create when you implement the\r
- /// <see cref="TraceListener">TraceListener</see> class.\r
- /// </summary>\r
- /// <param name="o">\r
- /// An <see cref="System.Object">Object</see> whose fully qualified\r
- /// class name you wish to write.\r
- /// </param>\r
- /// <param name="category">\r
- /// A category name used to organize the output.\r
- /// </param>\r
- public virtual void Write(object o, string category)\r
- {\r
- \r
- }\r
- \r
- /// <summary>\r
- /// Writes a category name and a message to the listener you create when \r
- /// you implement the <see cref="TraceListener">TraceListener</see> class.\r
- /// </summary>\r
- /// <param name="message">\r
- /// A message to write.\r
- /// </param>\r
- /// <param name="category">\r
- /// A category name used to organize the output.\r
- /// </param>\r
- public virtual void Write(string message, string category)\r
- {\r
- \r
- }\r
- \r
- /// <summary>\r
- /// Writes the value of the object's <see cref="System.Object.ToString">ToString</see>\r
- /// method to the listener you create when you implement the\r
- /// <see cref="TraceListener">TraceListener</see> class, followed by a line terminator.\r
- /// </summary>\r
- /// <param name="o">\r
- /// An <see cref="System.Object">Object</see> whose fully qualified\r
- /// class name you want to write.\r
- /// </param>\r
- public virtual void WriteLine(object o) \r
- {\r
- \r
- }\r
- \r
- /// <summary>\r
- /// When overridden in a derived class, writes the specified message to \r
- /// the listener you create in the derived class, followed by a line terminator.\r
- /// </summary>\r
- /// <param name="message">\r
- /// A message to write.\r
- /// </param>\r
- public abstract void WriteLine(string message);\r
- \r
- /// <summary>\r
- /// Writes a category name and the value of the object's \r
- /// <see cref="System.Object.ToString">ToString</see>\r
- /// method to the listener you create when you implement the\r
- /// <see cref="TraceListener">TraceListener</see> class, followed by a\r
- /// line terminator.\r
- /// </summary>\r
- /// <param name="o">\r
- /// An <see cref="System.Object">Object</see> whose fully qualified\r
- /// class name you wish to write.\r
- /// </param>\r
- /// <param name="category">\r
- /// A category name used to organize the output.\r
- /// </param>\r
- public virtual void WriteLine(object o, string category)\r
- {\r
- \r
- }\r
- \r
- /// <summary>\r
- /// Writes a category name and a message to the listener you create when \r
- /// you implement the <see cref="TraceListener">TraceListener</see> class,\r
- /// followed by a line terminator.\r
- /// </summary>\r
- /// <param name="message">\r
- /// A message to write.\r
- /// </param>\r
- /// <param name="category">\r
- /// A category name used to organize the output.\r
- /// </param>\r
- public virtual void WriteLine(string message, string category)\r
- {\r
- \r
- }\r
- \r
- /// <summary>\r
- /// Writes the indent to the listener you create when you implement this class,\r
- /// and resets the <see cref="NeedIndent">NeedIndent</see> Property to <b>false</b>.\r
- /// </summary>\r
- protected virtual void WriteIndent()\r
- {\r
- \r
- }\r
- }\r
-}\r