ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater.Logging/Logger.cs
(Generate patch)

Comparing trunk/RomCheater.Logging/Logger.cs (file contents):
Revision 17 by william, Wed May 9 08:02:18 2012 UTC vs.
Revision 26 by william, Wed May 9 09:28:57 2012 UTC

--- trunk/RomCheater.Logging/Logger.cs	2012/05/09 08:02:18	17
+++ trunk/RomCheater.Logging/Logger.cs	2012/05/09 09:28:57	26
@@ -13,11 +13,52 @@ namespace RomCheater.Logging
         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)
@@ -53,7 +94,7 @@ namespace RomCheater.Logging
                                 lw = (LogWriter)prop.GetValue(null, null);
                                 break;
                             }
-                            catch (Exception ex)
+                            catch (Exception)
                             {
                                 throw;
                             }