#9: add lightweightIocContainer

- add interfaces for FileLogger and ConsoleLogger
- add factories
- add installer
pull/26/head
Simon Gockner 6 years ago
parent b419d768e6
commit fcb5d7fd27
  1. 2
      GBase.Logging/ConsoleLogger.cs
  2. 14
      GBase.Logging/Factories/IConsoleLoggerFactory.cs
  3. 14
      GBase.Logging/Factories/IFileLoggerFactory.cs
  4. 14
      GBase.Logging/Factories/ILogFactory.cs
  5. 2
      GBase.Logging/FileLogger.cs
  6. 4
      GBase.Logging/GBase.Logging.csproj
  7. 27
      GBase.Logging/Installers/LoggingInstaller.cs
  8. 11
      GBase.Logging/Interfaces/IConsoleLogger.cs
  9. 11
      GBase.Logging/Interfaces/IFileLogger.cs

@ -11,7 +11,7 @@ namespace GBase.Logging
/// <summary>
/// An <see cref="ILogger"/> that writes log messages to the <see cref="Console"/>
/// </summary>
public class ConsoleLogger : ILogger
public class ConsoleLogger : IConsoleLogger
{
/// <summary>
/// Write the given <see cref="string"/> to the <see cref="Console"/>

@ -0,0 +1,14 @@
// Author: Gockner, Simon
// Created: 2020-02-12
// Copyright(c) 2020 SimonG. All Rights Reserved.
using GBase.Logging.Interfaces;
namespace GBase.Logging.Factories
{
public interface IConsoleLoggerFactory
{
IConsoleLogger Create();
}
}

@ -0,0 +1,14 @@
// Author: Gockner, Simon
// Created: 2020-02-12
// Copyright(c) 2020 SimonG. All Rights Reserved.
using GBase.Logging.Interfaces;
namespace GBase.Logging.Factories
{
public interface IFileLoggerFactory
{
IFileLogger Create(string filePath, string fileName);
}
}

@ -0,0 +1,14 @@
// Author: Gockner, Simon
// Created: 2020-02-12
// Copyright(c) 2020 SimonG. All Rights Reserved.
using GBase.Logging.Interfaces;
namespace GBase.Logging.Factories
{
public interface ILogFactory
{
ILog Create();
}
}

@ -12,7 +12,7 @@ namespace GBase.Logging
/// <summary>
/// An <see cref="ILogger"/> that writes log messages to a set file
/// </summary>
public class FileLogger : ILogger
public class FileLogger : IFileLogger
{
private readonly StreamWriter _fileWriter;
private readonly Timer _timer;

@ -4,4 +4,8 @@
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="LightweightIocContainer" Version="2.1.0" />
</ItemGroup>
</Project>

@ -0,0 +1,27 @@
// Author: Gockner, Simon
// Created: 2020-02-12
// Copyright(c) 2020 SimonG. All Rights Reserved.
using GBase.Logging.Factories;
using GBase.Logging.Interfaces;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Installers;
namespace GBase.Logging.Installers
{
public class LoggingInstaller : IIocInstaller
{
public void Install(IIocContainer container)
{
container.Register<ILog, Log>();
container.Register<IConsoleLogger, ConsoleLogger>();
container.Register<IFileLogger, FileLogger>();
//factories
container.RegisterFactory<ILogFactory>();
container.RegisterFactory<IConsoleLoggerFactory>();
container.RegisterFactory<IFileLoggerFactory>();
}
}
}

@ -0,0 +1,11 @@
// Author: Gockner, Simon
// Created: 2020-02-12
// Copyright(c) 2020 SimonG. All Rights Reserved.
namespace GBase.Logging.Interfaces
{
public interface IConsoleLogger : ILogger
{
}
}

@ -0,0 +1,11 @@
// Author: Gockner, Simon
// Created: 2020-02-12
// Copyright(c) 2020 SimonG. All Rights Reserved.
namespace GBase.Logging.Interfaces
{
public interface IFileLogger : ILogger
{
}
}
Loading…
Cancel
Save