-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #124 from serilog/dev
3.0.0 Release
- Loading branch information
Showing
26 changed files
with
983 additions
and
845 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,51 @@ | ||
echo "build: Build started" | ||
Write-Output "build: Build started" | ||
|
||
& dotnet --info | ||
& dotnet --list-sdks | ||
|
||
Push-Location $PSScriptRoot | ||
|
||
if(Test-Path .\artifacts) { | ||
echo "build: Cleaning .\artifacts" | ||
Write-Output "build: Cleaning .\artifacts" | ||
Remove-Item .\artifacts -Force -Recurse | ||
} | ||
|
||
& dotnet restore --no-cache | ||
|
||
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL]; | ||
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL]; | ||
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"] | ||
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "main" -and $revision -ne "local"] | ||
$commitHash = $(git rev-parse --short HEAD) | ||
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""] | ||
|
||
echo "build: Version suffix is $suffix" | ||
echo "build: Build version suffix is $buildSuffix" | ||
Write-Output "build: Package version suffix is $suffix" | ||
Write-Output "build: Build version suffix is $buildSuffix" | ||
|
||
foreach ($src in ls src/*) { | ||
Push-Location $src | ||
echo "build: Packaging project in $src" | ||
foreach ($src in Get-ChildItem src/*) { | ||
Push-Location $src | ||
|
||
& dotnet build -c Release --version-suffix=$buildSuffix | ||
Write-Output "build: Packaging project in $src" | ||
|
||
if($suffix) { | ||
& dotnet pack -c Release --no-build -o ..\..\artifacts --version-suffix=$suffix | ||
} else { | ||
& dotnet pack -c Release --no-build -o ..\..\artifacts | ||
} | ||
& dotnet build -c Release --version-suffix=$buildSuffix | ||
if ($suffix) { | ||
& dotnet pack -c Release --include-source -o ..\..\artifacts --version-suffix=$suffix --no-build | ||
} else { | ||
& dotnet pack -c Release --include-source -o ..\..\artifacts --no-build | ||
} | ||
if($LASTEXITCODE -ne 0) { throw "failed" } | ||
|
||
if($LASTEXITCODE -ne 0) { exit 1 } | ||
|
||
Pop-Location | ||
Pop-Location | ||
} | ||
|
||
foreach ($test in ls test/*.Tests) { | ||
Push-Location $test | ||
echo "build: Testing project in $test" | ||
& dotnet test -c Release | ||
if($LASTEXITCODE -ne 0) { exit 3 } | ||
Pop-Location | ||
foreach ($test in Get-ChildItem test/*.Tests) { | ||
Push-Location $test | ||
|
||
Write-Output "build: Testing project in $test" | ||
|
||
& dotnet test -c Release | ||
if($LASTEXITCODE -ne 0) { throw "failed" } | ||
|
||
Pop-Location | ||
} | ||
|
||
Pop-Location |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,106 @@ | ||
# Serilog.Sinks.Email | ||
|
||
[![Build status](https://ci.appveyor.com/api/projects/status/sfvp7dw8u6aiodj1/branch/master?svg=true)](https://ci.appveyor.com/project/serilog/serilog-sinks-email/branch/master) | ||
[![Build status](https://ci.appveyor.com/api/projects/status/sfvp7dw8u6aiodj1/branch/main?svg=true)](https://ci.appveyor.com/project/serilog/serilog-sinks-email/branch/main) | ||
|
||
Sends log events by SMTP email. | ||
|
||
**Package** - [Serilog.Sinks.Email](http://nuget.org/packages/serilog.sinks.email) | ||
| **Platforms** - .NET 4.5 | ||
|
||
```csharp | ||
var log = new LoggerConfiguration() | ||
await using var log = new LoggerConfiguration() | ||
.WriteTo.Email( | ||
fromEmail: "[email protected]", | ||
toEmail: "[email protected]", | ||
mailServer: "smtp.example.com") | ||
from: "[email protected]", | ||
to: "[email protected]", | ||
host: "smtp.example.com") | ||
.CreateLogger(); | ||
``` | ||
|
||
An overload accepting `EmailConnectionInfo` can be used to specify advanced options. | ||
Supported options are: | ||
|
||
| Parameter | Description | | ||
|------------------------|-------------------------------------------------------------------------------------------------------------------------------------| | ||
| `from` | The email address emails will be sent from. | | ||
| `to` | The email address emails will be sent to. Multiple addresses can be separated with commas or semicolons. | | ||
| `host` | The SMTP server to use. | | ||
| `port` | The port used for the SMTP connection. The default is 25. | | ||
| `connectionSecurity` | Choose the security applied to the SMTP connection. This enumeration type is supplied by MailKit. The default is `Auto`. | | ||
| `credentials` | The network credentials to use to authenticate with the mail server. | | ||
| `subject` | A message template describing the email subject. The default is `"Log Messages"`. | | ||
| `body` | A message template describing the format of the email body. The default is `"{Timestamp} [{Level}] {Message}{NewLine}{Exception}"`. | | ||
| `formatProvider` | Supplies culture-specific formatting information. The default is to use the current culture. | | ||
|
||
An overload accepting `EmailSinkOptions` can be used to specify advanced options such as batched and/or HTML body templates. | ||
|
||
## Sending batch email | ||
|
||
To send batch email, supply `WriteTo.Email` with a batch size: | ||
|
||
```csharp | ||
await using var log = new LoggerConfiguration() | ||
.WriteTo.Email( | ||
options: new() | ||
{ | ||
From = "[email protected]", | ||
To = "[email protected]", | ||
Host = "smtp.example.com", | ||
}, | ||
batchingOptions: new() | ||
{ | ||
BatchSizeLimit = 10, | ||
Period = TimeSpan.FromSeconds(30), | ||
}) | ||
.CreateLogger(); | ||
``` | ||
|
||
Batch formatting can be customized using `options.Body`. | ||
|
||
## Sending HTML email | ||
|
||
To send HTML email, specify a custom `IBatchTextFormatter` in `options.Body` and set `options.IsBodyHtml` to `true`: | ||
|
||
|
||
```csharp | ||
await using var log = new LoggerConfiguration() | ||
.WriteTo.Email( | ||
options: new() | ||
{ | ||
From = "[email protected]", | ||
To = "[email protected]", | ||
Host = "smtp.example.com", | ||
Body = new MyHtmlBodyFormatter(), | ||
IsBodyHtml = true, | ||
}, | ||
batchingOptions: new() | ||
{ | ||
BatchSizeLimit = 10, | ||
Period = TimeSpan.FromSeconds(30), | ||
}) | ||
.CreateLogger(); | ||
``` | ||
|
||
A simplistic HTML formatter is shown below: | ||
|
||
```csharp | ||
class MyHtmlBodyFormatter : IBatchTextFormatter | ||
{ | ||
public void FormatBatch(IEnumerable<LogEvent> logEvents, TextWriter output) | ||
{ | ||
output.Write("<table>"); | ||
foreach (var logEvent in logEvents) | ||
{ | ||
output.Write("<tr>"); | ||
Format(logEvent, output); | ||
output.Write("</tr>"); | ||
} | ||
|
||
output.Write("</table>"); | ||
} | ||
|
||
public void Format(LogEvent logEvent, TextWriter output) | ||
{ | ||
using var buffer = new StringWriter(); | ||
logEvent.RenderMessage(buffer); | ||
output.Write(WebUtility.HtmlEncode(buffer.ToString())); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,23 @@ | ||
version: '{build}' | ||
skip_tags: true | ||
image: | ||
- Visual Studio 2019 | ||
- Ubuntu | ||
configuration: Release | ||
image: Visual Studio 2022 | ||
test: off | ||
#install: | ||
#- ps: ./Setup.ps1 | ||
build_script: | ||
- ps: ./Build.ps1 | ||
for: | ||
- | ||
matrix: | ||
only: | ||
- image: Ubuntu | ||
# install: | ||
# - sh setup.sh | ||
build_script: | ||
- sh build.sh | ||
- pwsh: ./Build.ps1 | ||
artifacts: | ||
- path: artifacts/Serilog.*.nupkg | ||
- path: artifacts/Serilog.*.snupkg | ||
- path: artifacts/Serilog.*.nupkg | ||
deploy: | ||
- provider: NuGet | ||
api_key: | ||
secure: K3/810hkTO6rd2AEHVkUQAadjGmDREus9k96QHu6hxrA1/wRTuAJemHMKtVVgIvf | ||
skip_symbols: true | ||
on: | ||
branch: /^(master|dev)$/ | ||
- provider: GitHub | ||
auth_token: | ||
secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX | ||
artifact: | ||
/Serilog.*\.nupkg/ | ||
/Serilog.*\.snupkg/ | ||
tag: v$(appveyor_build_version) | ||
on: | ||
branch: master | ||
- provider: NuGet | ||
api_key: | ||
secure: sDnchSg4TZIOK7oIUI6BJwFPNENTOZrGNsroGO1hehLJSvlHpFmpTwiX8+bgPD+Q | ||
skip_symbols: true | ||
on: | ||
branch: /^(main|dev)$/ | ||
- provider: GitHub | ||
auth_token: | ||
secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX | ||
artifact: /Serilog.*\.nupkg/ | ||
tag: v$(appveyor_build_version) | ||
on: | ||
branch: main | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"sdk": { | ||
"allowPrerelease": false, | ||
"version": "3.1.100", | ||
"version": "8.0.100", | ||
"rollForward": "latestFeature" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.