diff --git a/ToolQit b/ToolQit index d2d3f1b..49ec417 160000 --- a/ToolQit +++ b/ToolQit @@ -1 +1 @@ -Subproject commit d2d3f1b864d8eb424063735d721c1b310c9ab0df +Subproject commit 49ec417fbaa33042d32a392dd2c432c386a7c5bf diff --git a/WebSharpRSS/Bootstrapper.cs b/WebSharpRSS/Bootstrapper.cs new file mode 100644 index 0000000..96fb437 --- /dev/null +++ b/WebSharpRSS/Bootstrapper.cs @@ -0,0 +1,29 @@ +using System; +using System.IO; +using Serilog; +using Serilog.Formatting.Json; +using ToolQit; +using ToolQit.Containers; + +namespace WebSharpRSS +{ + public static class Bootstrapper + { + public static void SetContainerDefaults(this DataContainer dataCon) + { + dataCon.Set("FaviconResolveUrl", "https://icons.duckduckgo.com/ip3/{0}.ico"); + dataCon.Set("LogPath", Path.Combine(Environment.CurrentDirectory, "logs", "log_.json")); + } + + private static LoggerConfiguration? _configuration; + public static void SetupLogging() + { + if (_configuration != null) return; + _configuration = new LoggerConfiguration() + .WriteTo.Console() + .WriteTo.File(new JsonFormatter(), Caretaker.Settings.GetString("LogPath"), rollingInterval: RollingInterval.Day) + .MinimumLevel.Verbose(); + Log.Logger = _configuration.CreateLogger(); + } + } +} \ No newline at end of file diff --git a/WebSharpRSS/Pages/Index.razor b/WebSharpRSS/Pages/Index.razor index a8c4e71..2f95661 100644 --- a/WebSharpRSS/Pages/Index.razor +++ b/WebSharpRSS/Pages/Index.razor @@ -1,24 +1,7 @@ @page "/" @inject RssService _rssService -@* - @for (int i = 0; i < 10; i++) - { - - - - Old Paint - Old paint found on a stone house door. - This photo was taken in a small village in Istra Croatia. - - - Share - Learn More - - - } - -*@ + @code { diff --git a/WebSharpRSS/Program.cs b/WebSharpRSS/Program.cs index b8e327b..6250cfe 100644 --- a/WebSharpRSS/Program.cs +++ b/WebSharpRSS/Program.cs @@ -3,7 +3,13 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using MudBlazor; using MudBlazor.Services; +using Serilog; using SharpRss; +using ToolQit; +using WebSharpRSS; + +Caretaker.Settings.SetContainerDefaults(); +Bootstrapper.SetupLogging(); var builder = WebApplication.CreateBuilder(args); builder.Services.AddRazorPages(); @@ -11,6 +17,7 @@ builder.Services.AddServerSideBlazor(); builder.Services.AddTransient(); builder.Services.AddMudServices(config => { + Log.Debug("Configuring MudServices"); config.SnackbarConfiguration.PositionClass = Defaults.Classes.Position.BottomRight; config.SnackbarConfiguration.PreventDuplicates = true; config.SnackbarConfiguration.ShowCloseIcon = true; diff --git a/WebSharpRSS/Settings.json b/WebSharpRSS/Settings.json new file mode 100644 index 0000000..11c0578 --- /dev/null +++ b/WebSharpRSS/Settings.json @@ -0,0 +1,4 @@ +{ + "FaviconResolveUrl": "https://icons.duckduckgo.com/ip3/{0}.ico", + "LogPath": "/home/max/GitHub/SharpRSS/WebSharpRSS/logs/log_.json" +} \ No newline at end of file diff --git a/WebSharpRSS/defaults.json b/WebSharpRSS/defaults.json new file mode 100644 index 0000000..11c0578 --- /dev/null +++ b/WebSharpRSS/defaults.json @@ -0,0 +1,4 @@ +{ + "FaviconResolveUrl": "https://icons.duckduckgo.com/ip3/{0}.ico", + "LogPath": "/home/max/GitHub/SharpRSS/WebSharpRSS/logs/log_.json" +} \ No newline at end of file