Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions .github/template-sync.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
name: Build & Tests
uses: dailydevops/pipelines/.github/workflows/cicd-dotnet.yml@0.9.3
with:
disablePublish: true
enableSonarQube: true
dotnet-logging: ${{ inputs.dotnet-logging }}
dotnet-version: |
8.x
solution: ###SOLUTION###
solution: ./Logging.XUnit.sln
secrets: inherit
24 changes: 0 additions & 24 deletions .github/workflows/template-sync.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "eng"]
path = eng
url = https://github.com/dailydevops/dotnet-engineering.git
update = merge
update = rebase
7 changes: 7 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,11 @@
<Import Project="$(DirEngineeringSettings)src.build.props" Condition=" '$(IsTestableProject)' != 'true' " />
<Import Project="$(DirEngineeringSettings)tests.build.props" Condition=" '$(IsTestableProject)' == 'true' " />

<PropertyGroup>
<ProjectTargetFrameworks>net6.0;net7.0;net8.0</ProjectTargetFrameworks>
<TestTargetFrameworks>net6.0;net7.0;net8.0</TestTargetFrameworks>

<DisableBannedApiForUTC>true</DisableBannedApiForUTC>
</PropertyGroup>

</Project>
27 changes: 20 additions & 7 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
<Project>

<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
</PropertyGroup>

<ItemGroup>
<GlobalPackageReference Include="CSharpier.MSBuild" Version="0.26.3" />
<GlobalPackageReference Include="CSharpier.MSBuild" Version="0.28.2" />
<GlobalPackageReference Include="GitVersion.MsBuild" Version="5.12.0" />
<GlobalPackageReference Include="Microsoft.CodeAnalysis.BannedApiAnalyzers" Version="3.3.4" />
<GlobalPackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0" />
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<GlobalPackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.8.14" />
<GlobalPackageReference Include="SonarAnalyzer.CSharp" Version="9.16.0.82469" Condition=" '$(BuildingInsideVisualStudio)' == 'true' " />
<GlobalPackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.10.48" />
<GlobalPackageReference Include="SonarAnalyzer.CSharp" Version="9.25.0.90414" Condition=" '$(BuildingInsideVisualStudio)' == 'true' " />
</ItemGroup>

</Project>
<ItemGroup>
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.2" />
<PackageVersion Include="Microsoft.Bcl.TimeProvider" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.Logging.Configuration" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.TimeProvider.Testing" Version="8.5.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageVersion Include="NetEvolve.Arguments" Version="1.2.0" />
<PackageVersion Include="NetEvolve.Logging.Abstractions" Version="1.1.0" />
<PackageVersion Include="Verify.Xunit" Version="24.2.0" />
<PackageVersion Include="xunit" Version="2.8.0" />
<PackageVersion Include="xunit.extensibility.core" Version="2.8.0" />
<PackageVersion Include="xunit.extensibility.execution" Version="2.8.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.0" />
</ItemGroup>
</Project>
81 changes: 81 additions & 0 deletions Logging.XUnit.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D9954CB8-DB50-4331-A461-36A4AD4DA06E}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.filenesting.json = .filenesting.json
.gitattributes = .gitattributes
.gitignore = .gitignore
.gitmodules = .gitmodules
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
Directory.Packages.props = Directory.Packages.props
Directory.Solution.props = Directory.Solution.props
GitVersion.yml = GitVersion.yml
LICENSE = LICENSE
new-project.ps1 = new-project.ps1
nuget.config = nuget.config
README.md = README.md
update-solution.ps1 = update-solution.ps1
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{EFE8181B-6FAB-4E04-BD9B-557C1286B858}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{BD750CCE-0318-424D-89B4-9C66EF329E96}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetEvolve.Logging.XUnit", "src\NetEvolve.Logging.XUnit\NetEvolve.Logging.XUnit.csproj", "{3F3CD6EC-4636-4B58-8400-09AC2B9BAFDF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetEvolve.Logging.XUnit.Tests.Unit", "tests\NetEvolve.Logging.XUnit.Tests.Unit\NetEvolve.Logging.XUnit.Tests.Unit.csproj", "{EAAD2C22-48F4-4E37-9A46-0350C6B84388}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetEvolve.Logging.XUnit.Tests.Integration", "tests\NetEvolve.Logging.XUnit.Tests.Integration\NetEvolve.Logging.XUnit.Tests.Integration.csproj", "{F2B38EDD-63F9-4027-9EA6-D1E0C6387C12}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3F3CD6EC-4636-4B58-8400-09AC2B9BAFDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3F3CD6EC-4636-4B58-8400-09AC2B9BAFDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F3CD6EC-4636-4B58-8400-09AC2B9BAFDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F3CD6EC-4636-4B58-8400-09AC2B9BAFDF}.Release|Any CPU.Build.0 = Release|Any CPU
{EAAD2C22-48F4-4E37-9A46-0350C6B84388}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EAAD2C22-48F4-4E37-9A46-0350C6B84388}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EAAD2C22-48F4-4E37-9A46-0350C6B84388}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EAAD2C22-48F4-4E37-9A46-0350C6B84388}.Release|Any CPU.Build.0 = Release|Any CPU
{F2B38EDD-63F9-4027-9EA6-D1E0C6387C12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2B38EDD-63F9-4027-9EA6-D1E0C6387C12}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2B38EDD-63F9-4027-9EA6-D1E0C6387C12}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2B38EDD-63F9-4027-9EA6-D1E0C6387C12}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{3F3CD6EC-4636-4B58-8400-09AC2B9BAFDF} = {EFE8181B-6FAB-4E04-BD9B-557C1286B858}
{EAAD2C22-48F4-4E37-9A46-0350C6B84388} = {BD750CCE-0318-424D-89B4-9C66EF329E96}
{F2B38EDD-63F9-4027-9EA6-D1E0C6387C12} = {BD750CCE-0318-424D-89B4-9C66EF329E96}
EndGlobalSection
EndGlobal
CPU.Build.0 = Release|Any CPU
{3F3CD6EC-4636-4B58-8400-09AC2B9BAFDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3F3CD6EC-4636-4B58-8400-09AC2B9BAFDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3F3CD6EC-4636-4B58-8400-09AC2B9BAFDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3F3CD6EC-4636-4B58-8400-09AC2B9BAFDF}.Release|Any CPU.Build.0 = Release|Any CPU
{EAAD2C22-48F4-4E37-9A46-0350C6B84388}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EAAD2C22-48F4-4E37-9A46-0350C6B84388}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EAAD2C22-48F4-4E37-9A46-0350C6B84388}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EAAD2C22-48F4-4E37-9A46-0350C6B84388}.Release|Any CPU.Build.0 = Release|Any CPU
{F2B38EDD-63F9-4027-9EA6-D1E0C6387C12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F2B38EDD-63F9-4027-9EA6-D1E0C6387C12}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F2B38EDD-63F9-4027-9EA6-D1E0C6387C12}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F2B38EDD-63F9-4027-9EA6-D1E0C6387C12}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{3F3CD6EC-4636-4B58-8400-09AC2B9BAFDF} = {EFE8181B-6FAB-4E04-BD9B-557C1286B858}
{EAAD2C22-48F4-4E37-9A46-0350C6B84388} = {BD750CCE-0318-424D-89B4-9C66EF329E96}
{F2B38EDD-63F9-4027-9EA6-D1E0C6387C12} = {BD750CCE-0318-424D-89B4-9C66EF329E96}
EndGlobalSection
EndGlobal
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# template-dotnet
.NET template for repositories
# NetEvolve.Logging.XUnit

