Permalink
Browse files

Adding teh codez

  • Loading branch information...
1 parent 25fcb1d commit a94ebf82331c3270a26aa8dc980c21ceaf9f49e2 @ferventcoder committed Dec 18, 2012
Showing with 2,618 additions and 0 deletions.
  1. +56 −0 LoggingExtensions.Core/LogExtensions.cs.pp
  2. +56 −0 LoggingExtensions.Core/LogExtensions.vb.pp
  3. +89 −0 LoggingExtensions.Core/Logging/ILog.cs
  4. +55 −0 LoggingExtensions.Core/Logging/Log.cs
  5. +54 −0 LoggingExtensions.Core/Logging/NullLog.cs
  6. +57 −0 LoggingExtensions.Core/LoggingExtensions.Core.csproj
  7. +36 −0 LoggingExtensions.Core/Properties/AssemblyInfo.cs
  8. +4 −0 LoggingExtensions.Core/ReadMe.txt
  9. +21 −0 LoggingExtensions.Core/this.Log.nuspec
  10. +65 −0 LoggingExtensions.Moq/LoggingExtensions.Moq.csproj
  11. +100 −0 LoggingExtensions.Moq/MockLogger.cs
  12. +36 −0 LoggingExtensions.Moq/Properties/AssemblyInfo.cs
  13. +7 −0 LoggingExtensions.Moq/ReadMe.txt
  14. +4 −0 LoggingExtensions.Moq/packages.config
  15. +22 −0 LoggingExtensions.Moq/this.log-Moq.nuspec
  16. +65 −0 LoggingExtensions.NLog/LoggingExtensions.NLog.csproj
  17. +74 −0 LoggingExtensions.NLog/NLogLog.cs
  18. +36 −0 LoggingExtensions.NLog/Properties/AssemblyInfo.cs
  19. +6 −0 LoggingExtensions.NLog/ReadMe.txt
  20. +4 −0 LoggingExtensions.NLog/packages.config
  21. +22 −0 LoggingExtensions.NLog/this.Log-NLog.nuspec
  22. +65 −0 LoggingExtensions.RhinoMocks/LoggingExtensions.RhinoMocks.csproj
  23. +107 −0 LoggingExtensions.RhinoMocks/MockLogger.cs
  24. +36 −0 LoggingExtensions.RhinoMocks/Properties/AssemblyInfo.cs
  25. +7 −0 LoggingExtensions.RhinoMocks/ReadMe.txt
  26. +4 −0 LoggingExtensions.RhinoMocks/packages.config
  27. +22 −0 LoggingExtensions.RhinoMocks/this.log-RhinoMocks.nuspec
  28. +64 −0 LoggingExtensions.Tests/LogExtensions.cs
  29. +90 −0 LoggingExtensions.Tests/LoggingExtensions.Tests.csproj
  30. +140 −0 LoggingExtensions.Tests/Performance/Log4NetPerformanceSpecs.cs
  31. +36 −0 LoggingExtensions.Tests/Properties/AssemblyInfo.cs
  32. +66 −0 LoggingExtensions.Tests/TinySpec.cs
  33. +9 −0 LoggingExtensions.Tests/packages.config
  34. +56 −0 LoggingExtensions.log4net.Sample.VB/LogExtensions.vb
  35. +134 −0 LoggingExtensions.log4net.Sample.VB/LoggingExtensions.log4net.VB.Sample.vbproj
  36. +35 −0 LoggingExtensions.log4net.Sample.VB/My Project/AssemblyInfo.vb
  37. +13 −0 LoggingExtensions.log4net.Sample.VB/SampleRun.vb
  38. +13 −0 LoggingExtensions.log4net.Sample.VB/SampleRun.vb.pp
  39. +7 −0 LoggingExtensions.log4net.Sample.VB/TestClass.vb
  40. +7 −0 LoggingExtensions.log4net.Sample.VB/TestClass.vb.pp
  41. +69 −0 LoggingExtensions.log4net.Sample.VB/app.config
  42. +6 −0 LoggingExtensions.log4net.Sample.VB/packages.config
  43. +25 −0 LoggingExtensions.log4net.Sample.VB/this.Log-log4net.Sample.VB.nuspec
  44. +69 −0 LoggingExtensions.log4net.Sample/App.config
  45. +56 −0 LoggingExtensions.log4net.Sample/LogExtensions.cs
  46. +112 −0 LoggingExtensions.log4net.Sample/LoggingExtensions.log4net.Sample.csproj
  47. +36 −0 LoggingExtensions.log4net.Sample/Properties/AssemblyInfo.cs
  48. +34 −0 LoggingExtensions.log4net.Sample/SampleRun.cs
  49. +34 −0 LoggingExtensions.log4net.Sample/SampleRun.cs.pp
  50. +6 −0 LoggingExtensions.log4net.Sample/packages.config
  51. +24 −0 LoggingExtensions.log4net.Sample/this.Log-log4net.Sample.nuspec
  52. +100 −0 LoggingExtensions.log4net/Log4NetLog.cs
  53. +69 −0 LoggingExtensions.log4net/LoggingExtensions.log4net.csproj
  54. +36 −0 LoggingExtensions.log4net/Properties/AssemblyInfo.cs
  55. +8 −0 LoggingExtensions.log4net/ReadMe.txt
  56. +4 −0 LoggingExtensions.log4net/packages.config
  57. +22 −0 LoggingExtensions.log4net/this.log-log4net.nuspec
  58. +128 −0 LoggingExtensions.sln
