Skip to content

Commit 619511e

Browse files
authored
Release v8 features (#101)
* Concept of v8 * Updated Sample to .NET 6 * Fix dup of label at formatter lvl * Enabled ImplicitUsings * Updated Web sample * Fixed bug at props copying * Fixed tests * Added test for global label and level renaming * Deleted obsolete test file * Added link to Discussions page to issue template * Bumped SDK to .NET 6 in CI pipeline * Deleted garbage file * Bumped .NET SDK to 6 in CodeQL pipeline * Bumped build project * Fixed RegExps in tests
1 parent e545a8b commit 619511e

File tree

87 files changed

+2135
-2163
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+2135
-2163
lines changed

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
blank_issues_enabled: true
1+
blank_issues_enabled: true
2+
contact_links:
3+
- name: Discussions
4+
url: https://github.com/serilog-contrib/serilog-sinks-grafana-loki/discussions
5+
about: The place for questions, support and feature requests

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Setup .NET Core
3131
uses: actions/setup-dotnet@v2
3232
with:
33-
dotnet-version: 5.0.x
33+
dotnet-version: 6.0.x
3434

3535
- run: dotnet --info
3636

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
- name: Setup dotnet
4242
uses: actions/setup-dotnet@v2
4343
with:
44-
dotnet-version: '5.0.x'
44+
dotnet-version: '6.0.x'
4545

4646
- run: dotnet --info
4747

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<Authors>Mykhailo Shevchuk, Contributors</Authors>
44
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)StyleCop.ruleset</CodeAnalysisRuleSet>
5-
<LangVersion>9</LangVersion>
5+
<LangVersion>10</LangVersion>
66
<MinVerTagPrefix>v</MinVerTagPrefix>
77
</PropertyGroup>
88

build/Build.csproj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net5.0</TargetFramework>
5+
<TargetFramework>net6.0</TargetFramework>
6+
<Nullable>enable</Nullable>
7+
<ImplicitUsings>enable</ImplicitUsings>
68
</PropertyGroup>
79

810
<ItemGroup>
9-
<PackageReference Include="Bullseye" Version="3.7.0" />
10-
<PackageReference Include="SimpleExec" Version="7.0.0" />
11+
<PackageReference Include="Bullseye" Version="4.0.0" />
12+
<PackageReference Include="SimpleExec" Version="10.0.0" />
1113
</ItemGroup>
1214

13-
</Project>
15+
</Project>

build/Program.cs

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,42 @@
1-
using System.IO;
2-
using static Bullseye.Targets;
1+
using static Bullseye.Targets;
32
using static SimpleExec.Command;
43

5-
namespace Build
4+
namespace Build;
5+
6+
internal static class Program
67
{
7-
internal static class Program
8+
private const string PackOutput = "./artifacts";
9+
private const string Solution = "Serilog.Sinks.Grafana.Loki.sln";
10+
11+
internal static async Task Main(string[] args)
812
{
9-
private const string PackOutput = "./artifacts";
10-
private const string Solution = "Serilog.Sinks.Grafana.Loki.sln";
13+
Target(Targets.CleanBuildOutput, () => { Run("dotnet", $"clean {Solution} -c Release -v m --nologo"); });
1114

12-
internal static void Main(string[] args)
15+
Target(Targets.Build, DependsOn(Targets.CleanBuildOutput), () =>
1316
{
14-
Target(Targets.CleanBuildOutput, () => { Run("dotnet", $"clean {Solution} -c Release -v m --nologo"); });
17+
Run("dotnet", $"build {Solution} -c Release --nologo");
18+
});
1519

16-
Target(Targets.Build, DependsOn(Targets.CleanBuildOutput), () =>
17-
{
18-
Run("dotnet", $"build {Solution} -c Release --nologo");
19-
});
20-
21-
Target(Targets.Test, DependsOn(Targets.Build), () =>
22-
{
23-
Run("dotnet", $"test {Solution} -c Release --no-build --nologo");
24-
});
20+
Target(Targets.Test, DependsOn(Targets.Build), () =>
21+
{
22+
Run("dotnet", $"test {Solution} -c Release --no-build --nologo");
23+
});
2524

26-
Target(Targets.CleanPackOutput, () =>
25+
Target(Targets.CleanPackOutput, () =>
26+
{
27+
if (Directory.Exists(PackOutput))
2728
{
28-
if (Directory.Exists(PackOutput))
29-
{
30-
Directory.Delete(PackOutput, true);
31-
}
32-
});
29+
Directory.Delete(PackOutput, true);
30+
}
31+
});
3332

34-
Target(Targets.Pack, DependsOn(Targets.CleanPackOutput), () =>
35-
{
36-
Run("dotnet", $"pack ./src/Serilog.Sinks.Grafana.Loki/Serilog.Sinks.Grafana.Loki.csproj -c Release -o {Directory.CreateDirectory(PackOutput).FullName} --no-build --nologo");
37-
});
33+
Target(Targets.Pack, DependsOn(Targets.CleanPackOutput), () =>
34+
{
35+
Run("dotnet", $"pack ./src/Serilog.Sinks.Grafana.Loki/Serilog.Sinks.Grafana.Loki.csproj -c Release -o {Directory.CreateDirectory(PackOutput).FullName} --no-build --nologo");
36+
});
3837

39-
Target("default", DependsOn(Targets.Test, Targets.Pack));
38+
Target("default", DependsOn(Targets.Test, Targets.Pack));
4039

41-
RunTargetsAndExit(args, ex => ex is SimpleExec.NonZeroExitCodeException);
42-
}
40+
await RunTargetsAndExitAsync(args, ex => ex is SimpleExec.ExitCodeException);
4341
}
4442
}

