2 using System.Collections.Generic;
9 protected TextWriter[] debugs, infos, errors;
12 /// Construct a Logger, writing to the specified TextWriter objects. Use an empty array to disable an output.
14 /// <param name="debugs">Array of TextWriter's to use for debug output</param>
15 /// <param name="infos">...for info output</param>
16 /// <param name="errors">...for error output</param>
17 public Logger(TextWriter[] debugs, TextWriter[] infos, TextWriter[] errors) {
22 this.debug("Starting logging (debug) here at {0}", DateTime.Now.ToString("F"));
23 this.info("Starting logging (info) here at {0}", DateTime.Now.ToString("F"));
24 this.error("Starting logging (error) here at {0}", DateTime.Now.ToString("F"));
28 this.debug("Stopping logging (debug) here at {0}", DateTime.Now.ToString("F"));
29 this.info("Stopping logging (info) here at {0}", DateTime.Now.ToString("F"));
30 this.error("Stopping logging (error) here at {0}", DateTime.Now.ToString("F"));
31 foreach (TextWriter[] group in new TextWriter[][] { this.debugs, this.infos, this.errors }) {
32 foreach (TextWriter outw in group) {
41 /// <param name="msg">Log message (with formatting placeholders, if desired)</param>
42 /// <param name="args">Formatting replacements.</param>
43 public void debug(string msg, params object[] args) {
44 foreach (TextWriter outw in this.debugs) {
45 outw.WriteLine("(D@" + DateTime.Now.ToString("HH:mm:ss") + ")[MAIN] " + msg, args);
52 /// <param name="msg">Log message (with formatting placeholders, if desired)</param>
53 /// <param name="args">Formatting replacements.</param>
54 public void info(string msg, params object[] args) {
55 foreach (TextWriter outw in this.infos) {
56 outw.WriteLine("(I@" + DateTime.Now.ToString("HH:mm:ss") + ")[MAIN] " + msg, args);
63 /// <param name="msg">Log message (with formatting placeholders, if desired)</param>
64 /// <param name="args">Formatting replacements.</param>
65 public void error(string msg, params object[] args) {
66 foreach (TextWriter outw in this.errors) {
67 outw.WriteLine("(E@" + DateTime.Now.ToString("HH:mm:ss") + ")[MAIN] " + msg, args);