Skip to content

Commit

Permalink
x97mdr#11 Added and configured log4net to the project. Added some ver…
Browse files Browse the repository at this point in the history
…y basic logging messages"
  • Loading branch information
Jeffrey Cameron committed Oct 21, 2011
1 parent 16d379f commit a685710
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Pickles/Pickles.CommandLine/Pickles.CommandLine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\packages\log4net.1.2.10\lib\2.0\log4net.dll</HintPath>
</Reference>
<Reference Include="NDesk.Options">
<HintPath>..\packages\NDesk.Options.0.2.1\lib\NDesk.Options.dll</HintPath>
</Reference>
Expand Down
15 changes: 15 additions & 0 deletions src/Pickles/Pickles.CommandLine/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,33 @@ namespace Pickles.CommandLine
{
class Program
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

static void Main(string[] args)
{
log4net.Config.XmlConfigurator.Configure();

var configuration = new Configuration();
var commandLineArgumentParser = new CommandLineArgumentParser();
bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, Console.Out);

if (shouldContinue)
{
if (log.IsInfoEnabled)
{
log.InfoFormat("Pickles v.{0}{1}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(), Environment.NewLine);
log.InfoFormat("Reading features from {0}", configuration.FeatureFolder.FullName);
}

var documentFormatter = new HtmlDocumentFormatter(new HtmlTableOfContentsFormatter(), new HtmlFeatureFormatter(new HtmlScenarioFormatter(new HtmlStepFormatter(new HtmlTableFormatter(), new HtmlMultilineStringFormatter()))), new HtmlFooterFormatter());
var documentationBuilder = new HtmlDocumentationBuilder(new FeatureCrawler(new FeatureParser()), documentFormatter, new StylesheetWriter());

documentationBuilder.Build(configuration.FeatureFolder, configuration.OutputFolder);

if (log.IsInfoEnabled)
{
log.Info("Pickles completed successfully");
}
}
}
}
Expand Down
26 changes: 26 additions & 0 deletions src/Pickles/Pickles.CommandLine/app.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>

<log4net debug="false">
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
<param name="File" value="log.txt" />
<param name="AppendToFile" value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c %m%n" />
</layout>
</appender>

<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" >
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%m%n" />
</layout>
</appender>

<root>
<level value="INFO" />
<appender-ref ref="LogFileAppender" />
<appender-ref ref="ConsoleAppender" />
</root>
</log4net>

<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
Expand Down
1 change: 1 addition & 0 deletions src/Pickles/Pickles.CommandLine/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NDesk.Options" version="0.2.1" />
<package id="log4net" version="1.2.10" />
</packages>
6 changes: 6 additions & 0 deletions src/Pickles/Pickles/HtmlDocumentationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Pickles
{
public class HtmlDocumentationBuilder : IDocumentationBuilder
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private readonly FeatureCrawler featureCrawler;
private readonly HtmlDocumentFormatter htmlDocumentFormatter;
private readonly StylesheetWriter stylesheetWriter;
Expand All @@ -26,6 +27,11 @@ public HtmlDocumentationBuilder(FeatureCrawler featureCrawler, HtmlDocumentForma

public void Build(DirectoryInfo inputPath, DirectoryInfo outputPath)
{
if (log.IsInfoEnabled)
{
log.InfoFormat("Writing HTML to {0}", outputPath.FullName);
}

var masterCssPath = this.stylesheetWriter.WriteTo(outputPath.FullName);
var masterCssUri = new Uri(masterCssPath);

Expand Down
3 changes: 3 additions & 0 deletions src/Pickles/Pickles/Pickles.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
<Reference Include="IKVM.Runtime">
<HintPath>..\..\..\lib\ikvm\IKVM.Runtime.dll</HintPath>
</Reference>
<Reference Include="log4net">
<HintPath>..\packages\log4net.1.2.10\lib\2.0\log4net.dll</HintPath>
</Reference>
<Reference Include="NDesk.Options">
<HintPath>..\packages\NDesk.Options.0.2.1\lib\NDesk.Options.dll</HintPath>
</Reference>
Expand Down
1 change: 1 addition & 0 deletions src/Pickles/Pickles/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NDesk.Options" version="0.2.1" />
<package id="log4net" version="1.2.10" />
</packages>

0 comments on commit a685710

Please sign in to comment.