view Logging/TextFileLogger.cs @ 8:d6ce8764e92b

Fix typo in method name reference no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Fri, 02 Jan 2009 20:19:16 +0000
parents 961030992bd2
children 0352fa33ee8f
line wrap: on
line source

using System;
using System.IO;
using IBBoard;

namespace IBBoard.Logging
{
	/// <summary>
	/// Summary description for FileLogger.
	/// </summary>
	public class TextFileLogger : FileLogger
	{
		public TextFileLogger() : base()
		{
		}
		
		public TextFileLogger(string path) : base(path)
		{
		}

		protected override void LogMessage(LogItem item)
		{
			string stack = item.StackTrace;
			string message = item.Message + Environment.NewLine + (stack!= "" ? stack + Environment.NewLine : "");
			LogMessageString(message);
		}
		
		protected override void LogMessageString (string str)
		{
			str.TrimEnd();
			str+= Environment.NewLine + Environment.NewLine;
			stream.Write(encoding.GetBytes(str), 0, encoding.GetByteCount(str));
			stream.Flush();
		}

	}
}