Skip to content

Commit

Permalink
Replaced internal NLogAdapter with Caliburn.Micro.Logging & Caliburn.…
Browse files Browse the repository at this point in the history
…Micro.Logging.NLog
  • Loading branch information
unknown authored and unknown committed Jan 11, 2012
1 parent dadddaa commit ce34aaf
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 38 deletions.
5 changes: 3 additions & 2 deletions src/MarkPad/AppBootstrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ private static void SetupLogging()
protected override void Configure()
{
SetupLogging();

Caliburn.Micro.LogManager.GetLog = t => new NLogAdapter(t);
// DTB: replaced use of internal NLogAdapter to the one provided by Caliburn.Micro.Logging
Caliburn.Micro.LogManager.GetLog = t => new Caliburn.Micro.Logging.NLog.NLogLogger(t);
//Caliburn.Micro.LogManager.GetLog = t => new NLogAdapter(t);

var builder = new ContainerBuilder();

Expand Down
85 changes: 85 additions & 0 deletions src/MarkPad/Caliburn/Micro/Logging/DebugLogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using System;
using System.Diagnostics;

namespace Caliburn.Micro.Logging
{
/// <summary>
/// Implementation of the ILog and ILogExtended interfaces using
/// <see cref="Debug"/>.
/// </summary>
public class DebugLogger : ILog, ILogExtended
{
#region Constants
private const string ErrorText = "ERROR";
private const string WarnText = "WARN";
private const string InfoText = "INFO";
#endregion

#region Fields
private readonly Type _type;
#endregion

#region Constructors
public DebugLogger(Type type)
{
_type = type;
}
#endregion

#region Helper Methods
private string CreateLogMessage(string format, params object[] args)
{
return string.Format("[{0}] {1}", DateTime.Now.ToString("o"), string.Format(format, args));
}
#endregion

#region ILog Members
/// <summary>
/// Logs the exception.
/// </summary>
/// <param name="exception">The exception.</param>
public void Error(Exception exception)
{
Debug.WriteLine(CreateLogMessage(exception.ToString()), ErrorText);
}
/// <summary>
/// Logs the message as info.
/// </summary>
/// <param name="format">A formatted message.</param><param name="args">Parameters to be injected into the formatted message.</param>
public void Info(string format, params object[] args)
{
Debug.WriteLine(CreateLogMessage(format, args), InfoText);
}
/// <summary>
/// Logs the message as a warning.
/// </summary>
/// <param name="format">A formatted message.</param><param name="args">Parameters to be injected into the formatted message.</param>
public void Warn(string format, params object[] args)
{
Debug.WriteLine(CreateLogMessage(format, args), WarnText);
}
#endregion

#region Implementation of ILogExtended
/// <summary>
/// Logs the message as error.
/// </summary>
/// <param name="format">A formatted message.</param>
/// <param name="args">Parameters to be injected into the formatted message.</param>
public void Error(string format, params object[] args)
{
Debug.WriteLine(CreateLogMessage(format, args), ErrorText);
}
/// <summary>
/// Logs the exception.
/// </summary>
/// <param name="exception">The exception.</param>
/// <param name="format">A formatted message.</param>
/// <param name="args">Parameters to be injected into the formatted message.</param>
public void Error(Exception exception, string format, params object[] args)
{
Debug.WriteLine(CreateLogMessage(format + " - Exception = " + exception.ToString(), args), ErrorText);
}
#endregion
}
}
35 changes: 0 additions & 35 deletions src/MarkPad/Framework/NLogAdapter.cs

This file was deleted.

46 changes: 45 additions & 1 deletion src/MarkPad/MarkPad.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@
<RestorePackages>true</RestorePackages>
<Utf8Output>true</Utf8Output>
<ExpressionBlendVersion>4.0.30816.0</ExpressionBlendVersion>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
Expand Down Expand Up @@ -63,6 +78,12 @@
<Reference Include="Caliburn.Micro">
<HintPath>..\..\packages\Caliburn.Micro.1.2.0\lib\Net40\Caliburn.Micro.dll</HintPath>
</Reference>
<Reference Include="Caliburn.Micro.Logging">
<HintPath>..\..\packages\Caliburn.Micro.Logging.1.2.1\lib\net40\Caliburn.Micro.Logging.dll</HintPath>
</Reference>
<Reference Include="Caliburn.Micro.Logging.NLog">
<HintPath>..\..\packages\Caliburn.Micro.Logging.NLog.1.2.1\lib\net40\Caliburn.Micro.Logging.NLog.dll</HintPath>
</Reference>
<Reference Include="CookComputing.XmlRpcV2">
<HintPath>..\..\packages\xmlrpcnet.2.5.0\lib\net20\CookComputing.XmlRpcV2.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -104,6 +125,7 @@
<DependentUpon>AboutView.xaml</DependentUpon>
</Compile>
<Compile Include="About\AboutViewModel.cs" />
<Compile Include="Caliburn\Micro\Logging\DebugLogger.cs" />
<Compile Include="Document\FormattingCommands.cs" />
<Compile Include="Framework\ObjectExtensions.cs" />
<Compile Include="Settings\BlogSetting.cs" />
Expand Down Expand Up @@ -176,14 +198,14 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Framework\EventAggregationAutoSubscriptionModule.cs" />
<Compile Include="Framework\NLogAdapter.cs" />
<Compile Include="Loader.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<EmbeddedResource Include="..\..\lib\AwesomiumProcess">
<Link>Libs\x86\AwesomiumProcess</Link>
</EmbeddedResource>
<None Include="app.config" />
<None Include="packages.config" />
<AppDesigner Include="Properties\" />
<EmbeddedResource Include="Syntax\Markdown.xshd" />
Expand Down Expand Up @@ -263,6 +285,28 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
<Import Project="$(SolutionDir)\tools\EmbedAssemblies.targets" />
Expand Down
2 changes: 2 additions & 0 deletions src/MarkPad/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<package id="Autofac" version="2.5.2.830" />
<package id="AvalonEdit" version="4.1.0.8000" />
<package id="Caliburn.Micro" version="1.2.0" />
<package id="Caliburn.Micro.Logging" version="1.2.1" />
<package id="Caliburn.Micro.Logging.NLog" version="1.2.1" />
<package id="MahApps.Metro" version="0.4.0.17" />
<package id="MarkdownSharp" version="1.13.0.0" />
<package id="NLog" version="2.0.0.2000" />
Expand Down

0 comments on commit ce34aaf

Please sign in to comment.