using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Daramkun.Log
{
	/// <summary>
	/// Log Writer for Stream
	/// </summary>
	public class StreamLogWriter : ILogWriter, IDisposable
	{
		Stream baseStream;
		TextWriter textWriter;

		/// <summary>
		/// Base Stream
		/// </summary>
		public Stream BaseStream { get { return baseStream; } }

		/// <summary>
		/// Constructor of StreamLogWriter
		/// </summary>
		/// <param name="stream">Base Stream</param>
		public StreamLogWriter ( Stream stream )
		{
			baseStream = stream;
			textWriter = new StreamWriter ( baseStream );
		}

		/// <summary>
		/// Write Message to Stream
		/// </summary>
		/// <param name="completedMessage"></param>
		public void WriteMessage ( string completedMessage )
		{
			textWriter.WriteLine ( completedMessage );
		}

		/// <summary>
		/// Dispose
		/// </summary>
		public void Dispose ()
		{
			baseStream = null;
			textWriter.Dispose ();
		}
	}
}
