2017-10-26 00:55:04 +02:00
|
|
|
|
using System;
|
|
|
|
|
using Serilog;
|
2017-09-27 22:48:09 +02:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace Geekbot.net.Lib
|
|
|
|
|
{
|
|
|
|
|
public class LoggerFactory
|
|
|
|
|
{
|
|
|
|
|
public static ILogger createLogger(string[] args)
|
|
|
|
|
{
|
|
|
|
|
var loggerCreation = new LoggerConfiguration()
|
|
|
|
|
.WriteTo.LiterateConsole()
|
|
|
|
|
.WriteTo.RollingFile("Logs/geekbot-{Date}.txt", shared: true);
|
2017-10-26 00:55:04 +02:00
|
|
|
|
var sentryDsn = Environment.GetEnvironmentVariable("SENTRY");
|
|
|
|
|
if (!string.IsNullOrEmpty(sentryDsn))
|
|
|
|
|
{
|
|
|
|
|
loggerCreation.WriteTo.SentryIO(sentryDsn)
|
|
|
|
|
.Enrich.FromLogContext();
|
|
|
|
|
Console.WriteLine($"Logging to Sentry Enabled: {sentryDsn}");
|
|
|
|
|
}
|
2017-10-02 21:57:48 +02:00
|
|
|
|
if (args.Contains("--verbose"))
|
2017-09-27 22:48:09 +02:00
|
|
|
|
{
|
|
|
|
|
loggerCreation.MinimumLevel.Verbose();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
loggerCreation.MinimumLevel.Information();
|
|
|
|
|
}
|
|
|
|
|
return loggerCreation.CreateLogger();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|