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 24 by william, Wed May 9 08:59:52 2012 UTC vs.
Revision 26 by william, Wed May 9 09:28:57 2012 UTC

# Line 13 | Line 13 | namespace RomCheater.Logging
13          void WriteLine(string format, params object[] args);
14      }
15  
16 <    #region public static class Logger
16 >
17 >    #region MesageLogger
18 >    [Flags]
19 >    public enum loggerflags
20 >    {
21 >        NONE = 0x0000,              // 000
22 >        INFO = 0x0001,              // 001
23 >        DEBUG = 0x0002,             // 010
24 >        ERROR= 0x0004,              // 100
25 >        DEFAULT = INFO | ERROR,
26 >        ALL = 0x07,
27 >    }
28      public static class logger
29      {
30 +        private static loggerflags logging_flags;
31 +        static logger() { SetLoggingFlags(loggerflags.DEFAULT); }
32 +        public static void SetLoggingFlags(loggerflags flags) { logging_flags = flags; }
33 +        #region sub-classes
34 +        public static class Info
35 +        {
36 +            private static string CreateNewFormat(string format) { return "    INFO: " + format; }
37 +            public static void Write(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.INFO)) { xlogger.Write(CreateNewFormat(format), args); } }
38 +            public static void WriteLine(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.INFO)) { xlogger.WriteLine(CreateNewFormat(format), args); } }
39 +        }
40 +        public static class Debug
41 +        {
42 +            private static string CreateNewFormat(string format) { return "    DEBUG: " + format; }
43 +            public static void Write(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.DEBUG)) { xlogger.Write(CreateNewFormat(format), args); } }
44 +            public static void WriteLine(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.DEBUG)) { xlogger.WriteLine(CreateNewFormat(format), args); } }
45 +        }
46 +        public static class Error
47 +        {
48 +            private static string CreateNewFormat(string format) { return "    ERROR: " + format; }
49 +            public static void Write(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.ERROR)) { xlogger.Write(CreateNewFormat(format), args); } }
50 +            public static void WriteLine(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.ERROR)) { xlogger.WriteLine(CreateNewFormat(format), args); } }
51 +        }
52 +        #endregion
53 +
54 +    }
55 +    #endregion
56 +
57 +    #region internal static class Logger
58 +    internal static class xlogger
59 +    {
60          private static logwriter lh;
61 <        static logger() { lh = new logwriter(); }
61 >        static xlogger() { lh = new logwriter(); }
62  
63          #region ILogger Members
64          public static void Write(string format, params object[] args)
65          {            
66              init();
67 <            string new_format = "    " + format;
27 <            lh.Write(new_format, args);
67 >            lh.Write(format, args);
68          }
69          public static void WriteLine(string format, params object[] args)
70          {
71              init();
72 <            string new_format = "    " + format;
33 <            lh.WriteLine(new_format, args);
72 >            lh.WriteLine(format, args);
73          }
74          #endregion
75  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines