view Logging/TextFileLogger.cs @ 7:f4da31cb09d9

* Add translation DTD to utils project * Alter Translation class to resolve error when initialising with an empty local language (should default to no local language, not exception) no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Fri, 02 Jan 2009 20:12:06 +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();
		}

	}
}