using System.Text; namespace ExtremelySimpleLogger { /// /// A that writes output to a string, which can be queried using . /// Note that this uses a internally for performance. /// public class StringSink : Sink { private readonly StringBuilder builder = new StringBuilder(); /// /// The string that this sink currently contains. /// Can be cleared using . /// public string Value { get { lock (this.builder) return this.builder.ToString(); } } /// /// Logs the given message, which has already been formatted using . /// /// The message to log public override void Log(string s) { lock (this.builder) this.builder.AppendLine(s); } /// /// Clears the string that this sink currently contains. /// After this call, will be empty. /// public void Clear() { lock (this.builder) this.builder.Clear(); } } }