/[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 10:05:28	28
+++ trunk/RomCheater.Logging/logger.cs	2012/05/09 23:23:38	99
@@ -16,20 +16,23 @@
 
     #region MesageLogger
     [Flags]
-    public enum loggerflags
+    public enum loggerflags :ushort
     {
-        NONE = 0x0000,              // 000
-        INFO = 0x0001,              // 001
-        DEBUG = 0x0002,             // 010
-        ERROR= 0x0004,              // 100
-        DEFAULT = INFO | ERROR,
-        ALL = 0x07,
+        NONE = 0x0000,              // 00000
+        INFO = 0x0001,              // 00001
+        DEBUG = 0x0002,             // 00010
+        ERROR= 0x0004,              // 00100
+        VERBOSE_DEBUG = 0x0008,             // 01000
+        VERBOSE_ERROR = 0x0010,             // 10000
+        DEFAULT = INFO | ERROR | DEBUG,
+        ALL = DEFAULT | VERBOSE_DEBUG | VERBOSE_ERROR
     }
     public static class logger
     {
         private static loggerflags logging_flags;
         static logger() { SetLoggingFlags(loggerflags.DEFAULT); }
         public static void SetLoggingFlags(loggerflags flags) { logging_flags = flags; }
+        public static loggerflags GetLoggingFlags() { return logging_flags; }
         #region sub-classes
         private static string CreateTimeStamp()
         {
@@ -50,12 +53,47 @@
             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 VerboseDebug
+        {
+            private static string CreateNewFormat(string format) { return "    " + CreateTimeStamp() + "(VERBOSE DEBUG) " + format; }
+            public static void Write(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.VERBOSE_DEBUG)) { xlogger.Write(CreateNewFormat(format), args); } }
+            public static void WriteLine(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.VERBOSE_DEBUG)) { xlogger.WriteLine(CreateNewFormat(format), args); } }
+        }
         public static class Error
         {
             private static string CreateNewFormat(string format) { return "    " + CreateTimeStamp() + "(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); } }
         }
+        public static class VerboseError
+        {
+            private static string CreateNewFormat(string format) { return "    " + CreateTimeStamp() + "(VERBOSE ERROR) " + format; }
+            public static void Write(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.VERBOSE_ERROR)) { xlogger.Write(CreateNewFormat(format), args); } }
+            public static void WriteLine(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.VERBOSE_ERROR)) { xlogger.WriteLine(CreateNewFormat(format), args); } }
+        }
+        #region Force logging
+        public static class ForceLog
+        {
+            public static class Info
+            {
+                private static string CreateNewFormat(string format) { return "    " + CreateTimeStamp() + "(FORCED INFO) " + format; }
+                public static void Write(string format, params object[] args) { xlogger.Write(CreateNewFormat(format), args); }
+                public static void WriteLine(string format, params object[] args) { xlogger.WriteLine(CreateNewFormat(format), args); }
+            }
+            public static class Debug
+            {
+                private static string CreateNewFormat(string format) { return "    " + CreateTimeStamp() + "(FORCED DEBUG) " + format; }
+                public static void Write(string format, params object[] args) { xlogger.Write(CreateNewFormat(format), args); }
+                public static void WriteLine(string format, params object[] args) { xlogger.WriteLine(CreateNewFormat(format), args); }
+            }
+            public static class Error
+            {
+                private static string CreateNewFormat(string format) { return "    " + CreateTimeStamp() + "(FORCED ERROR) " + format; }
+                public static void Write(string format, params object[] args) { xlogger.Write(CreateNewFormat(format), args); }
+                public static void WriteLine(string format, params object[] args) { xlogger.WriteLine(CreateNewFormat(format), args); }
+            }
+        }
+        #endregion
         #endregion
 
     }
@@ -99,6 +137,7 @@
                             try
                             {
                                 lw = (LogWriter)prop.GetValue(null, null);
+                                lh = new logwriter(lw);
                                 break;
                             }
                             catch (Exception)
@@ -106,9 +145,7 @@
                                 throw;
                             }
                         }
-                    }
-                    lh = new logwriter(lw);
-                    break;
+                    }                    
                 }
             }
         }

 

  ViewVC Help
Powered by ViewVC 1.1.22