2023-05-07 18:37:25 +02:00
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
using Serilog;
|
|
|
|
using Serilog.Formatting.Json;
|
2023-05-19 14:40:57 +02:00
|
|
|
using Serilog.Sinks.SystemConsole.Themes;
|
2023-05-20 00:04:45 +02:00
|
|
|
using SharpRss.Models;
|
2023-05-07 18:37:25 +02:00
|
|
|
using ToolQit;
|
|
|
|
using ToolQit.Containers;
|
2023-05-20 00:04:45 +02:00
|
|
|
using WebSharpRSS.Models;
|
2023-05-07 18:37:25 +02:00
|
|
|
|
|
|
|
namespace WebSharpRSS
|
|
|
|
{
|
|
|
|
public static class Bootstrapper
|
|
|
|
{
|
2023-05-09 19:57:54 +02:00
|
|
|
public static void SetAppDefaultSettings(this DataContainer dataCon)
|
2023-05-07 18:37:25 +02:00
|
|
|
{
|
2023-05-12 23:58:49 +02:00
|
|
|
var paths = dataCon["Paths"];
|
2023-05-15 15:53:08 +02:00
|
|
|
//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);
|
2023-05-07 18:37:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
2023-05-07 18:37:25 +02:00
|
|
|
.MinimumLevel.Verbose();
|
2023-05-12 23:58:49 +02:00
|
|
|
|
2023-05-07 18:37:25 +02:00
|
|
|
Log.Logger = _configuration.CreateLogger();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|