@@ -0,0 +1,56 @@
+// ==============================================================================
+//
+// RealDimensions Software, LLC - Copyright © 2012 - Present - Released under the Apache 2.0 License
+//
+// Copyright 2007-2008 The Apache Software Foundation.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+// this file except in compliance with the License. You may obtain a copy of the
+// License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software distributed
+// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+// CONDITIONS OF ANY KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations under the License.
+// ==============================================================================
+
+namespace $rootnamespace$
+{
+ using System.Collections.Concurrent;
+ using LoggingExtensions.Logging;
+
+ /// <summary>
+ /// Extensions to help make logging awesome - this should be installed into the root namespace of your application
+ /// </summary>
+ public static class LogExtensions
+ {
+ /// <summary>
+ /// Concurrent dictionary that ensures only one instance of a logger for a type.
+ /// </summary>
+ private static readonly ConcurrentDictionary<string, ILog> _dictionary = new ConcurrentDictionary<string, ILog>();
+
+ /// <summary>
+ /// Gets the logger for <see cref="T"/>.
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="type">The type to get the logger for.</param>
+ /// <returns>Instance of a logger for the object.</returns>
+ public static ILog Log<T>(this T type)
+ {
+ string objectName = typeof (T).FullName;
+ return Log(objectName);
+ }
+
+ /// <summary>
+ /// Gets the logger for the specified object name.
+ /// </summary>
+ /// <param name="objectName">Either use the fully qualified object name or the short. If used with Log&lt;T&gt;() you must use the fully qualified object name"/></param>
+ /// <returns>Instance of a logger for the object.</returns>
+ public static ILog Log(this string objectName)
+ {
+ return _dictionary.GetOrAdd(objectName, LoggingExtensions.Logging.Log.GetLoggerFor);
+ }
+ }
+}
@@ -0,0 +1,56 @@
+' ==============================================================================
+'
+' RealDimensions Software, LLC - Copyright © 2012 - Present - Released under the Apache 2.0 License
+'
+' Copyright 2007-2008 The Apache Software Foundation.
+'
+' Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+' this file except in compliance with the License. You may obtain a copy of the
+' License at
+'
+' http://www.apache.org/licenses/LICENSE-2.0
+'
+' Unless required by applicable law or agreed to in writing, software distributed
+' under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+' CONDITIONS OF ANY KIND, either express or implied. See the License for the
+' specific language governing permissions and limitations under the License.
+' ==============================================================================
+
+Imports System.Collections.Concurrent
+Imports System.Runtime.CompilerServices
+Imports LoggingExtensions.Logging
+
+''' <summary>
+''' Extensions to help make logging awesome - this should be installed into the root namespace of your application
+''' </summary>
+Public Module LogExtensions
+
+ ''' <summary>
+ ''' Concurrent dictionary that ensures only one instance of a logger for a type.
+ ''' </summary>
+ Private ReadOnly _dictionary As ConcurrentDictionary(Of String, ILog) = New ConcurrentDictionary(Of String, ILog)
+
+ ''' <summary>
+ ''' Gets the logger for <see cref="T"/>.
+ ''' </summary>
+ ''' <typeparam name="T"></typeparam>
+ ''' <param name="type">The type to get the logger for.</param>
+ ''' <returns>Instance of a logger for the object.</returns>
+ <Extension()>
+ Public Function Log(Of T)(type As T) As ILog
+ Dim objectName As String = GetType(T).FullName
+
+ Return Log(objectName)
+ End Function
+
+ ''' <summary>
+ ''' Gets the logger for the specified object name.
+ ''' </summary>
+ ''' <param name="objectName">Either use the fully qualified object name or the short. If used with Log&lt;T&gt;() you must use the fully qualified object name"/></param>
+ ''' <returns>Instance of a logger for the object.</returns>
+ <Extension()>
+ Public Function Log(objectName As String) As ILog
+ Return _dictionary.GetOrAdd(objectName, Function(name) (LoggingExtensions.Logging.Log.GetLoggerFor(name)))
+ End Function
+
+End Module
@@ -0,0 +1,89 @@
+namespace LoggingExtensions.Logging
+{
+ using System;
+
+ /// <summary>
+ /// Custom interface for logging messages
+ /// </summary>
+ public interface ILog
+ {
+ /// <summary>
+ /// Initializes the instance for the logger name
+ /// </summary>
+ /// <param name="loggerName">Name of the logger</param>
+ void InitializeFor(string loggerName);
+
+ /// <summary>
+ /// Debug level of the specified message. The other method is preferred since the execution is deferred.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ /// <param name="formatting">The formatting.</param>
+ void Debug(string message, params object[] formatting);
+
+ /// <summary>
+ /// Debug level of the specified message.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ void Debug(Func<string> message);
+
+ /// <summary>
+ /// Info level of the specified message. The other method is preferred since the execution is deferred.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ /// <param name="formatting">The formatting.</param>
+ void Info(string message, params object[] formatting);
+
+ /// <summary>
+ /// Info level of the specified message.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ void Info(Func<string> message);
+
+ /// <summary>
+ /// Warn level of the specified message. The other method is preferred since the execution is deferred.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ /// <param name="formatting">The formatting.</param>
+ void Warn(string message, params object[] formatting);
+
+ /// <summary>
+ /// Warn level of the specified message.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ void Warn(Func<string> message);
+
+ /// <summary>
+ /// Error level of the specified message. The other method is preferred since the execution is deferred.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ /// <param name="formatting">The formatting.</param>
+ void Error(string message, params object[] formatting);
+
+ /// <summary>
+ /// Error level of the specified message.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ void Error(Func<string> message);
+
+ /// <summary>
+ /// Fatal level of the specified message. The other method is preferred since the execution is deferred.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ /// <param name="formatting">The formatting.</param>
+ void Fatal(string message, params object[] formatting);
+
+ /// <summary>
+ /// Fatal level of the specified message.
+ /// </summary>
+ /// <param name="message">The message.</param>
+ void Fatal(Func<string> message);
+ }
+
+ /// <summary>
+ /// Ensures a default constructor for the logger type
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ public interface ILog<T> //where T : new()
+ {
+ }
+}
@@ -0,0 +1,55 @@
+namespace LoggingExtensions.Logging
+{
+ using System;
+ using System.Collections.Concurrent;
+ using System.ComponentModel;
+
+ /// <summary>
+ /// Logger type initialization
+ /// </summary>
+ public static class Log
+ {
+ private static Type _logType = typeof(NullLog);
+ private static ILog _testLogger;
+
+ /// <summary>
+ /// Sets up logging to be with a certain type
+ /// </summary>
+ /// <typeparam name="T">The type of ILog for the application to use</typeparam>
+ public static void InitializeWith<T>() where T : ILog, new()
+ {
+ _logType = typeof(T);
+ }
+
+ /// <summary>
+ /// Sets up logging to be with a certain instance. The other method is preferred.
+ /// </summary>
+ /// <param name="testLoggerType">Type of the logger.</param>
+ /// <remarks>This is mostly geared towards testing</remarks>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static void InitializeWith(ILog testLoggerType)
+ {
+ _logType = testLoggerType.GetType();
+ _testLogger = testLoggerType;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of a logger for an object.
+ /// This should be done only once per object name.
+ /// </summary>
+ /// <param name="objectName">Name of the object.</param>
+ /// <returns>ILog instance for an object if log type has been intialized; otherwise null</returns>
+ public static ILog GetLoggerFor(string objectName)
+ {
+ if (_testLogger != null) return _testLogger;
+
+ var logger = Activator.CreateInstance(_logType) as ILog;
+ if (logger != null)
+ {
+ logger.InitializeFor(objectName);
+ }
+
+ return logger;
+ }
+ }
+}
@@ -0,0 +1,54 @@
+namespace LoggingExtensions.Logging
+{
+ using System;
+
+ /// <summary>
+ /// The default logger until one is set.
+ /// </summary>
+ public class NullLog : ILog, ILog<NullLog>
+ {
+ public void InitializeFor(string loggerName)
+ {
+ }
+
+ public void Debug(string message, params object[] formatting)
+ {
+ }
+
+ public void Debug(Func<string> message)
+ {
+ }
+
+ public void Info(string message, params object[] formatting)
+ {
+ }
+
+ public void Info(Func<string> message)
+ {
+ }
+
+ public void Warn(string message, params object[] formatting)
+ {
+ }
+
+ public void Warn(Func<string> message)
+ {
+ }
+
+ public void Error(string message, params object[] formatting)
+ {
+ }
+
+ public void Error(Func<string> message)
+ {
+ }
+
+ public void Fatal(string message, params object[] formatting)
+ {
+ }
+
+ public void Fatal(Func<string> message)
+ {
+ }
+ }
+}
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{F61EB8DD-2E99-4E3B-96F0-8015FC6FB880}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>LoggingExtensions</RootNamespace>
+ <AssemblyName>this.Log</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Logging\ILog.cs" />
+ <Compile Include="Logging\Log.cs" />
+ <Content Include="ReadMe.txt" />
+ <Content Include="LogExtensions.cs.pp" />
+ <Compile Include="Logging\NullLog.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="LogExtensions.vb.pp" />
+ <None Include="this.Log.nuspec" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
Oops, something went wrong. Retry.

0 comments on commit a94ebf8

Please sign in to comment.