This library provides a logging implementation for [XUnit](https://xunit.net/). When using this library, you have the ability to access the logs generated while executing your tests. This can be useful for debugging purposes.
2 changes: 1 addition & 1 deletion new-project.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ New-Project `
-DisableTests $DisableTests `
-DisableUnitTests $DisableUnitTests `
-DisableIntegrationTests $DisableIntegrationTests `
-SolutionFile "###SOLUTION###" `
-SolutionFile "./Logging.XUnit.sln" `
-OutputDirectory (Get-Location) `
-EnableProjectGrouping $EnableProjectGrouping `
-DisableArchitectureTests $DisableArchitectureTests
19 changes: 0 additions & 19 deletions new-solution.ps1

This file was deleted.

32 changes: 32 additions & 0 deletions src/NetEvolve.Logging.XUnit/IXUnitLoggerOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace NetEvolve.Logging.XUnit;

/// <summary>
/// Accessor for the options of the <see cref="XUnitLogger"/>.
/// </summary>
public interface IXUnitLoggerOptions
{
/// <summary>
/// Disables the output of the additional information in the log output. Default <see langword="false"/>.
/// </summary>
bool DisableAdditionalInformation { get; }

/// <summary>
/// Disable the log level in the log output. Default <see langword="false"/>.
/// </summary>
bool DisableLogLevel { get; }

/// <summary>
/// Disable the scopes in the log output. Default <see langword="false"/>.
/// </summary>
bool DisableScopes { get; }

/// <summary>
/// Disables the timestamps in the log output. Default <see langword="false"/>.
/// </summary>
bool DisableTimestamp { get; }

/// <summary>
/// The format of the timestamp in the log output. Default <c>"o"</c>.
/// </summary>
string TimestampFormat { get; }
}
27 changes: 27 additions & 0 deletions src/NetEvolve.Logging.XUnit/NetEvolve.Logging.XUnit.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>$(ProjectTargetFrameworks)</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup Label="Package settings">
<Title>$(MSBuildProjectName)</Title>
<Description>Extensions for `ILogger` implementations to log messages to xUnit test output.</Description>
<RepositoryUrl>https://github.com/dailydevops/logging.xunit.git</RepositoryUrl>
<PackageProjectUrl>https://github.com/dailydevops/logging.xunit.git</PackageProjectUrl>
<PackageTags>logging;provider;xunit</PackageTags>
<CopyrightYearStart>2024</CopyrightYearStart>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Bcl.TimeProvider" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" />
<PackageReference Include="NetEvolve.Arguments" />
<PackageReference Include="NetEvolve.Logging.Abstractions" />
<PackageReference Include="xunit.extensibility.core" />
</ItemGroup>

</Project>
67 changes: 67 additions & 0 deletions src/NetEvolve.Logging.XUnit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# NetEvolve.Logging.XUnit

This library provides a logging implementation for [XUnit](https://xunit.net/). When using this library, you have the ability to access the logs generated while executing your tests. This can be useful for debugging purposes.

## Installation
```bash
dotnet add package NetEvolve.Logging.XUnit
```

## Usage

You can choose to use the `XUnitLogger` class directly or use the `AddXUnit` extension method on the `ILoggingBuilder` instance.

### Direct usage

```csharp
using Microsoft.Extensions.Logging;
using NetEvolve.Logging.XUnit;
using XUnit;

public class ExampleTests
{
private readonly ITestOutputHelper _output;

public ExampleTests(ITestOutputHelper output)
{
_output = output;
}

[Fact]
public void Test()
{
var logger = XUnitLogger.CreateLogger<ExampleTests>(_output);

// Arrange
...
// Act
...
// Assert
...

Assert.NotEmpty(logger.LoggedMessages);
}
}
```

### Usage with `ILoggingBuilder.AddXUnit`

Or you can use the `AddXUnit` extension method on the `ILoggingBuilder` instance.

```csharp
using Microsoft.Extensions.Logging;
using NetEvolve.Logging.XUnit;

var services = new ServiceCollection();
services.AddLogging(builder =>
{
// Add the XUnit logging implementation
builder.AddXUnit();

// Or alternatively with options
builder.AddXUnit(options =>
{
options.TimestampFormat = "HH:mm:ss.fff";
});
});
```
Loading