Skip to content

Commit 2c51031

Browse files
Merge pull request #95 from Stravaig-Projects/#88-refactor
88 Refactor in prep for different logging scenarios
2 parents 738b111 + c5efaea commit 2c51031

File tree

112 files changed

+645
-526
lines changed

Some content is hidden

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

112 files changed

+645
-526
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ on:
33
push:
44
branches:
55
- main
6+
- '#88-refactor'
67

78
paths-ignore:
89
- 'README.md'
@@ -38,9 +39,8 @@ jobs:
3839
name: Build, Test, and Release
3940
runs-on: ubuntu-latest
4041
env:
41-
STRAVAIG_SOLUTION: src/Stravaig.Extensions.Configuration.Diagnostics.sln
42-
STRAVAIG_TESTS: Stravaig.Extensions.Configuration.Diagnostics.Tests
43-
STRAVAIG_PROJECT: Stravaig.Extensions.Configuration.Diagnostics
42+
STRAVAIG_SOLUTION: src/Stravaig.Configuration.Diagnostics.sln
43+
STRAVAIG_TESTS: Stravaig.Configuration.Diagnostics.Tests
4444

4545
steps:
4646
- name: Check out code
@@ -56,7 +56,6 @@ jobs:
5656
run: |
5757
echo "GITHUB_SHA: $GITHUB_SHA"
5858
echo "Solution: $STRAVAIG_SOLUTION"
59-
echo "Project: $STRAVAIG_PROJECT"
6059
echo "Tests: $STRAVAIG_TESTS"
6160
echo "Package version: $STRAVAIG_PACKAGE_VERSION"
6261
echo "Version Suffix: $STRAVAIG_PACKAGE_VERSION_SUFFIX"
@@ -78,11 +77,11 @@ jobs:
7877

7978
- name: Package Preview Release
8079
if: ${{ env.STRAVAIG_IS_PREVIEW == 'true' }}
81-
run: dotnet pack ./src/$STRAVAIG_PROJECT/$STRAVAIG_PROJECT.csproj --configuration Release --output ./out --include-symbols --include-source /p:VersionPrefix="$STRAVAIG_PACKAGE_VERSION" --version-suffix "$STRAVAIG_PACKAGE_VERSION_SUFFIX" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
80+
run: dotnet pack $STRAVAIG_SOLUTION --configuration Release --output ./out --include-symbols --include-source /p:VersionPrefix="$STRAVAIG_PACKAGE_VERSION" --version-suffix "$STRAVAIG_PACKAGE_VERSION_SUFFIX" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
8281

8382
- name: Package Stable Release
8483
if: ${{ env.STRAVAIG_IS_STABLE == 'true' }}
85-
run: dotnet pack ./src/$STRAVAIG_PROJECT/$STRAVAIG_PROJECT.csproj --configuration Release --output ./out --include-symbols --include-source /p:VersionPrefix="$STRAVAIG_PACKAGE_VERSION" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
84+
run: dotnet pack $STRAVAIG_SOLUTION --configuration Release --output ./out --include-symbols --include-source /p:VersionPrefix="$STRAVAIG_PACKAGE_VERSION" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
8685

8786
- name: Push package to NuGet
8887
if: ${{ env.STRAVAIG_PUBLISH_TO_NUGET == 'true' }}

