Skip to content

Commit 7d4f169

Browse files
authored
Merge pull request #23 from serilog/dev
2.1.0 Release
2 parents 350f662 + 030293f commit 7d4f169

File tree

7 files changed

+86
-113
lines changed

7 files changed

+86
-113
lines changed

Build.ps1

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,51 @@
1+
echo "build: Build started"
2+
13
Push-Location $PSScriptRoot
24

3-
if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse }
5+
if(Test-Path .\artifacts) {
6+
echo "build: Cleaning .\artifacts"
7+
Remove-Item .\artifacts -Force -Recurse
8+
}
49

510
& dotnet restore --no-cache
611

7-
$branch = $(git symbolic-ref --short -q HEAD)
8-
$revision = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
9-
$suffix = @{ $true = ""; $false = "$branch-$revision"}[$branch -eq "master" -and $revision -ne "local"]
12+
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
13+
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
14+
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"]
1015

11-
foreach ($src in ls src/Serilog.*) {
16+
echo "build: Version suffix is $suffix"
17+
18+
foreach ($src in ls src/*) {
1219
Push-Location $src
1320

14-
& dotnet pack -c Release -o ..\..\.\artifacts --version-suffix=$suffix
21+
echo "build: Packaging project in $src"
22+
23+
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix
1524
if($LASTEXITCODE -ne 0) { exit 1 }
1625

1726
Pop-Location
1827
}
1928

20-
foreach ($test in ls test/Serilog.*.Tests) {
29+
foreach ($test in ls test/*.PerformanceTests) {
2130
Push-Location $test
2231

23-
& dotnet test -c Release
32+
echo "build: Building performance test project in $test"
33+
34+
& dotnet build -c Release
2435
if($LASTEXITCODE -ne 0) { exit 2 }
2536

2637
Pop-Location
2738
}
2839

40+
foreach ($test in ls test/*.Tests) {
41+
Push-Location $test
42+
43+
echo "build: Testing project in $test"
44+
45+
& dotnet test -c Release
46+
if($LASTEXITCODE -ne 0) { exit 3 }
47+
48+
Pop-Location
49+
}
50+
2951
Pop-Location

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ deploy:
2222
branch: /^(master|dev)$/
2323
- provider: GitHub
2424
auth_token:
25-
secure: ggZTqqV1z0xecDoQbeoy3A7xikShCt9FWZIGp95dG9Fo0p5RAT9oGU0ZekHfUIwk
25+
secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
2626
artifact: /Serilog.*\.nupkg/
2727
tag: v$(appveyor_build_version)
2828
on:

serilog-sinks-email.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{340DBC35-BD0
2020
EndProject
2121
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{70D17E86-9325-4228-8512-547B3E0774A1}"
2222
EndProject
23+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Sinks.Email.Tests", "test\Serilog.Sinks.Email.Tests\Serilog.Sinks.Email.Tests.xproj", "{7BC4F72D-F40B-4F7C-8EBD-E50F0D6C0D97}"
24+
EndProject
2325
Global
2426
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2527
Debug|Any CPU = Debug|Any CPU
@@ -30,11 +32,16 @@ Global
3032
{37082D9A-C3C9-490E-8AB9-FED496F5A70B}.Debug|Any CPU.Build.0 = Debug|Any CPU
3133
{37082D9A-C3C9-490E-8AB9-FED496F5A70B}.Release|Any CPU.ActiveCfg = Release|Any CPU
3234
{37082D9A-C3C9-490E-8AB9-FED496F5A70B}.Release|Any CPU.Build.0 = Release|Any CPU
35+
{7BC4F72D-F40B-4F7C-8EBD-E50F0D6C0D97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36+
{7BC4F72D-F40B-4F7C-8EBD-E50F0D6C0D97}.Debug|Any CPU.Build.0 = Debug|Any CPU
37+
{7BC4F72D-F40B-4F7C-8EBD-E50F0D6C0D97}.Release|Any CPU.ActiveCfg = Release|Any CPU
38+
{7BC4F72D-F40B-4F7C-8EBD-E50F0D6C0D97}.Release|Any CPU.Build.0 = Release|Any CPU
3339
EndGlobalSection
3440
GlobalSection(SolutionProperties) = preSolution
3541
HideSolutionNode = FALSE
3642
EndGlobalSection
3743
GlobalSection(NestedProjects) = preSolution
3844
{37082D9A-C3C9-490E-8AB9-FED496F5A70B} = {340DBC35-BD09-414B-818C-978FBCA4CDF1}
45+
{7BC4F72D-F40B-4F7C-8EBD-E50F0D6C0D97} = {70D17E86-9325-4228-8512-547B3E0774A1}
3946
EndGlobalSection
4047
EndGlobal

src/Serilog.Sinks.Email/Sinks/Email/EmailSink.cs

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -94,36 +94,6 @@ protected override void Dispose(bool disposing)
9494
_smtpClient.Dispose();
9595
}
9696

97-
protected override void EmitBatch(IEnumerable<LogEvent> events)
98-
{
99-
if (events == null)
100-
throw new ArgumentNullException(nameof(events));
101-
var payload = new StringWriter();
102-
103-
foreach (var logEvent in events)
104-
{
105-
_textFormatter.Format(logEvent, payload);
106-
}
107-
108-
var mailMessage = new MailMessage
109-
{
110-
From = new MailAddress(_connectionInfo.FromEmail),
111-
Subject = _connectionInfo.EmailSubject,
112-
Body = payload.ToString(),
113-
BodyEncoding = Encoding.UTF8,
114-
SubjectEncoding = Encoding.UTF8,
115-
IsBodyHtml = _connectionInfo.IsBodyHtml
116-
};
117-
118-
foreach (var recipient in _connectionInfo.ToEmail.Split(",;".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
119-
{
120-
mailMessage.To.Add(recipient);
121-
}
122-
123-
_smtpClient.Send(mailMessage);
124-
}
125-
126-
#if NET45
12797
/// <summary>
12898
/// Emit a batch of log events, running asynchronously.
12999
/// </summary>
@@ -132,9 +102,9 @@ protected override void EmitBatch(IEnumerable<LogEvent> events)
132102
/// not both.</remarks>
133103
protected override async Task EmitBatchAsync(IEnumerable<LogEvent> events)
134104
{
135-
136105
if (events == null)
137106
throw new ArgumentNullException(nameof(events));
107+
138108
var payload = new StringWriter();
139109

140110
foreach (var logEvent in events)
@@ -159,7 +129,6 @@ protected override async Task EmitBatchAsync(IEnumerable<LogEvent> events)
159129

160130
await _smtpClient.SendMailAsync(mailMessage);
161131
}
162-
#endif
163132

164133
private SmtpClient CreateSmtpClient()
165134
{

src/Serilog.Sinks.Email/Sinks/Email/MailKitEmailSink.cs

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -83,34 +83,6 @@ private MimeKit.MimeMessage CreateMailMessage(string payload)
8383
return mailMessage;
8484
}
8585

86-
protected override void EmitBatch(IEnumerable<LogEvent> events)
87-
{
88-
if (events == null)
89-
throw new ArgumentNullException(nameof(events));
90-
91-
var payload = new StringWriter();
92-
93-
foreach (var logEvent in events)
94-
{
95-
_textFormatter.Format(logEvent, payload);
96-
}
97-
98-
var mailMessage = CreateMailMessage(payload.ToString());
99-
100-
try
101-
{
102-
using (var smtpClient = OpenConnectedSmtpClient())
103-
{
104-
smtpClient.Send(mailMessage);
105-
smtpClient.Disconnect(quit: false);
106-
}
107-
}
108-
catch(Exception ex)
109-
{
110-
SelfLog.WriteLine("Failed to send email: {0}", ex.ToString());
111-
}
112-
}
113-
11486
/// <summary>
11587
/// Emit a batch of log events, running asynchronously.
11688
/// </summary>
@@ -150,17 +122,17 @@ private SmtpClient OpenConnectedSmtpClient()
150122
var smtpClient = new SmtpClient();
151123
if (!string.IsNullOrWhiteSpace(_connectionInfo.MailServer))
152124
{
125+
smtpClient.Connect(
126+
_connectionInfo.MailServer, _connectionInfo.Port,
127+
useSsl: _connectionInfo.EnableSsl);
128+
153129
if (_connectionInfo.NetworkCredentials != null)
154130
{
155131
smtpClient.Authenticate(
156132
Encoding.UTF8,
157133
_connectionInfo.NetworkCredentials.GetCredential(
158134
_connectionInfo.MailServer, _connectionInfo.Port, "smtp"));
159135
}
160-
161-
smtpClient.Connect(
162-
_connectionInfo.MailServer, _connectionInfo.Port,
163-
useSsl: _connectionInfo.EnableSsl);
164136
}
165137
return smtpClient;
166138
}

src/Serilog.Sinks.Email/project.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "2.0.0",
2+
"version": "2.1.0-*",
33
"description": "The file sink for Serilog",
44
"authors": [ "Serilog Contributors" ],
55
"packOptions": {
@@ -27,7 +27,7 @@
2727
},
2828
"netstandard1.3": {
2929
"dependencies": {
30-
"MailKit": "1.4.0",
30+
"MailKit": "1.4.2",
3131
"System.Linq": "4.1.0",
3232
"System.Threading": "4.0.11"
3333
},
Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,43 @@
11
{
2-
"version": "2.0.0",
3-
"testRunner": "xunit",
4-
"dependencies": {
5-
"Serilog": "2.0.0",
6-
"xunit": "2.2.0-*",
7-
"dotnet-test-xunit": "2.2.0-preview2-build1029",
8-
"Serilog.Sinks.Email": { "target": "project" }
9-
},
10-
"frameworks": {
11-
"net4.5.2": {
12-
"buildOptions": {
13-
"keyFile": "../../assets/Serilog.snk",
14-
"define": [ "SYSTEM_NET" ]
15-
},
16-
"frameworkAssemblies": {
17-
"System.Configuration": ""
18-
}
19-
},
20-
"netcoreapp1.0": {
21-
"buildOptions": {
22-
"keyFile": "../../assets/Serilog.snk",
23-
"define": [ "MAIL_KIT" ]
24-
},
25-
"imports": [
26-
"dnxcore50",
27-
"portable-net45+win8"
28-
],
29-
"dependencies": {
30-
"Microsoft.NETCore.App": {
31-
"type": "platform",
32-
"version": "1.0.0"
33-
},
34-
"MailKit": "1.4.0",
35-
"System.Linq": "4.1.0",
36-
"System.Threading": "4.0.11"
37-
}
38-
}
39-
}
2+
"version": "2.0.0",
3+
"testRunner": "xunit",
4+
5+
"dependencies": {
6+
"Serilog": "2.0.0",
7+
"xunit": "2.2.0-*",
8+
"dotnet-test-xunit": "2.2.0-preview2-build1029",
9+
"Serilog.Sinks.Email": { "target": "project" }
10+
},
11+
12+
"buildOptions": {
13+
"keyFile": "../../assets/Serilog.snk"
14+
},
15+
16+
"frameworks": {
17+
"net4.5.2": {
18+
"buildOptions": {
19+
"define": [ "SYSTEM_NET" ]
20+
},
21+
"frameworkAssemblies": {
22+
"System.Configuration": ""
23+
}
24+
},
25+
"netcoreapp1.0": {
26+
"buildOptions": {
27+
"define": [ "MAIL_KIT" ]
28+
},
29+
"imports": [
30+
"dnxcore50",
31+
"portable-net45+win8"
32+
],
33+
"dependencies": {
34+
"Microsoft.NETCore.App": {
35+
"type": "platform",
36+
"version": "1.0.0"
37+
},
38+
"System.Linq": "4.1.0",
39+
"System.Threading": "4.0.11"
40+
}
41+
}
42+
}
4043
}

0 commit comments

Comments
 (0)