SharpRSS/WebSharpRSS/Bootstrapper.cs

35 lines
1.2 KiB
C#
Raw Normal View History

using System;
using System.IO;
using Serilog;
using Serilog.Formatting.Json;
using Serilog.Sinks.SystemConsole.Themes;
2023-05-20 00:04:45 +02:00
using SharpRss.Models;
using ToolQit;
using ToolQit.Containers;
2023-05-20 00:04:45 +02:00
using WebSharpRSS.Models;
namespace WebSharpRSS
{
public static class Bootstrapper
{
2023-05-09 19:57:54 +02:00
public static void SetAppDefaultSettings(this DataContainer dataCon)
{
2023-05-12 23:58:49 +02:00
var paths = dataCon["Paths"];
//paths.Set("FaviconResolveUrl", "https://icons.duckduckgo.com/ip3/{0}.ico", false);
paths.Set("FaviconResolveUrl", "http://www.google.com/s2/favicons?domain={0}", false);
2023-05-12 23:58:49 +02:00
paths.Set("LogPath", Path.Combine(Environment.CurrentDirectory, "logs", "log_.json"), false);
}
private static LoggerConfiguration? _configuration;
public static void SetupLogging()
{
if (_configuration != null) return;
_configuration = new LoggerConfiguration()
.WriteTo.Console()
2023-05-12 23:58:49 +02:00
.WriteTo.File(new JsonFormatter(), Caretaker.Settings["Paths"].GetString("LogPath"), rollingInterval: RollingInterval.Day)
.MinimumLevel.Verbose();
2023-05-12 23:58:49 +02:00
Log.Logger = _configuration.CreateLogger();
}
}
}