--- trunk/RomCheater.Logging/logger.cs 2012/06/22 08:21:18 414 +++ trunk/RomCheater.Logging/logger.cs 2012/06/22 08:33:51 415 @@ -1,6 +1,6 @@ #region Logging Defines // include this any class or method that required logging, and comment-out what is not needed -#define LOGGING_ENABLED +#define LOGGING_ENABLED // this is only valid within the logger class #region Enabled logging levels #define LOGGING_ENABLE_INFO #define LOGGING_ENABLE_WARN @@ -24,11 +24,11 @@ namespace RomCheater.Logging { - public interface ILogger - { - void Write(string format, params object[] args); - void WriteLine(string format, params object[] args); - } + //public interface ILogger + //{ + // void Write(string format, params object[] args); + // void WriteLine(string format, params object[] args); + //} #region loggerflags @@ -210,57 +210,58 @@ public static class Info { private static string CreateNewFormat(string format) { return " " + CreateTimeStamp() + "(INFO) " + format; } - [Conditional("LOGGING_ENABLE_INFO"), Conditional("LOGGING_ENABLED")] + [Conditional("LOGGING_ENABLE_INFO")] public static void Write(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.INFO)) { xlogger.Write(CreateNewFormat(format), args); } } - [Conditional("LOGGING_ENABLE_INFO"), Conditional("LOGGING_ENABLED")] + [Conditional("LOGGING_ENABLE_INFO")] public static void WriteLine(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.INFO)) { xlogger.WriteLine(CreateNewFormat(format), args); } } } public static class Warn { private static string CreateNewFormat(string format) { return " " + CreateTimeStamp() + "(WARN) " + format; } - [Conditional("LOGGING_ENABLE_WARN"), Conditional("LOGGING_ENABLED")] + [Conditional("LOGGING_ENABLE_WARN")] public static void Write(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.WARN)) { xlogger.Write(CreateNewFormat(format), args); } } - [Conditional("LOGGING_ENABLE_WARN"), Conditional("LOGGING_ENABLED")] + [Conditional("LOGGING_ENABLE_WARN")] public static void WriteLine(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.WARN)) { xlogger.WriteLine(CreateNewFormat(format), args); } } } public static class Debug { private static string CreateNewFormat(string format) { return " " + CreateTimeStamp() + "(DEBUG) " + format; } - [Conditional("LOGGING_ENABLE_DEBUG"), Conditional("LOGGING_ENABLED")] + [Conditional("LOGGING_ENABLE_DEBUG")] public static void Write(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.DEBUG)) { xlogger.Write(CreateNewFormat(format), args); } } - [Conditional("LOGGING_ENABLE_DEBUG"), Conditional("LOGGING_ENABLED")] + [Conditional("LOGGING_ENABLE_DEBUG")] 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; } - [Conditional("LOGGING_ENABLE_VERBOSEDEBUG"), Conditional("LOGGING_ENABLED")] + [Conditional("LOGGING_ENABLE_VERBOSEDEBUG")] public static void Write(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.VERBOSE_DEBUG)) { xlogger.Write(CreateNewFormat(format), args); } } - [Conditional("LOGGING_ENABLE_VERBOSEDEBUG"), Conditional("LOGGING_ENABLED")] + [Conditional("LOGGING_ENABLE_VERBOSEDEBUG")] + 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; } - [Conditional("LOGGING_ENABLE_ERROR"), Conditional("LOGGING_ENABLED")] + [Conditional("LOGGING_ENABLE_ERROR")] public static void Write(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.ERROR)) { xlogger.Write(CreateNewFormat(format), args); } } - [Conditional("LOGGING_ENABLE_ERROR"), Conditional("LOGGING_ENABLED")] + [Conditional("LOGGING_ENABLE_ERROR")] 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; } - [Conditional("LOGGING_ENABLE_VERBOSEERROR"), Conditional("LOGGING_ENABLED")] + [Conditional("LOGGING_ENABLE_VERBOSEERROR")] public static void Write(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.VERBOSE_ERROR)) { xlogger.Write(CreateNewFormat(format), args); } } - [Conditional("LOGGING_ENABLE_VERBOSEERROR"), Conditional("LOGGING_ENABLED")] + [Conditional("LOGGING_ENABLE_VERBOSEERROR")] public static void WriteLine(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.VERBOSE_ERROR)) { xlogger.WriteLine(CreateNewFormat(format), args); } } } public static class Profiler { private static string CreateNewFormat(string format) { return " " + CreateTimeStamp() + "(PROFILER) " + format; } - [Conditional("LOGGING_ENABLE_PROFILER"), Conditional("LOGGING_ENABLED")] + [Conditional("LOGGING_ENABLE_PROFILER")] public static void Write(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.PROFILER)) { xlogger.Write(CreateNewFormat(format), args); } } - [Conditional("LOGGING_ENABLE_PROFILER"), Conditional("LOGGING_ENABLED")] + [Conditional("LOGGING_ENABLE_PROFILER")] public static void WriteLine(string format, params object[] args) { if (logging_flags.HasFlag(loggerflags.PROFILER)) { xlogger.WriteLine(CreateNewFormat(format), args); } } } #region Force logging @@ -310,11 +311,13 @@ static xlogger() { lh = new logwriter(); } #region ILogger Members + [Conditional("LOGGING_ENABLED")] public static void Write(string format, params object[] args) { init(); lh.Write(format, args); } + [Conditional("LOGGING_ENABLED")] public static void WriteLine(string format, params object[] args) { init(); @@ -358,7 +361,7 @@ #endregion #region internal class LogHelper : ILogger - internal class logwriter : ILogger + internal class logwriter //: ILogger { private LogWriter writer; public logwriter() : this(null) { } @@ -367,10 +370,12 @@ this.writer = writer; } #region ILogger Members + [Conditional("LOGGING_ENABLED")] public void Write(string format, params object[] args) { WriteToLog(format, false, args); } + [Conditional("LOGGING_ENABLED")] public void WriteLine(string format, params object[] args) { WriteToLog(format, true, args);