using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; namespace CommonLang.Log { public class FileStreamLogFactory : LoggerFactory { private TextWriter writer; private FileStream output; public FileStreamLogFactory(FileStream output) { this.output = output; this.writer = new StreamWriter(output); } protected override Logger CreateLogger(string name) { FileStreamLogger log = new FileStreamLogger(writer); log.SetName(name); return log; } } public class FileStreamLogger : Logger { private TextWriter writer; public FileStreamLogger(TextWriter writer) { this.writer = writer; } protected override void Print(string text) { lock (writer) { writer.WriteLine(text); writer.Flush(); } } } }