From f44b12cf56311a48a08f8ee6ede9b13e91397e83 Mon Sep 17 00:00:00 2001 From: tmont Date: Fri, 17 Apr 2009 06:28:21 +0000 Subject: [PATCH] branch reintegration from 1.1 svn merge http://svn.tommymontgomery.com/SimpleLog/trunk http://svn.tommymontgomery.com/SimpleLog/branches/1.1 --- SimpleLog.Tests/ConsoleLogHandlerTest.cs | 4 +- SimpleLog.Tests/DefaultLoggerTest.cs | 16 +-- SimpleLog.Tests/DefaultMessageHandlerTest.cs | 2 +- SimpleLog.Tests/LoggerManagerTest.cs | 24 +++++ SimpleLog.Tests/SimpleLog.Tests.csproj | 1 + SimpleLog/Properties/AssemblyInfo.cs | 36 ------- SimpleLog/SimpleLog.csproj | 38 ++++--- SimpleLog/{ => Src}/DefaultLogger.cs | 101 ++++++++++++++---- SimpleLog/{ => Src}/DefaultMessageHandler.cs | 56 ++++++++-- SimpleLog/{ => Src/Framework}/ILogHandler.cs | 2 +- SimpleLog/{ => Src/Framework}/ILogger.cs | 2 +- .../{ => Src/Framework}/IMessageFormatter.cs | 2 +- .../{ => Src/Framework}/IMessageHandler.cs | 2 +- SimpleLog/Src/Framework/LoggerManager.cs | 51 +++++++++ SimpleLog/{ => Src/Framework}/Util.cs | 32 +++++- .../LogHandlers/ConsoleLogHandler.cs | 3 +- .../LogHandlers/ConsoleWindowLogHandler.cs | 14 ++- .../{ => Src}/LogHandlers/FileLogHandler.cs | 6 +- Versioning.targets | 59 ++++++++++ 19 files changed, 335 insertions(+), 116 deletions(-) create mode 100644 SimpleLog.Tests/LoggerManagerTest.cs delete mode 100644 SimpleLog/Properties/AssemblyInfo.cs rename SimpleLog/{ => Src}/DefaultLogger.cs (59%) rename SimpleLog/{ => Src}/DefaultMessageHandler.cs (56%) rename SimpleLog/{ => Src/Framework}/ILogHandler.cs (91%) rename SimpleLog/{ => Src/Framework}/ILogger.cs (94%) rename SimpleLog/{ => Src/Framework}/IMessageFormatter.cs (83%) rename SimpleLog/{ => Src/Framework}/IMessageHandler.cs (91%) create mode 100644 SimpleLog/Src/Framework/LoggerManager.cs rename SimpleLog/{ => Src/Framework}/Util.cs (57%) rename SimpleLog/{ => Src}/LogHandlers/ConsoleLogHandler.cs (92%) rename SimpleLog/{ => Src}/LogHandlers/ConsoleWindowLogHandler.cs (92%) rename SimpleLog/{ => Src}/LogHandlers/FileLogHandler.cs (92%) create mode 100644 Versioning.targets diff --git a/SimpleLog.Tests/ConsoleLogHandlerTest.cs b/SimpleLog.Tests/ConsoleLogHandlerTest.cs index 60e998c..d8737ae 100644 --- a/SimpleLog.Tests/ConsoleLogHandlerTest.cs +++ b/SimpleLog.Tests/ConsoleLogHandlerTest.cs @@ -16,8 +16,8 @@ namespace SimpleLog.Tests { [Test] public void TestLog() { - Assert.That(this.handler.Log("yay", LogLevel.Critical)); - Assert.That(this.handler.Log("yay", LogLevel.Debug)); + Assert.That(this.handler.Log("yay", Framework.LogLevel.Critical)); + Assert.That(this.handler.Log("yay", Framework.LogLevel.Debug)); } [Test] diff --git a/SimpleLog.Tests/DefaultLoggerTest.cs b/SimpleLog.Tests/DefaultLoggerTest.cs index ecf2cd9..7d73ddd 100644 --- a/SimpleLog.Tests/DefaultLoggerTest.cs +++ b/SimpleLog.Tests/DefaultLoggerTest.cs @@ -2,6 +2,7 @@ using NUnit.Framework; using NUnit.Mocks; using NUnit.Framework.SyntaxHelpers; +using SimpleLog.Framework; namespace SimpleLog.Tests { [TestFixture] @@ -12,8 +13,7 @@ namespace SimpleLog.Tests { [SetUp] public void Init() { - this.Logger = DefaultLogger.Instance; - this.Logger.Enabled = true; + this.Logger = new DefaultLogger(); this.Logger.MessageHandler = new DefaultMessageHandler(); this.Handler = new DynamicMock(typeof(ILogHandler)); @@ -28,19 +28,21 @@ namespace SimpleLog.Tests { [Test] public void TestRegisterAndUnregisterLogHandler() { - int oldCount = this.Logger.LogHandlerCount; this.Handler.ExpectAndReturn("GetType", typeof(ILogHandler)); - + //this.Handler.ExpectAndReturn("GetType", typeof(ILogHandler)); ILogHandler handler = (ILogHandler)this.Handler.MockInstance; this.Logger.RegisterLogHandler(handler); - Assert.That(this.Logger.LogHandlerCount, Is.EqualTo(oldCount + 1)); + Assert.That(this.Logger.LogHandlerCount, Is.EqualTo(1)); - Assert.That(this.Logger.UnregisterLogHandlerType("SimpleLog.ILogHandler"), Is.EqualTo(1)); + //this.Logger.UnregisterLogHandlerType("SimpleLog.Framework.ILogHandler"); + + Assert.That(this.Logger.UnregisterLogHandlerType("SimpleLog.Framework.ILogHandler"), Is.EqualTo(1)); + Assert.That(this.Logger.LogHandlerCount, Is.EqualTo(0)); this.Logger.RegisterLogHandler(handler); - Assert.That(this.Logger.LogHandlerCount, Is.EqualTo(oldCount + 1)); + Assert.That(this.Logger.LogHandlerCount, Is.EqualTo(1)); this.Logger.UnregisterAllLogHandlers(); Assert.That(this.Logger.LogHandlerCount, Is.EqualTo(0)); diff --git a/SimpleLog.Tests/DefaultMessageHandlerTest.cs b/SimpleLog.Tests/DefaultMessageHandlerTest.cs index 16bed41..5a0df4c 100644 --- a/SimpleLog.Tests/DefaultMessageHandlerTest.cs +++ b/SimpleLog.Tests/DefaultMessageHandlerTest.cs @@ -37,7 +37,7 @@ namespace SimpleLog.Tests { expected += "\\[some kind of context\\] "; expected += "log message\n"; - Assert.That(this.messageHandler.FormatLogMessage("log message", LogLevel.Warning), Text.Matches(expected)); + Assert.That(this.messageHandler.FormatLogMessage("log message", Framework.LogLevel.Warning), Text.Matches(expected)); } } diff --git a/SimpleLog.Tests/LoggerManagerTest.cs b/SimpleLog.Tests/LoggerManagerTest.cs new file mode 100644 index 0000000..7042aa7 --- /dev/null +++ b/SimpleLog.Tests/LoggerManagerTest.cs @@ -0,0 +1,24 @@ +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; +using SimpleLog.Framework; + +namespace SimpleLog.Tests { + [TestFixture] + public class LoggerManagerTest { + + [Test] + public void TestGetLogger() { + DefaultLogger logger = LoggerManager.GetLogger(); + Assert.That(logger, Is.TypeOf(typeof(DefaultLogger))); + DefaultLogger logger2 = LoggerManager.GetLogger(); + Assert.That(logger2, Is.TypeOf(typeof(DefaultLogger))); + } + + [Test] + [ExpectedException("System.ArgumentException")] + public void TestGetLoggerThrowsArgumentException() { + LoggerManager.GetLogger(); + } + + } +} diff --git a/SimpleLog.Tests/SimpleLog.Tests.csproj b/SimpleLog.Tests/SimpleLog.Tests.csproj index 9e9fed8..15f11fc 100644 --- a/SimpleLog.Tests/SimpleLog.Tests.csproj +++ b/SimpleLog.Tests/SimpleLog.Tests.csproj @@ -51,6 +51,7 @@ + diff --git a/SimpleLog/Properties/AssemblyInfo.cs b/SimpleLog/Properties/AssemblyInfo.cs deleted file mode 100644 index ff8a4ef..0000000 --- a/SimpleLog/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SimpleLog")] -[assembly: AssemblyDescription("Simple .NET 3.5 logging utility")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SimpleLog")] -[assembly: AssemblyCopyright("Copyright © Tommy Montgomery 2009")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("eec4e17e-cbc6-4982-86dd-a3d0ce488eaf")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SimpleLog/SimpleLog.csproj b/SimpleLog/SimpleLog.csproj index ac0d2c2..5c99971 100644 --- a/SimpleLog/SimpleLog.csproj +++ b/SimpleLog/SimpleLog.csproj @@ -26,10 +26,11 @@ - pdbonly + None true bin\Release\ - TRACE + + prompt 4 @@ -48,24 +49,21 @@ - - - - - - - - - - - + + + + + + + + + + + + + + - + \ No newline at end of file diff --git a/SimpleLog/DefaultLogger.cs b/SimpleLog/Src/DefaultLogger.cs similarity index 59% rename from SimpleLog/DefaultLogger.cs rename to SimpleLog/Src/DefaultLogger.cs index 8e078be..dd1cf69 100644 --- a/SimpleLog/DefaultLogger.cs +++ b/SimpleLog/Src/DefaultLogger.cs @@ -1,35 +1,62 @@ using System; using System.Collections.Generic; +using SimpleLog.Framework; namespace SimpleLog { + /// + /// Default logger class; illustrates how to use + /// the SimpleLog framework. + /// public class DefaultLogger : ILogger { + #region Public members /// - /// The singleton instance of this logger. All interactions - /// with the logger should be done via this static property. - /// - public static readonly DefaultLogger Instance = new DefaultLogger(); - /// - /// Gets or sets whether this logger is enabled or not + /// Gets or sets whether this logger is enabled /// public bool Enabled; + #endregion - protected List LogHandlers; + #region Protected members + protected List logHandlers; protected IMessageHandler messageHandler; protected LogLevel logLevel; protected string dateFormat; protected string lineTerminator; + #endregion - private DefaultLogger() { - this.LogHandlers = new List(); - this.logLevel = SimpleLog.LogLevel.Warning; - this.lineTerminator = SimpleLog.LineTerminator.Unix; - this.Enabled = true; - this.messageHandler = new DefaultMessageHandler(); - this.dateFormat = "yyyy-MM-dd HH:mm:ss"; + #region Constructors + /// + /// Creates a new DefaultLogger with the default settings + /// + public DefaultLogger() : this(LogLevel.Warning) { + } + /// + /// Creates a new DefaultLogger initialized to the specified log level + /// + public DefaultLogger(LogLevel logLevel) : this(new DefaultMessageHandler(), "yyyy-MM-dd HH:mm:ss", logLevel, SimpleLog.Framework.LineTerminator.Unix) { + + } + + /// + /// Creates a new DefaultLogger + /// + /// A message handler + /// A date format suitable as an argument to string.Format() + /// The default log level + /// The line terminator + public DefaultLogger(IMessageHandler messageHandler, string dateFormat, LogLevel logLevel, string lineTerminator) { + this.LogHandlers = new List(); + this.LogLevel = logLevel; + this.LineTerminator = lineTerminator; + this.Enabled = true; + this.MessageHandler = messageHandler; + this.DateFormat = dateFormat; + } + #endregion + #region ILogger members /// /// Logs a message to all registered handlers @@ -37,14 +64,14 @@ namespace SimpleLog { /// The message to log /// The log level of the message /// TRUE if all handlers successfully logged the message, FALSE otherwise - public bool Log(object message, LogLevel level) { + public virtual bool Log(object message, LogLevel level) { bool success = true; if (this.Enabled) { string convertedMessage; LogLevel allowedLevel; IMessageHandler messageHandler; - foreach (ILogHandler handler in this.LogHandlers) { + foreach (ILogHandler handler in this.logHandlers) { allowedLevel = handler.LogLevel ?? (LogLevel)this.LogLevel; if (level >= allowedLevel) { messageHandler = handler.MessageHandler ?? this.MessageHandler; @@ -65,20 +92,19 @@ namespace SimpleLog { /// Registers a log handler /// public void RegisterLogHandler(ILogHandler handler) { - this.LogHandlers.Add(handler); + this.logHandlers.Add(handler); } /// /// Unregisters all log handlers that are instances or /// derived instances of the specified class /// - /// The fully qualified class name (e.g. SimpleLog.ILogHandler + /// The fully qualified class name (e.g. SimpleLog.Framework.ILogHandler) /// The number of log handlers that were removed public int UnregisterLogHandlerType(string qualifiedClassName) { - return this.LogHandlers.RemoveAll( + return this.logHandlers.RemoveAll( delegate(ILogHandler handler) { - //Console.WriteLine(handler.GetType().ToString() == qualifiedClassName); - return (handler.GetType().ToString() == qualifiedClassName); + return (handler.GetType().FullName == qualifiedClassName); } ); } @@ -89,10 +115,13 @@ namespace SimpleLog { /// The number of log handlers that were removed public int UnregisterAllLogHandlers() { int count = this.LogHandlerCount; - this.LogHandlers.RemoveRange(0, count); + this.logHandlers.RemoveRange(0, count); return count; } + /// + /// Gets or sets the message handler + /// public IMessageHandler MessageHandler { get { return this.messageHandler; @@ -101,6 +130,10 @@ namespace SimpleLog { this.messageHandler = value; } } + + /// + /// Gets or sets the log level + /// public LogLevel LogLevel { get { return this.logLevel; @@ -109,6 +142,10 @@ namespace SimpleLog { this.logLevel = value; } } + + /// + /// Gets or sets the format used for dates + /// public string DateFormat { get { return this.dateFormat; @@ -117,6 +154,10 @@ namespace SimpleLog { this.dateFormat = value; } } + + /// + /// Gets or sets the line terminator + /// public string LineTerminator { get { return this.lineTerminator; @@ -131,6 +172,19 @@ namespace SimpleLog { } #endregion + #region Accessors + /// + /// Gets or sets the list of registered log handlers + /// + protected List LogHandlers { + get { + return this.logHandlers; + } + set { + this.logHandlers = value; + } + } + /// /// Gets the number of registered log handlers /// @@ -139,7 +193,9 @@ namespace SimpleLog { return this.LogHandlers.Count; } } + #endregion + #region Convenience methods /// /// Logs a debug message /// @@ -174,6 +230,7 @@ namespace SimpleLog { public bool Critical(object message) { return this.Log(message, LogLevel.Critical); } + #endregion } } diff --git a/SimpleLog/DefaultMessageHandler.cs b/SimpleLog/Src/DefaultMessageHandler.cs similarity index 56% rename from SimpleLog/DefaultMessageHandler.cs rename to SimpleLog/Src/DefaultMessageHandler.cs index 21c1acf..bdc12e7 100644 --- a/SimpleLog/DefaultMessageHandler.cs +++ b/SimpleLog/Src/DefaultMessageHandler.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using SimpleLog.Framework; namespace SimpleLog { /// @@ -9,20 +10,52 @@ namespace SimpleLog { /// public class DefaultMessageHandler : IMessageHandler, IMessageFormatter { + #region Protected members protected string dateFormat; protected string lineTerminator; protected string context; protected string delimiter; + #endregion + + #region Constructors + /// + /// Creates a DefaultMessageHandler with the default settings + /// + public DefaultMessageHandler() : this("") { - public DefaultMessageHandler() { - this.dateFormat = null; - this.lineTerminator = SimpleLog.LineTerminator.Unix; - this.context = ""; - this.delimiter = "\t"; } + /// + /// Creates a DefaultMessageHandler with the specified context + /// + /// Context of the message handler + public DefaultMessageHandler(string context) : this(context, null, SimpleLog.Framework.LineTerminator.Unix, "\t") { + + } + + /// + /// Creates a DefaultMessageHandler + /// + /// Context of the message handler + /// Date format suitable as an argument to string.Format() + /// The line terminator + /// The string that delimits each part of the log message + public DefaultMessageHandler(string context, string dateFormat, string lineTerminator, string delimiter) { + this.DateFormat = dateFormat; + this.LineTerminator = lineTerminator; + this.Context = context; + this.Delimiter = delimiter; + } + #endregion + #region IMessageHandler Members - public string FormatLogMessage(string message, LogLevel level) { + /// + /// Formats a log message + /// + /// The message to log + /// The log level of the message + /// The formatted message + public virtual string FormatLogMessage(string message, LogLevel level) { List messageData = new List(); messageData.Add(string.Format("{0:" + this.DateFormat + "}", DateTime.Now)); messageData.Add(level.ToString().ToUpper()); @@ -42,7 +75,7 @@ namespace SimpleLog { /// /// The message object to convert /// The message as a string - public string ConvertMessageToString(object message) { + public virtual string ConvertMessageToString(object message) { string msg = null; if (message is Exception) { Exception e = (Exception)message; @@ -67,6 +100,7 @@ namespace SimpleLog { } #endregion + #region Accessors /// /// Gets or sets the delimiter used to separate log message data /// @@ -78,8 +112,12 @@ namespace SimpleLog { this.delimiter = value; } } + #endregion #region IMessageFormatter members + /// + /// Gets or sets the date format + /// public string DateFormat { get { return this.dateFormat; @@ -88,6 +126,10 @@ namespace SimpleLog { this.dateFormat = value; } } + + /// + /// Gets or sets the line terminator + /// public string LineTerminator { get { return this.lineTerminator; diff --git a/SimpleLog/ILogHandler.cs b/SimpleLog/Src/Framework/ILogHandler.cs similarity index 91% rename from SimpleLog/ILogHandler.cs rename to SimpleLog/Src/Framework/ILogHandler.cs index e8cc11b..c084e04 100644 --- a/SimpleLog/ILogHandler.cs +++ b/SimpleLog/Src/Framework/ILogHandler.cs @@ -1,4 +1,4 @@ -namespace SimpleLog { +namespace SimpleLog.Framework { public interface ILogHandler { /// diff --git a/SimpleLog/ILogger.cs b/SimpleLog/Src/Framework/ILogger.cs similarity index 94% rename from SimpleLog/ILogger.cs rename to SimpleLog/Src/Framework/ILogger.cs index 7ab0b4e..637a1fa 100644 --- a/SimpleLog/ILogger.cs +++ b/SimpleLog/Src/Framework/ILogger.cs @@ -1,4 +1,4 @@ -namespace SimpleLog { +namespace SimpleLog.Framework { public interface ILogger : IMessageFormatter { /// diff --git a/SimpleLog/IMessageFormatter.cs b/SimpleLog/Src/Framework/IMessageFormatter.cs similarity index 83% rename from SimpleLog/IMessageFormatter.cs rename to SimpleLog/Src/Framework/IMessageFormatter.cs index 1d26e28..6dc553d 100644 --- a/SimpleLog/IMessageFormatter.cs +++ b/SimpleLog/Src/Framework/IMessageFormatter.cs @@ -1,4 +1,4 @@ -namespace SimpleLog { +namespace SimpleLog.Framework { public interface IMessageFormatter { /// diff --git a/SimpleLog/IMessageHandler.cs b/SimpleLog/Src/Framework/IMessageHandler.cs similarity index 91% rename from SimpleLog/IMessageHandler.cs rename to SimpleLog/Src/Framework/IMessageHandler.cs index 57e0a34..6162fe2 100644 --- a/SimpleLog/IMessageHandler.cs +++ b/SimpleLog/Src/Framework/IMessageHandler.cs @@ -1,4 +1,4 @@ -namespace SimpleLog { +namespace SimpleLog.Framework { public interface IMessageHandler : IMessageFormatter { diff --git a/SimpleLog/Src/Framework/LoggerManager.cs b/SimpleLog/Src/Framework/LoggerManager.cs new file mode 100644 index 0000000..5a601fd --- /dev/null +++ b/SimpleLog/Src/Framework/LoggerManager.cs @@ -0,0 +1,51 @@ +using System; +using System.Reflection; +using System.Collections.Generic; + +namespace SimpleLog.Framework { + /// + /// Manages ILogger instances in a singletonish way and provides + /// a single point of entry to creating loggers. If singleton + /// behavior is not desired, just instantiate each logger class + /// normally. + /// + public static class LoggerManager { + + /// + /// Registry of ILogger instances + /// + private static Dictionary registry = new Dictionary(); + + /// + /// Gets a logger from the registry. + /// This will reuse a logger that has already been instantiated, + /// or create a new instance and stick it in the registry for + /// later use. + /// + /// The specified class must implement the SimpleLog.Framework.ILogger + /// interface + /// + /// + /// DefaultLogger logger = LogManager.GetLogger{DefaultLogger}(); + /// Must implement the SimpleLog.Framework.ILogger interface + /// + public static T GetLogger() { + Type type = typeof(T); + string index = type.FullName; + + if (LoggerManager.registry.ContainsKey(index)) { + ILogger logger; + LoggerManager.registry.TryGetValue(index, out logger); + return (T)logger; + } + + //Type interfaceType = type.GetInterface("ILogger"); + if (type.GetInterface("ILogger") != null && type.IsClass) { + return (T)Activator.CreateInstance(type); + } + + throw new ArgumentException("The type specified (" + index + ") does not implement the " + (typeof(ILogger).FullName) + " interface"); + } + + } +} diff --git a/SimpleLog/Util.cs b/SimpleLog/Src/Framework/Util.cs similarity index 57% rename from SimpleLog/Util.cs rename to SimpleLog/Src/Framework/Util.cs index a29b318..aca8b8b 100644 --- a/SimpleLog/Util.cs +++ b/SimpleLog/Src/Framework/Util.cs @@ -1,16 +1,37 @@ using System; -namespace SimpleLog { +namespace SimpleLog.Framework { + /// + /// Log level enumeration + /// [Flags] public enum LogLevel { + /// + /// Debug message + /// Debug = 1, + /// + /// Informational message + /// Info = 2, - Warning = 4, - Error = 8, - Critical = 16 + /// + /// Warning message + /// + Warning = 3, + /// + /// Error message + /// + Error = 4, + /// + /// Critical death message + /// + Critical = 5 } + /// + /// Struct representing the different line terminators + /// public struct LineTerminator { /// /// Windows line terminator (CRLF) @@ -26,6 +47,9 @@ namespace SimpleLog { public static readonly string Unix = "\n"; } + /// + /// Utility class + /// public static class Util { /// diff --git a/SimpleLog/LogHandlers/ConsoleLogHandler.cs b/SimpleLog/Src/LogHandlers/ConsoleLogHandler.cs similarity index 92% rename from SimpleLog/LogHandlers/ConsoleLogHandler.cs rename to SimpleLog/Src/LogHandlers/ConsoleLogHandler.cs index 5141150..33d924a 100644 --- a/SimpleLog/LogHandlers/ConsoleLogHandler.cs +++ b/SimpleLog/Src/LogHandlers/ConsoleLogHandler.cs @@ -1,4 +1,5 @@ using System; +using SimpleLog.Framework; namespace SimpleLog.LogHandlers { @@ -86,7 +87,7 @@ namespace SimpleLog.LogHandlers { /// The log level /// One of the STD_* constants protected virtual uint GetStreamType(LogLevel level) { - if (level >= SimpleLog.LogLevel.Warning) { + if (level >= SimpleLog.Framework.LogLevel.Warning) { return STD_ERROR_HANDLE; } diff --git a/SimpleLog/LogHandlers/ConsoleWindowLogHandler.cs b/SimpleLog/Src/LogHandlers/ConsoleWindowLogHandler.cs similarity index 92% rename from SimpleLog/LogHandlers/ConsoleWindowLogHandler.cs rename to SimpleLog/Src/LogHandlers/ConsoleWindowLogHandler.cs index 988d4c9..41278d1 100644 --- a/SimpleLog/LogHandlers/ConsoleWindowLogHandler.cs +++ b/SimpleLog/Src/LogHandlers/ConsoleWindowLogHandler.cs @@ -1,6 +1,6 @@ using System; using System.Runtime.InteropServices; -using System.Diagnostics; +using SimpleLog.Framework; namespace SimpleLog.LogHandlers { @@ -19,8 +19,6 @@ namespace SimpleLog.LogHandlers { HighIntensity = 0x0008, } - - /// /// Log handler for writing log messages to a console window (e.g. cmd.exe). /// @@ -76,15 +74,15 @@ namespace SimpleLog.LogHandlers { /// protected virtual ConsoleColor GetConsoleColors(LogLevel level) { switch (level) { - case SimpleLog.LogLevel.Debug: + case SimpleLog.Framework.LogLevel.Debug: return ConsoleColor.Green; - case SimpleLog.LogLevel.Info: + case SimpleLog.Framework.LogLevel.Info: return ConsoleColor.White; - case SimpleLog.LogLevel.Warning: + case SimpleLog.Framework.LogLevel.Warning: return ConsoleColor.Yellow | ConsoleColor.HighIntensity; - case SimpleLog.LogLevel.Error: + case SimpleLog.Framework.LogLevel.Error: return ConsoleColor.Red | ConsoleColor.HighIntensity; - case SimpleLog.LogLevel.Critical: + case SimpleLog.Framework.LogLevel.Critical: return (ConsoleColor.White | ConsoleColor.HighIntensity) + ((int)(ConsoleColor.Red | ConsoleColor.HighIntensity) << 4); default: return ConsoleColor.White; diff --git a/SimpleLog/LogHandlers/FileLogHandler.cs b/SimpleLog/Src/LogHandlers/FileLogHandler.cs similarity index 92% rename from SimpleLog/LogHandlers/FileLogHandler.cs rename to SimpleLog/Src/LogHandlers/FileLogHandler.cs index 4cdb5b1..547e5da 100644 --- a/SimpleLog/LogHandlers/FileLogHandler.cs +++ b/SimpleLog/Src/LogHandlers/FileLogHandler.cs @@ -1,8 +1,6 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.IO; +using SimpleLog.Framework; namespace SimpleLog.LogHandlers { public class FileLogHandler : ILogHandler { @@ -71,7 +69,7 @@ namespace SimpleLog.LogHandlers { try { File.AppendAllText(fileName, message); } - catch (Exception e) { + catch (Exception) { return false; } diff --git a/Versioning.targets b/Versioning.targets new file mode 100644 index 0000000..2494f6f --- /dev/null +++ b/Versioning.targets @@ -0,0 +1,59 @@ + + + + + + Tommy Montgomery + Copyright (C) 2009 Tommy Montgomery + 1 + 1 + 0 + 0 + Properties + + ConfigureVersionNumber; + CreateAssemblyInfo; + $(BuildDependsOn) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file