build/Targets.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
namespace Build
1+
namespace Build;
2+
3+
internal static class Targets
24
{
3-
internal static class Targets
4-
{
5-
internal const string Build = "build";
6-
internal const string CleanBuildOutput = "clean-build-output";
7-
internal const string CleanPackOutput = "clean-pack-output";
8-
internal const string Pack = "pack";
9-
internal const string Test = "test";
10-
}
5+
internal const string Build = "build";
6+
internal const string CleanBuildOutput = "clean-build-output";
7+
internal const string CleanPackOutput = "clean-pack-output";
8+
internal const string Pack = "pack";
9+
internal const string Test = "test";
1110
}
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
namespace Serilog.Sinks.Grafana.Loki.Sample
2-
{
3-
internal record Person(string Name, int Age);
4-
}
1+
namespace Serilog.Sinks.Grafana.Loki.Sample;
2+
3+
internal record Person(string Name, int Age);
Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,42 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using Serilog.Debugging;
1+
using Serilog.Debugging;
42

5-
namespace Serilog.Sinks.Grafana.Loki.Sample
3+
namespace Serilog.Sinks.Grafana.Loki.Sample;
4+
5+
public static class Program
66
{
7-
public static class Program
7+
private const string OutputTemplate =
8+
"{Timestamp:dd-MM-yyyy HH:mm:ss} [{Level:u3}] [{ThreadId}] {Message}{NewLine}{Exception}";
9+
10+
public static void Main(string[] args)
811
{
9-
private const string OutputTemplate =
10-
"{Timestamp:dd-MM-yyyy HH:mm:ss} [{Level:u3}] [{ThreadId}] {Message}{NewLine}{Exception}";
12+
SelfLog.Enable(Console.Error);
13+
14+
Log.Logger = new LoggerConfiguration()
15+
.MinimumLevel.Debug()
16+
.Enrich.WithThreadId()
17+
.Enrich.WithProperty("meaning_of_life", 42)
18+
.WriteTo.Console(outputTemplate: OutputTemplate)
19+
.WriteTo.GrafanaLoki(
20+
"http://localhost:3100",
21+
new List<LokiLabel> { new() { Key = "app", Value = "console" } },
22+
credentials: null)
23+
.CreateLogger();
24+
25+
Log.Debug("This is a debug message");
26+
27+
var person = new Person("Billy", 42);
1128

12-
public static void Main(string[] args)
29+
Log.Information("Person of the day: {@Person}", person);
30+
31+
try
32+
{
33+
throw new AccessViolationException("Access denied");
34+
}
35+
catch (Exception ex)
1336
{
14-
SelfLog.Enable(Console.Error);
15-
16-
Log.Logger = new LoggerConfiguration()
17-
.MinimumLevel.Debug()
18-
.Enrich.WithThreadId()
19-
.Enrich.WithProperty("meaning_of_life", "42")
20-
.WriteTo.Console(outputTemplate: OutputTemplate)
21-
.WriteTo.GrafanaLoki(
22-
"http://localhost:3100",
23-
new List<LokiLabel> { new() { Key = "app", Value = "console" } },
24-
credentials: null,
25-
outputTemplate: OutputTemplate,
26-
createLevelLabel: true,
27-
useInternalTimestamp: false)
28-
.CreateLogger();
29-
30-
Log.Debug("This is a debug message");
31-
32-
var person = new Person("Billy", 42);
33-
34-
Log.Information("Person of the day: {@Person}", person);
35-
36-
try
37-
{
38-
throw new AccessViolationException("Access denied");
39-
}
40-
catch (Exception ex)
41-
{
42-
Log.Error(ex, "An error occured");
43-
}
44-
45-
Log.CloseAndFlush();
37+
Log.Error(ex, "An error occured");
4638
}
39+
40+
Log.CloseAndFlush();
4741
}
4842
}

sample/Serilog.Sinks.Grafana.Loki.Sample/Serilog.Sinks.Grafana.Loki.Sample.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net5.0</TargetFramework>
5+
<TargetFramework>net6.0</TargetFramework>
66
<Nullable>enable</Nullable>
7+
<ImplicitUsings>enable</ImplicitUsings>
78
</PropertyGroup>
89

910
<ItemGroup>
@@ -16,4 +17,4 @@
1617
<ProjectReference Include="..\..\src\Serilog.Sinks.Grafana.Loki\Serilog.Sinks.Grafana.Loki.csproj" />
1718
</ItemGroup>
1819

19-
</Project>
20+
</Project>

0 commit comments

Comments
 (0)