Build-LocalPackages.ps1

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[CmdletBinding()]
2+
param (
3+
[ValidateScript({Test-Path $_ -PathType Container})]
4+
[parameter(Mandatory=$false)]
5+
$NugetFileShare = "C:\dev\nuget"
6+
)
7+
8+
function Get-NextVersion($VersionFile)
9+
{
10+
# Work out the version number
11+
$nextVersion = Get-Content $VersionFile -ErrorAction Stop
12+
if ($null -eq $nextVersion)
13+
{
14+
Write-Error "The $VersionFile file is empty"
15+
Exit 1
16+
}
17+
if ($nextVersion.GetType().BaseType.Name -eq "Array")
18+
{
19+
$nextVersion = $nextVersion[0]
20+
Write-Warning "$VersionFile contains more than one line of text. Using the first line."
21+
}
22+
if ($nextVersion -notmatch "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$")
23+
{
24+
Write-Error "The contents of $VersionFile (`"$nextVersion`") not recognised as a valid version number."
25+
Exit 2
26+
}
27+
28+
return $nextVersion;
29+
}
30+
31+
function Get-PackageVersionSuffix()
32+
{
33+
$now = Get-Date
34+
$datePart = $now.ToString("yyMMdd.HHmm");
35+
return "lp.$datePart";
36+
}
37+
38+
$VersionFile = "$PSScriptRoot/version.txt";
39+
$STRAVAIG_SOLUTION = "$PSScriptRoot/src/Stravaig.Configuration.Diagnostics.sln"
40+
$STRAVAIG_PACKAGE_VERSION = Get-NextVersion -VersionFile $VersionFile;
41+
$STRAVAIG_PACKAGE_VERSION_SUFFIX = Get-PackageVersionSuffix;
42+
43+
Get-ChildItem ./out -Recurse | Remove-Item;
44+
45+
dotnet pack $STRAVAIG_SOLUTION --configuration Release --output ./out --include-symbols --include-source /p:VersionPrefix="$STRAVAIG_PACKAGE_VERSION" --version-suffix "$STRAVAIG_PACKAGE_VERSION_SUFFIX" -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
46+
47+
Get-ChildItem ./out/*.nupkg | ForEach-Object {
48+
$name = $_.FullName;
49+
Write-Output "Pushing $name";
50+
dotnet nuget push "$name" --source $NugetFileShare
51+
}

Example/Example.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.1" NoWarn="NU1605" />
1010
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.1" NoWarn="NU1605" />
1111
<PackageReference Include="Seq.Extensions.Logging" Version="6.0.0" />
12-
<PackageReference Include="Stravaig.Extensions.Configuration.Diagnostics" Version="0.5.0-preview.153" />
12+
<PackageReference Include="Stravaig.Configuration.Diagnostics.Logging" Version="0.6.0-lp.210213.1710" />
1313
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
1414
</ItemGroup>
1515

Example/Startup.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
using Microsoft.Extensions.Hosting;
66
using Microsoft.Extensions.Logging;
77
using Microsoft.OpenApi.Models;
8-
using Stravaig.Extensions.Configuration.Diagnostics;
8+
using Stravaig.Configuration.Diagnostics;
9+
using Stravaig.Configuration.Diagnostics.Extensions;
10+
using Stravaig.Configuration.Diagnostics.Logging;
911

1012
namespace Example
1113
{

Set-Version.ps1

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,34 @@ function ConvertTo-Boolean([string]$Value, [bool]$EmptyDefault)
1717
throw "Don't know how to convert `"$Value`" into a Boolean."
1818
}
1919

20+
function Get-NextVersion($VersionFile)
21+
{
22+
# Work out the version number
23+
$nextVersion = Get-Content $VersionFile -ErrorAction Stop
24+
if ($null -eq $nextVersion)
25+
{
26+
Write-Error "The $VersionFile file is empty"
27+
Exit 1
28+
}
29+
if ($nextVersion.GetType().BaseType.Name -eq "Array")
30+
{
31+
$nextVersion = $nextVersion[0]
32+
Write-Warning "$VersionFile contains more than one line of text. Using the first line."
33+
}
34+
if ($nextVersion -notmatch "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$")
35+
{
36+
Write-Error "The contents of $VersionFile (`"$nextVersion`") not recognised as a valid version number."
37+
Exit 2
38+
}
39+
40+
return $nextVersion;
41+
}
42+
2043
[bool]$IsPreview = ConvertTo-Boolean -Value $IsPreview -EmptyDefault $true;
2144
[bool]$IsPublicRelease = ConvertTo-Boolean -Value $IsPublicRelease -EmptyDefault $false;
2245

2346
$VersionFile = "$PSScriptRoot/version.txt";
24-
25-
# Work out the version number
26-
$nextVersion = Get-Content $VersionFile -ErrorAction Stop
27-
if ($null -eq $nextVersion)
28-
{
29-
Write-Error "The $VersionFile file is empty"
30-
Exit 1
31-
}
32-
if ($nextVersion.GetType().BaseType.Name -eq "Array")
33-
{
34-
$nextVersion = $nextVersion[0]
35-
Write-Warning "$VersionFile contains more than one line of text. Using the first line."
36-
}
37-
if ($nextVersion -notmatch "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$")
38-
{
39-
Write-Error "The contents of $VersionFile (`"$nextVersion`") not recognised as a valid version number."
40-
Exit 2
41-
}
47+
$nextVersion = Get-NextVersion -VersionFile $VersionFile;
4248
"STRAVAIG_PACKAGE_VERSION=$nextVersion" | Out-File -FilePath $Env:GITHUB_ENV -Encoding UTF8 -Append
4349
$fullVersion = $nextVersion;
4450

docs/intro/installing-the-package.rst

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,35 @@
33
Installing
44
==========
55

6-
The latest package is available on `NuGet`_.
6+
This library is made up of several packages. The core functionality is contained in a package called ``Stravaig.Configuration.Diagnostics.Core``, the Logger extensions are in ``Stravaig.Configuration.Diagnostics.Logging``.
77

8-
.. _NuGet: https://www.nuget.org/packages/Stravaig.Extensions.Configuration.Diagnostics
8+
All the packages that contain the final output form (e.g. Logging) also reference the Core package, so there is no need to include that separately. It also means that you only have one package
99

10-
+------------------------------------------------------------------------------------------------------------------------------------------+---------------------------+
11-
| Badge | Notes |
12-
+------------------------------------------------------------------------------------------------------------------------------------------+---------------------------+
13-
| .. image:: https://img.shields.io/nuget/v/Stravaig.Extensions.Configuration.Diagnostics?color=004880&label=nuget%20stable&logo=nuget | Latest stable |
14-
+------------------------------------------------------------------------------------------------------------------------------------------+---------------------------+
15-
| .. image:: https://img.shields.io/nuget/vpre/Stravaig.Extensions.Configuration.Diagnostics?color=ffffff&label=nuget%20latest&logo=nuget) | Latest, including preview |
16-
+------------------------------------------------------------------------------------------------------------------------------------------+---------------------------+
10+
The latest packages are available on `NuGet`_.
1711

18-
Latest, including preview
12+
.. _NuGet: https://www.nuget.org/packages?q=Stravaig.Configuration.Diagnostics
13+
14+
.. list-table:: packages
15+
:header-rows: 1
16+
17+
* - Package
18+
- Stable Version
19+
- Preview Version
20+
* - Stravaig.Configuration.Diagnostics.Core
21+
- .. image:: https://img.shields.io/nuget/v/Stravaig.Configuration.Diagnostics.Core?color=004880&label=nuget%20stable&logo=nuget
22+
- .. image:: https://img.shields.io/nuget/vpre/Stravaig.Configuration.Diagnostics.Core?color=ffffff&label=nuget%20latest&logo=nuget)
23+
* - Stravaig.Configuration.Diagnostics.Logging
24+
- .. image:: https://img.shields.io/nuget/v/Stravaig.Configuration.Diagnostics.Logging?color=004880&label=nuget%20stable&logo=nuget
25+
- .. image:: https://img.shields.io/nuget/vpre/Stravaig.Configuration.Diagnostics.Logging?color=ffffff&label=nuget%20latest&logo=nuget)
1926

2027
Installing from a PowerShell prompt
2128
-----------------------------------
2229

23-
You can install the package into your project from a PowerShell prompt. Navigate to the folder your project file is in and type: ::
30+
You can install the package into your project from a PowerShell prompt. Navigate to the folder your project file is in and type:
2431

2532
::
2633

27-
Install-Package Stravaig.Extensions.Configuration.Diagnostics
34+
Install-Package Stravaig.Configuration.Diagnostics.Logging
2835

2936
Installing using the .NET CLI
3037
-----------------------------
@@ -33,5 +40,5 @@ You can install the package into your project with the .NET CLI command. Navigat
3340

3441
::
3542

36-
dotnet add package Stravaig.Extensions.Configuration.Diagnostics
43+
dotnet add package Stravaig.Configuration.Diagnostics.Logging
3744

release-notes/wip-release-notes.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44

55
Date: ???
66

7+
**THIS RELEASE CONTAINS BREAKING CHANGES**
8+
9+
710
### Bugs
811

912
### Features
1013

1114
### Miscellaneous
1215

13-
- #84 Update List-Contributors script
16+
* #84 Update List-Contributors script
17+
* #88 Refactor internal structure to support different logging frameworks by creating a new "Core" package, with the specifics for various logging frameworks ultimately residing in various satellite packages.
1418

1519
### Dependabot
1620

src/.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
root=true
3+
24
[*]
35
charset=utf-8
46
end_of_line=crlf

src/.idea/.idea.Stravaig.Configuration.Diagnostics/.idea/.gitignore

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/.idea/.idea.Stravaig.Configuration.Diagnostics/.idea/.name

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)