]> jfr.im git - z_archive/kelsier.git/blame - Logger.cs
init repo
[z_archive/kelsier.git] / Logger.cs
CommitLineData
88ae06a4
JR
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.IO;
6
7namespace Kelsier
8{
9 class Logger
10 {
11 protected TextWriter[] debugs, infos, errors;
12 public Logger(TextWriter[] debugs, TextWriter[] infos, TextWriter[] errors) // constructor
13 {
14 this.debugs = debugs;
15 this.infos = infos;
16 this.errors = errors;
17
18 this.debug("Starting logging (debug) here at {0}", DateTime.Now.ToString("F"));
19 this.info("Starting logging (info) here at {0}", DateTime.Now.ToString("F"));
20 this.error("Starting logging (error) here at {0}", DateTime.Now.ToString("F"));
21 }
22
23 ~Logger() // destructor
24 {
25 this.debug("Stopping logging (debug) here at {0}", DateTime.Now.ToString("F"));
26 this.info("Stopping logging (info) here at {0}", DateTime.Now.ToString("F"));
27 this.error("Stopping logging (error) here at {0}", DateTime.Now.ToString("F"));
28 foreach (TextWriter[] group in new TextWriter[][]{this.debugs, this.infos, this.errors})
29 {
30 foreach (TextWriter outw in group)
31 {
32 outw.Close();
33 }
34 }
35 }
36
37 public void debug(string msg, params object[] args)
38 {
39 foreach (TextWriter outw in this.debugs)
40 {
41 outw.WriteLine("(D@" + DateTime.Now.ToString("HH:mm:ss") + ")[MAIN] " + msg, args);
42 }
43 }
44
45 public void info(string msg, params object[] args)
46 {
47 foreach (TextWriter outw in this.infos)
48 {
49 outw.WriteLine("(I@" + DateTime.Now.ToString("HH:mm:ss") + ")[MAIN] " + msg, args);
50 }
51 }
52
53 public void error(string msg, params object[] args)
54 {
55 foreach (TextWriter outw in this.errors)
56 {
57 outw.WriteLine("(E@" + DateTime.Now.ToString("HH:mm:ss") + ")[MAIN] " + msg, args);
58 }
59 }
60 }
61}