]> jfr.im git - z_archive/kelsier.git/blobdiff - Logger.cs
Moving MySQL into new class
[z_archive/kelsier.git] / Logger.cs
index 753b063af872c44dffd2a7b4426ba60528830a8e..bbe14d183cf8b3b5908c54a0044ee2bf680a509f 100644 (file)
--- a/Logger.cs
+++ b/Logger.cs
@@ -4,13 +4,17 @@
 using System.Text;
 using System.IO;
 
-namespace Kelsier
-{
-    class Logger
-    {
+namespace Kelsier {
+    class Logger {
         protected TextWriter[] debugs, infos, errors;
-        public Logger(TextWriter[] debugs, TextWriter[] infos, TextWriter[] errors) // constructor
-        {
+
+        /// <summary>
+        /// Construct a Logger, writing to the specified TextWriter objects. Use an empty array to disable an output.
+        /// </summary>
+        /// <param name="debugs">Array of TextWriter's to use for debug output</param>
+        /// <param name="infos">...for info output</param>
+        /// <param name="errors">...for error output</param>
+        public Logger(TextWriter[] debugs, TextWriter[] infos, TextWriter[] errors) {
             this.debugs = debugs;
             this.infos = infos;
             this.errors = errors;
@@ -20,40 +24,46 @@ class Logger
             this.error("Starting logging (error) here at {0}", DateTime.Now.ToString("F"));
         }
 
-        ~Logger() // destructor
-        {
+        ~Logger() {
             this.debug("Stopping logging (debug) here at {0}", DateTime.Now.ToString("F"));
             this.info("Stopping logging (info) here at {0}", DateTime.Now.ToString("F"));
             this.error("Stopping logging (error) here at {0}", DateTime.Now.ToString("F"));
-            foreach (TextWriter[] group in new TextWriter[][]{this.debugs, this.infos, this.errors})
-            {
-                foreach (TextWriter outw in group)
-                {
+            foreach (TextWriter[] group in new TextWriter[][] { this.debugs, this.infos, this.errors }) {
+                foreach (TextWriter outw in group) {
                     outw.Close();
                 }
             }
         }
 
-        public void debug(string msg, params object[] args)
-        {
-            foreach (TextWriter outw in this.debugs)
-            {
+        /// <summary>
+        /// Debug logging.
+        /// </summary>
+        /// <param name="msg">Log message (with formatting placeholders, if desired)</param>
+        /// <param name="args">Formatting replacements.</param>
+        public void debug(string msg, params object[] args) {
+            foreach (TextWriter outw in this.debugs) {
                 outw.WriteLine("(D@" + DateTime.Now.ToString("HH:mm:ss") + ")[MAIN] " + msg, args);
             }
         }
 
-        public void info(string msg, params object[] args)
-        {
-            foreach (TextWriter outw in this.infos)
-            {
+        /// <summary>
+        /// Info logging.
+        /// </summary>
+        /// <param name="msg">Log message (with formatting placeholders, if desired)</param>
+        /// <param name="args">Formatting replacements.</param>
+        public void info(string msg, params object[] args) {
+            foreach (TextWriter outw in this.infos) {
                 outw.WriteLine("(I@" + DateTime.Now.ToString("HH:mm:ss") + ")[MAIN] " + msg, args);
             }
         }
 
-        public void error(string msg, params object[] args)
-        {
-            foreach (TextWriter outw in this.errors)
-            {
+        /// <summary>
+        /// Error logging.
+        /// </summary>
+        /// <param name="msg">Log message (with formatting placeholders, if desired)</param>
+        /// <param name="args">Formatting replacements.</param>
+        public void error(string msg, params object[] args) {
+            foreach (TextWriter outw in this.errors) {
                 outw.WriteLine("(E@" + DateTime.Now.ToString("HH:mm:ss") + ")[MAIN] " + msg, args);
             }
         }