Skip to content

Commit e4ab4ae

Browse files
committed
Merge pull request #12 from merbla/core-dotnet
Serilog 2.0 Support
2 parents 2cef112 + 3629606 commit e4ab4ae

39 files changed

+9116
-770
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
## Ignore Visual Studio temporary files, build results, and
22
## files generated by popular Visual Studio add-ons.
33

4+
.vs/
5+
46
# User-specific files
57
*.suo
68
*.user

.nuget/packages.config

Lines changed: 0 additions & 4 deletions
This file was deleted.

Build.ps1

Lines changed: 87 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,109 @@
1-
param(
2-
[String] $majorMinor = "0.0", # 2.0
3-
[String] $patch = "0", # $env:APPVEYOR_BUILD_VERSION
4-
[String] $customLogger = "", # C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll
5-
[Switch] $notouch
6-
)
7-
8-
function Set-AssemblyVersions($informational, $assembly)
1+
$root = $(Get-Item $($MyInvocation.MyCommand.Path)).DirectoryName
2+
3+
function Install-Dnvm
94
{
10-
(Get-Content assets/CommonAssemblyInfo.cs) |
11-
ForEach-Object { $_ -replace """1.0.0.0""", """$assembly""" } |
12-
ForEach-Object { $_ -replace """1.0.0""", """$informational""" } |
13-
ForEach-Object { $_ -replace """1.1.1.1""", """$($informational).0""" } |
14-
Set-Content assets/CommonAssemblyInfo.cs
5+
& where.exe dnvm 2>&1 | Out-Null
6+
if(($LASTEXITCODE -ne 0) -Or ((Test-Path Env:\APPVEYOR) -eq $true))
7+
{
8+
Write-Host "DNVM not found"
9+
&{$Branch='dev';iex ((New-Object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}
10+
11+
# Normally this happens automatically during install but AppVeyor has
12+
# an issue where you may need to manually re-run setup from within this process.
13+
if($env:DNX_HOME -eq $NULL)
14+
{
15+
Write-Host "Initial DNVM environment setup failed; running manual setup"
16+
$tempDnvmPath = Join-Path $env:TEMP "dnvminstall"
17+
$dnvmSetupCmdPath = Join-Path $tempDnvmPath "dnvm.ps1"
18+
& $dnvmSetupCmdPath setup
19+
}
20+
}
1521
}
1622

17-
function Install-NuGetPackages()
23+
function Get-DnxVersion
1824
{
19-
nuget restore serilog-sinks-splunk.sln
25+
$globalJson = Join-Path $PSScriptRoot "global.json"
26+
$jsonData = Get-Content -Path $globalJson -Raw | ConvertFrom-JSON
27+
return $jsonData.sdk.version
2028
}
2129

22-
function Invoke-MSBuild($solution, $customLogger)
30+
function Restore-Packages
2331
{
24-
if ($customLogger)
25-
{
26-
msbuild "$solution" /verbosity:minimal /p:Configuration=Release /logger:"$customLogger"
27-
}
28-
else
29-
{
30-
msbuild "$solution" /verbosity:minimal /p:Configuration=Release
31-
}
32+
param([string] $DirectoryName)
33+
& dnu restore ("""" + $DirectoryName + """")
3234
}
3335

34-
function Invoke-NuGetPackProj($csproj)
36+
function Build-Projects
3537
{
36-
nuget pack -Prop Configuration=Release -Symbols $csproj
38+
param($Directory, $pack)
39+
40+
$DirectoryName = $Directory.DirectoryName
41+
$artifactsFolder = join-path $root "artifacts"
42+
$projectsFolder = join-path $artifactsFolder $Directory.Name
43+
$buildFolder = join-path $projectsFolder "testbin"
44+
$packageFolder = join-path $projectsFolder "packages"
45+
46+
& dnu build ("""" + $DirectoryName + """") --configuration Release --out $buildFolder; if($LASTEXITCODE -ne 0) { exit 1 }
47+
48+
if($pack){
49+
& dnu pack ("""" + $DirectoryName + """") --configuration Release --out $packageFolder; if($LASTEXITCODE -ne 0) { exit 1 }
50+
}
3751
}
38-
39-
function Invoke-NuGetPackSpec($nuspec, $version)
52+
53+
function Test-Projects
4054
{
41-
nuget pack $nuspec -Version $version -OutputDirectory ..\..\
55+
param([string] $DirectoryName)
56+
& dnx -p ("""" + $DirectoryName + """") test; if($LASTEXITCODE -ne 0) { exit 2 }
4257
}
4358

44-
function Invoke-NuGetPack($version)
45-
{
46-
pushd .\src\Serilog.Sinks.Splunk
47-
Invoke-NuGetPackSpec "Serilog.Sinks.Splunk.nuspec" $version
48-
popd
59+
function Remove-PathVariable
60+
{
61+
param([string] $VariableToRemove)
62+
$path = [Environment]::GetEnvironmentVariable("PATH", "User")
63+
$newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove }
64+
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "User")
65+
$path = [Environment]::GetEnvironmentVariable("PATH", "Process")
66+
$newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove }
67+
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "Process")
4968
}
5069

51-
function Invoke-Build($majorMinor, $patch, $customLogger, $notouch)
52-
{
53-
$package="$majorMinor.$patch"
70+
Push-Location $PSScriptRoot
5471

55-
Write-Output "Building Serilog.Sinks.Splunk $package"
72+
$dnxVersion = Get-DnxVersion
5673

57-
if (-not $notouch)
58-
{
59-
$assembly = "$majorMinor.0.0"
74+
# Clean
75+
if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse }
6076

61-
Write-Output "Assembly version will be set to $assembly"
62-
Set-AssemblyVersions $package $assembly
63-
}
77+
# Remove the installed DNVM from the path and force use of
78+
# per-user DNVM (which we can upgrade as needed without admin permissions)
79+
Remove-PathVariable "*Program Files\Microsoft DNX\DNVM*"
6480

65-
Install-NuGetPackages
66-
67-
Invoke-MSBuild "serilog-sinks-splunk.sln" $customLogger
81+
# Make sure per-user DNVM is installed
82+
Install-Dnvm
6883

69-
Invoke-NuGetPack $package
70-
}
84+
# Install DNX
85+
dnvm install $dnxVersion -r CoreCLR -NoNative
86+
dnvm install $dnxVersion -r CLR -NoNative
87+
dnvm use $dnxVersion -r CLR
88+
89+
# Package restore
90+
Get-ChildItem -Path . -Filter *.xproj -Recurse | ForEach-Object { Restore-Packages $_.DirectoryName }
91+
92+
# Set build number
93+
$env:DNX_BUILD_VERSION = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
94+
Write-Host "Build number: " $env:DNX_BUILD_VERSION
95+
96+
# Build/package
97+
Get-ChildItem -Path .\src -Filter *.xproj -Recurse | ForEach-Object { Build-Projects $_ $true }
98+
Get-ChildItem -Path .\test -Filter *.xproj -Recurse | ForEach-Object { Build-Projects $_ $false }
99+
100+
# Test
101+
Get-ChildItem -Path .\test -Filter *.xproj -Recurse | ForEach-Object { Test-Projects $_.DirectoryName }
102+
103+
# Switch to Core CLR
104+
dnvm use $dnxVersion -r CoreCLR
105+
106+
# Test again
107+
Get-ChildItem -Path .\test -Filter *.xproj -Recurse | ForEach-Object { Test-Projects $_.DirectoryName }
71108

72-
$ErrorActionPreference = "Stop"
73-
Invoke-Build $majorMinor $patch $customLogger $notouch
109+
Pop-Location

CHANGES.md

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
##1.5.0
2-
- Moved the sink from its [original location](https://github.com/serilog/serilog)
1+
##2.0
2+
- Support for DotNet Core
3+
- Event Collector Sink targeting core
4+
- TCP/UDP Sinks targeting 4.5
5+
- Changed HTTP Client to include URI endpoint to host: "services/collector/event"
36

4-
##1.5.30
5-
- Added switch for template rendering
7+
##1.7
8+
- Better support for formatting including [#578](https://github.com/serilog/serilog/issues/578)
9+
- Cleanup on Event Collector
610

11+
##1.6.50
12+
- Streaming support for Event Collector
13+
714
##1.6.42
815
- Added support for Splunk 6.3 Event Collector
916
- Deprecated Splunk HTTP Sink using Management Port/API
1017

11-
##1.6.50
12-
- Streaming support for Event Collector
13-
14-
##1.7
15-
- Better support for formatting including [#578](https://github.com/serilog/serilog/issues/578)
16-
- Cleanup on Event Collector
18+
##1.5.30
19+
- Added switch for template rendering
20+
21+
##1.5.0
22+
- Moved the sink from its [original location](https://github.com/serilog/serilog)

README.md

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,6 @@ Using the new Event Collector in Splunk 6.3
2121

2222
```csharp
2323
var log = new LoggerConfiguration()
24-
.WriteTo.SplunkViaEventCollector("https://mysplunk:8088/services/collector", "myeventcollectortoken")
24+
.WriteTo.EventCollector("https://mysplunk:8088/services/collector", "myeventcollectortoken")
2525
.CreateLogger();
26-
```
27-
28-
Set up to log via TCP
29-
30-
```csharp
31-
var log = new LoggerConfiguration()
32-
.WriteTo.SplunkViaTcp("127.0.0.1", 10001)
33-
.CreateLogger();
34-
```
35-
36-
Or maybe UDP
37-
38-
```csharp
39-
var log = new LoggerConfiguration()
40-
.WriteTo.SplunkViaUdp("127.0.0.1", 10000)
41-
.CreateLogger();
42-
```
43-
26+
```

global.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"sdk": {
3+
"version": "1.0.0-rc1-update1"
4+
}
5+
}

sample/Serilog.Sinks.Splunk.Sample/App.config

Lines changed: 0 additions & 6 deletions
This file was deleted.

sample/Serilog.Sinks.Splunk.Sample/IConfigure.cs

Lines changed: 0 additions & 7 deletions
This file was deleted.

sample/Serilog.Sinks.Splunk.Sample/Program.cs

Lines changed: 0 additions & 113 deletions
This file was deleted.

0 commit comments

Comments
 (0)