Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Fetcharr/fetcharr
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnatamo committed Sep 9, 2024
2 parents 2087d6e + 078acd1 commit f623e83
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 36 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 4 additions & 4 deletions docs/docs/getting-started/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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`!

:::

Expand All @@ -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
```
</TabItem>
<TabItem value="docker-compose" label="Docker Compose">
Expand All @@ -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
Expand Down Expand Up @@ -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.

:::
:::
4 changes: 4 additions & 0 deletions src/API/src/Fetcharr.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="Serilog" />
<PackageReference Include="Serilog.AspNetCore" />
<PackageReference Include="Serilog.Sinks.Console" />
<PackageReference Include="Serilog.Sinks.File" />
<PackageReference Include="YamlDotNet" />

<PackageReference Include="GitVersion.MsBuild">
Expand Down
38 changes: 28 additions & 10 deletions src/API/src/Program.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -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<IAppDataSetup>();

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")
Expand Down
12 changes: 0 additions & 12 deletions src/API/src/appsettings.Development.json

This file was deleted.

8 changes: 0 additions & 8 deletions src/API/src/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,5 @@
"Url": "http://0.0.0.0:8080"
}
}
},
"Logging": {
"LogLevel": {
"Default": "Warning",
"Microsoft.AspNetCore": "None",
"Microsoft.Hosting": "Information",
"Fetcharr": "Information"
}
}
}
4 changes: 4 additions & 0 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="Serilog" Version="4.0.1" />
<PackageVersion Include="Serilog.AspNetCore" Version="8.0.2" />
<PackageVersion Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageVersion Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageVersion Include="YamlDotNet" Version="16.0.0" />
</ItemGroup>

Expand Down
10 changes: 10 additions & 0 deletions src/Models/src/Configuration/AppDataSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public interface IAppDataSetup
/// Gets the base location for configurations.
/// </summary>
string ConfigDirectory { get; }

/// <summary>
/// Gets the base location for runtime logs.
/// </summary>
string LogDirectory { get; }
}

/// <summary>
Expand All @@ -41,6 +46,11 @@ public class EnvironmentalAppDataSetup : IAppDataSetup
Environment.GetEnvironmentVariable("FETCHARR_CONFIG_DIR") ??
Path.Join(this.BaseDirectory, "config");

/// <inheritdoc />
public string LogDirectory =>
Environment.GetEnvironmentVariable("FETCHARR_LOG_DIR") ??
Path.Join(this.BaseDirectory, "logs");

public EnvironmentalAppDataSetup()
{
Directory.CreateDirectory(this.BaseDirectory);
Expand Down

0 comments on commit f623e83

Please sign in to comment.