From f723f637b983c453387f4c486bdc5df48386dc24 Mon Sep 17 00:00:00 2001 From: "Max T. Kristiansen" Date: Sun, 8 Sep 2024 18:38:25 +0200 Subject: [PATCH 1/5] ci: Push image on `main` build --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b024797..166c776 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,6 +34,6 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Build and release - run: ./build.cmd Release + run: ./build.cmd Release --push-image --include-integration-tests env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 0e7280ec229755e4c237b4e41198efe7fc7922d7 Mon Sep 17 00:00:00 2001 From: "Max T. Kristiansen" Date: Sun, 8 Sep 2024 18:54:11 +0200 Subject: [PATCH 2/5] fix(docs): add correct registry to Docker image tags --- docs/docs/getting-started/installation.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/docs/getting-started/installation.mdx b/docs/docs/getting-started/installation.mdx index 6b21bb6..6e3629c 100644 --- a/docs/docs/getting-started/installation.mdx +++ b/docs/docs/getting-started/installation.mdx @@ -12,7 +12,7 @@ Lists all the available options for installing/building Fetcharr. Some of these :::warning -**Fetcharr is still early in development.** If you would like to help test the bleeding edge, please use the image `fetcharr/fetcharr:develop`! +**Fetcharr is still early in development.** If you would like to help test the bleeding edge, please use the image `ghcr.io/fetcharr/fetcharr:develop`! ::: @@ -34,7 +34,7 @@ Be sure to replace `/path/to/appdata/config` with a valid host directory path. I -e TZ=Europe/Copenhagen \ -v /path/to/appdata/config:/config \ --restart unless-stopped \ - fetcharr/fetcharr:latest + ghcr.io/fetcharr/fetcharr:latest ``` @@ -43,7 +43,7 @@ Be sure to replace `/path/to/appdata/config` with a valid host directory path. I ```yaml title="compose.yaml" services: fetcharr: - image: fetcharr/fetcharr:latest + image: ghcr.io/fetcharr/fetcharr:latest container_name: fetcharr environment: - TZ=Europe/Copenhagen @@ -84,4 +84,4 @@ Afterwards, build the Docker image using [NUKE](https://nuke.build): You don't need to have NUKE installed for `build.cmd` to work. -::: \ No newline at end of file +::: From ed4215f09483359e3a5b90a9e7a5d8aaba5c57e6 Mon Sep 17 00:00:00 2001 From: "Max T. Kristiansen" Date: Mon, 9 Sep 2024 13:15:53 +0200 Subject: [PATCH 3/5] feat: install Serilog --- src/API/src/Fetcharr.API.csproj | 4 ++++ src/Directory.Packages.props | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/API/src/Fetcharr.API.csproj b/src/API/src/Fetcharr.API.csproj index de5e65a..62a9016 100644 --- a/src/API/src/Fetcharr.API.csproj +++ b/src/API/src/Fetcharr.API.csproj @@ -9,6 +9,10 @@ + + + + diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 150ce45..1a760a7 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -25,6 +25,10 @@ + + + + From 6734161d1d7c97c892eece224427c66b30daa3b5 Mon Sep 17 00:00:00 2001 From: "Max T. Kristiansen" Date: Mon, 9 Sep 2024 13:56:50 +0200 Subject: [PATCH 4/5] feat: add Serilog configuration --- src/API/src/Program.cs | 38 ++++++++++++++------ src/API/src/appsettings.json | 8 ----- src/Models/src/Configuration/AppDataSetup.cs | 10 ++++++ 3 files changed, 38 insertions(+), 18 deletions(-) diff --git a/src/API/src/Program.cs b/src/API/src/Program.cs index 496f28b..980e6dd 100644 --- a/src/API/src/Program.cs +++ b/src/API/src/Program.cs @@ -1,11 +1,11 @@ using Fetcharr.API.Extensions; -using Fetcharr.API.Services; using Fetcharr.Cache.Core.Extensions; using Fetcharr.Cache.Hybrid.Extensions; using Fetcharr.Cache.InMemory.Extensions; -using Fetcharr.Configuration.Extensions; -using Fetcharr.Models.Extensions; -using Fetcharr.Shared.Http.Extensions; +using Fetcharr.Models.Configuration; + +using Serilog; +using Serilog.Events; namespace Fetcharr.API { @@ -15,13 +15,31 @@ static async Task Main(string[] args) { WebApplicationBuilder builder = WebApplication.CreateBuilder(args); - builder.Services.AddLogging(opts => - opts.AddSimpleConsole(options => + builder.Host.UseSerilog((context, serviceProvider, configuration) => + { + IAppDataSetup appDataSetup = serviceProvider.GetRequiredService(); + + configuration.MinimumLevel.Warning(); + configuration.MinimumLevel.Override("Microsoft.AspNetCore", LogEventLevel.Error); + configuration.MinimumLevel.Override("Microsoft.Hosting", LogEventLevel.Information); + configuration.MinimumLevel.Override("Fetcharr", LogEventLevel.Information); + + if(context.HostingEnvironment.IsDevelopment()) + { + configuration.MinimumLevel.Information(); + configuration.MinimumLevel.Override("Fetcharr", LogEventLevel.Verbose); + configuration.MinimumLevel.Override("Fetcharr.Cache", LogEventLevel.Information); + } + + configuration.WriteTo.Console(); + + if(context.HostingEnvironment.IsProduction()) { - options.IncludeScopes = true; - options.SingleLine = true; - options.TimestampFormat = "HH:mm:ss "; - })); + configuration.WriteTo.File( + $"{appDataSetup.LogDirectory}/fetcharr.log", + rollingInterval: RollingInterval.Day); + } + }); builder.Services.AddCaching(opts => opts .UseHybrid("metadata", opts => opts.SQLite.DatabasePath = "metadata.sqlite") diff --git a/src/API/src/appsettings.json b/src/API/src/appsettings.json index 777226d..0a7578d 100644 --- a/src/API/src/appsettings.json +++ b/src/API/src/appsettings.json @@ -5,13 +5,5 @@ "Url": "http://0.0.0.0:8080" } } - }, - "Logging": { - "LogLevel": { - "Default": "Warning", - "Microsoft.AspNetCore": "None", - "Microsoft.Hosting": "Information", - "Fetcharr": "Information" - } } } \ No newline at end of file diff --git a/src/Models/src/Configuration/AppDataSetup.cs b/src/Models/src/Configuration/AppDataSetup.cs index eb07cbe..4b4a5f8 100644 --- a/src/Models/src/Configuration/AppDataSetup.cs +++ b/src/Models/src/Configuration/AppDataSetup.cs @@ -21,6 +21,11 @@ public interface IAppDataSetup /// Gets the base location for configurations. /// string ConfigDirectory { get; } + + /// + /// Gets the base location for runtime logs. + /// + string LogDirectory { get; } } /// @@ -41,6 +46,11 @@ public class EnvironmentalAppDataSetup : IAppDataSetup Environment.GetEnvironmentVariable("FETCHARR_CONFIG_DIR") ?? Path.Join(this.BaseDirectory, "config"); + /// + public string LogDirectory => + Environment.GetEnvironmentVariable("FETCHARR_LOG_DIR") ?? + Path.Join(this.BaseDirectory, "logs"); + public EnvironmentalAppDataSetup() { Directory.CreateDirectory(this.BaseDirectory); From 078acd17db5c7b98fec7745dbf8f05bb472d6ae7 Mon Sep 17 00:00:00 2001 From: "Max T. Kristiansen" Date: Mon, 9 Sep 2024 13:57:20 +0200 Subject: [PATCH 5/5] chore: remove redundant `appsettings.Development.json` file --- src/API/src/appsettings.Development.json | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 src/API/src/appsettings.Development.json diff --git a/src/API/src/appsettings.Development.json b/src/API/src/appsettings.Development.json deleted file mode 100644 index 85fb0cd..0000000 --- a/src/API/src/appsettings.Development.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "None", - "Microsoft.Hosting": "Information", - "Fetcharr.Cache": "Information", - "Fetcharr.API": "Trace", - "Fetcharr": "Trace" - } - } -} \ No newline at end of file