mirror of
https://github.com/hmaxnl/SharpRSS.git
synced 2024-09-20 01:54:20 +02:00
49 lines
1.7 KiB
C#
49 lines
1.7 KiB
C#
using System;
|
|
using System.IO;
|
|
using Serilog;
|
|
using Serilog.Formatting.Json;
|
|
using SharpRss;
|
|
using ToolQit;
|
|
using ToolQit.Containers;
|
|
|
|
namespace WebSharpRSS
|
|
{
|
|
public static class Bootstrapper
|
|
{
|
|
private static bool _defaultsSet;
|
|
private static bool _bootstrapped;
|
|
|
|
public static void Bootstrap()
|
|
{
|
|
if (_bootstrapped) return;
|
|
Caretaker.Settings.SetAppDefaultSettings();
|
|
SetupLogging();
|
|
Log.Information("Starting SharpRSS...");
|
|
SyndicationManager.Init();
|
|
_bootstrapped = true;
|
|
}
|
|
|
|
private 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);
|
|
_defaultsSet = true;
|
|
}
|
|
|
|
private static LoggerConfiguration? _configuration;
|
|
private static void SetupLogging()
|
|
{
|
|
if (!_defaultsSet) throw new Exception("Bootstrapper defaults are not initialized!");
|
|
if (_configuration != null) return;
|
|
_configuration = new LoggerConfiguration()
|
|
.WriteTo.Console()
|
|
.WriteTo.File(new JsonFormatter(), Caretaker.Settings["Paths"].GetString("LogPath"),
|
|
rollingInterval: RollingInterval.Day);
|
|
/*.MinimumLevel.Verbose(); // ONLY FOR DEBUGGING!!!*/
|
|
|
|
Log.Logger = _configuration.CreateLogger();
|
|
}
|
|
}
|
|
} |