SharpRSS/WebSharpRSS/Bootstrapper.cs

37 lines
1.3 KiB
C#
Raw Normal View History

using System;
using System.IO;
using Serilog;
using Serilog.Formatting.Json;
using ToolQit;
using ToolQit.Containers;
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("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()
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();
}
}
}