// // openmapi.org - IRC <--> Jabber bridge - Logger.cs // // (C) 2009 by Johannes Roith // // Author: Johannes Roith // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // namespace Jonfo.Jabber.IRC { using System; using System.IO; /// /// A very simple logger. /// public sealed class Logger : IDisposable { private TextWriter writer; public Logger (string fileName) { this.writer = File.AppendText (fileName); } public void Dispose () { writer.Flush (); writer.Close (); writer.Dispose (); } /// /// Log something. /// public void Log (string line) { writer.WriteLine (DateTime.Now + " - " + line); } /// /// Should be called on first run or something. /// public void StartLogging () { Log ("----------------- bot started. ----------------- "); } } }