/[RomCheater]/trunk/RomCheater.Logging/Logger.cs
ViewVC logotype

Diff of /trunk/RomCheater.Logging/Logger.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater.Logging/Logger.cs	2012/05/09 09:00:23	25
+++ trunk/RomCheater.Logging/Logger.cs	2012/05/09 09:28:57	26
@@ -13,24 +13,63 @@
         void WriteLine(string format, params object[] args);
     }
 
-    #region public static class Logger
+
+    #region MesageLogger
+    [Flags]
+    public enum loggerflags
+    {
+        NONE = 0x0000,              // 000
+        INFO = 0x0001,              // 001
+        DEBUG = 0x0002,             // 010
+        ERROR= 0x0004,              // 100
+        DEFAULT = INFO | ERROR,
+        ALL = 0x07,
+    }
     public static class logger
     {
+        private static loggerflags logging_flags;
+        static logger() { SetLoggingFlags(loggerflags.DEFAULT); }
+        public static void SetLoggingFlags(loggerflags flags) { logging_flags = flags; }
+        #region sub-classes
+        public static class Info
+        {
+            private static string CreateNewFormat(string format) { return "    INFO: " + format; }
+            public static void Write(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.INFO)) { xlogger.Write(CreateNewFormat(format), args); } }
+            public static void WriteLine(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.INFO)) { xlogger.WriteLine(CreateNewFormat(format), args); } }
+        }
+        public static class Debug
+        {
+            private static string CreateNewFormat(string format) { return "    DEBUG: " + format; }
+            public static void Write(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.DEBUG)) { xlogger.Write(CreateNewFormat(format), args); } }
+            public static void WriteLine(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.DEBUG)) { xlogger.WriteLine(CreateNewFormat(format), args); } }
+        }
+        public static class Error
+        {
+            private static string CreateNewFormat(string format) { return "    ERROR: " + format; }
+            public static void Write(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.ERROR)) { xlogger.Write(CreateNewFormat(format), args); } }
+            public static void WriteLine(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.ERROR)) { xlogger.WriteLine(CreateNewFormat(format), args); } }
+        }
+        #endregion
+
+    }
+    #endregion
+
+    #region internal static class Logger
+    internal static class xlogger
+    {
         private static logwriter lh;
-        static logger() { lh = new logwriter(); }
+        static xlogger() { lh = new logwriter(); }
 
         #region ILogger Members
         public static void Write(string format, params object[] args)
         {            
             init();
-            string new_format = "    " + format;
-            lh.Write(new_format, args);
+            lh.Write(format, args);
         }
         public static void WriteLine(string format, params object[] args)
         {
             init();
-            string new_format = "    " + format;
-            lh.WriteLine(new_format, args);
+            lh.WriteLine(format, args);
         }
         #endregion
 

 

  ViewVC Help
Powered by ViewVC 1.1.22