SharpRSS/WebSharpRSS/Bootstrapper.cs
2023-05-20 00:04:45 +02:00

41 lines
1.5 KiB
C#

using System;
using System.IO;
using Serilog;
using Serilog.Formatting.Json;
using Serilog.Sinks.SystemConsole.Themes;
using SharpRss.Models;
using ToolQit;
using ToolQit.Containers;
using WebSharpRSS.Models;
namespace WebSharpRSS
{
public static class Bootstrapper
{
public static void SetAppDefaultSettings(this DataContainer dataCon)
{
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);
paths.Set("LogPath", Path.Combine(Environment.CurrentDirectory, "logs", "log_.json"), false);
var dbSql = dataCon["SQL"];
dbSql.Set("Host", "localhost", false);
dbSql.Set("Port", "6969", false);
dbSql.Set("Username", "sharpUser", false);
dbSql.Set("Password", "sh@rP@s$", false);
}
private static LoggerConfiguration? _configuration;
public static void SetupLogging()
{
if (_configuration != null) return;
_configuration = new LoggerConfiguration()
.WriteTo.Console()
.WriteTo.File(new JsonFormatter(), Caretaker.Settings["Paths"].GetString("LogPath"), rollingInterval: RollingInterval.Day)
.MinimumLevel.Verbose();
Log.Logger = _configuration.CreateLogger();
}
}
}