Add Serilog

This commit is contained in:
Runebaas 2017-09-26 13:02:38 +02:00
parent a7e3bb957f
commit 79e52774b8
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
7 changed files with 60 additions and 46 deletions

View file

@ -1,5 +1,6 @@
using System;
using System.IO;
using Serilog;
namespace Geekbot.net.Lib
{
@ -9,7 +10,7 @@ namespace Geekbot.net.Lib
private readonly Random rnd;
private readonly int totalCheckEmImages;
public CheckEmImageProvider(Random rnd)
public CheckEmImageProvider(Random rnd, ILogger logger)
{
var path = Path.GetFullPath("./Storage/checkEmPics");
if (File.Exists(path))
@ -18,12 +19,12 @@ namespace Geekbot.net.Lib
checkEmImageArray = rawCheckEmPics.Split("\n");
totalCheckEmImages = checkEmImageArray.Length;
this.rnd = rnd;
Console.WriteLine($"-- Loaded {totalCheckEmImages} CheckEm Images");
logger.Information($"-- Loaded {totalCheckEmImages} CheckEm Images");
}
else
{
Console.WriteLine("checkEmPics File not found");
Console.WriteLine($"Path should be {path}");
logger.Error("checkEmPics File not found");
logger.Error($"Path should be {path}");
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.IO;
using Serilog;
namespace Geekbot.net.Lib
{
@ -9,7 +10,7 @@ namespace Geekbot.net.Lib
private readonly Random rnd;
private readonly int totalFortunes;
public FortunesProvider(Random rnd)
public FortunesProvider(Random rnd, ILogger logger)
{
var path = Path.GetFullPath("./Storage/fortunes");
if (File.Exists(path))
@ -18,12 +19,12 @@ namespace Geekbot.net.Lib
fortuneArray = rawFortunes.Split("%");
totalFortunes = fortuneArray.Length;
this.rnd = rnd;
Console.WriteLine($"-- Loaded {totalFortunes} Fortunes");
logger.Information($"-- Loaded {totalFortunes} Fortunes");
}
else
{
Console.WriteLine("Fortunes File not found");
Console.WriteLine($"Path should be {path}");
logger.Error("Fortunes File not found");
logger.Error($"Path should be {path}");
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.IO;
using Serilog;
namespace Geekbot.net.Lib
{
@ -9,7 +10,7 @@ namespace Geekbot.net.Lib
private readonly Random rnd;
private readonly int totalPandas;
public PandaProvider(Random rnd)
public PandaProvider(Random rnd, ILogger logger)
{
var path = Path.GetFullPath("./Storage/pandas");
if (File.Exists(path))
@ -18,12 +19,12 @@ namespace Geekbot.net.Lib
PandaArray = rawFortunes.Split("\n");
totalPandas = PandaArray.Length;
this.rnd = rnd;
Console.WriteLine($"-- Loaded {totalPandas} Panda Images");
logger.Information($"-- Loaded {totalPandas} Panda Images");
}
else
{
Console.WriteLine("Pandas File not found");
Console.WriteLine($"Path should be {path}");
logger.Error("Pandas File not found");
logger.Error($"Path should be {path}");
}
}
@ -32,7 +33,7 @@ namespace Geekbot.net.Lib
return PandaArray[rnd.Next(0, totalPandas)];
}
}
public interface IPandaProvider
{
string GetRandomPanda();