Skip to content

Commit b202599

Browse files
authored
Merge pull request #8 from serilog/dev
2.1.0 Release
2 parents 07d91dd + c8fc6b6 commit b202599

File tree

9 files changed

+91
-40
lines changed

9 files changed

+91
-40
lines changed

Diff for: Build.ps1

+18-10
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,28 @@ Push-Location $PSScriptRoot
22

33
if(Test-Path .\artifacts) { Remove-Item .\artifacts -Force -Recurse }
44

5-
& dotnet restore
5+
& dotnet restore --no-cache
66

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

9-
Push-Location src/Serilog.Sinks.RollingFile
11+
foreach ($src in ls src/Serilog.*) {
12+
Push-Location $src
1013

11-
& dotnet pack -c Release -o ..\..\.\artifacts --version-suffix=$revision
12-
if($LASTEXITCODE -ne 0) { exit 1 }
14+
& dotnet pack -c Release -o ..\..\.\artifacts --version-suffix=$suffix
15+
if($LASTEXITCODE -ne 0) { exit 1 }
1316

14-
Pop-Location
15-
Push-Location test/Serilog.Sinks.RollingFile.Tests
17+
Pop-Location
18+
}
1619

17-
& dotnet test -c Release
18-
if($LASTEXITCODE -ne 0) { exit 2 }
20+
foreach ($test in ls test/Serilog.*.Tests) {
21+
Push-Location $test
22+
23+
& dotnet test -c Release
24+
if($LASTEXITCODE -ne 0) { exit 2 }
25+
26+
Pop-Location
27+
}
1928

20-
Pop-Location
2129
Pop-Location

Diff for: README.md

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
# Serilog.Sinks.RollingFile
1+
# Serilog.Sinks.RollingFile [![Build status](https://ci.appveyor.com/api/projects/status/s9y1u1djdtdwn6u5?svg=true)](https://ci.appveyor.com/project/serilog/serilog-sinks-rollingfile) [![NuGet Version](http://img.shields.io/nuget/v/Serilog.Sinks.RollingFile.svg?style=flat)](https://www.nuget.org/packages/Serilog.Sinks.RollingFile/) [![Documentation](https://img.shields.io/badge/docs-wiki-yellow.svg)](https://github.com/serilog/serilog/wiki) [![Join the chat at https://gitter.im/serilog/serilog](https://img.shields.io/gitter/room/serilog/serilog.svg)](https://gitter.im/serilog/serilog)
22

3-
The rolling file sink for Serilog.
4-
5-
[![Build status](https://ci.appveyor.com/api/projects/status/s9y1u1djdtdwn6u5?svg=true)](https://ci.appveyor.com/project/serilog/serilog-sinks-rollingfile) [![NuGet Version](http://img.shields.io/nuget/v/Serilog.Sinks.RollingFile.svg?style=flat)](https://www.nuget.org/packages/Serilog.Sinks.RollingFile/)
6-
7-
Writes log events to a set of text files, one per day.
3+
Writes [Serilog](https://serilog.net) events to a set of text files, one per day.
84

95
The filename can include the `{Date}` placeholder, which will be replaced with the date of the events contained in the file.
106

@@ -28,6 +24,4 @@ For the same reason, only **the most recent 31 files** are retained by default (
2824

2925
> **Important:** Only one process may write to a log file at a given time. For multi-process scenarios, either use separate files or one of the non-file-based sinks.
3026
31-
* [Documentation](https://github.com/serilog/serilog/wiki)
32-
33-
Copyright © 2016 Serilog Contributors - Provided under the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0.html).
27+
_Copyright © 2016 Serilog Contributors - Provided under the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0.html)._

Diff for: appveyor.yml

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
version: '{build}'
2+
skip_tags: true
23
image: Visual Studio 2015
34
configuration: Release
45
install:
@@ -18,5 +19,11 @@ deploy:
1819
secure: nvZ/z+pMS91b3kG4DgfES5AcmwwGoBYQxr9kp4XiJHj25SAlgdIxFx++1N0lFH2x
1920
skip_symbols: true
2021
on:
21-
branch: /^(dev|master)$/
22-
22+
branch: /^(master|dev)$/
23+
- provider: GitHub
24+
auth_token:
25+
secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
26+
artifact: /Serilog.*\.nupkg/
27+
tag: v$(appveyor_build_version)
28+
on:
29+
branch: master

Diff for: src/Serilog.Sinks.RollingFile/Properties/AssemblyInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
[assembly: CLSCompliant(true)]
88

9-
[assembly: InternalsVisibleTo("Serilog.Tests, PublicKey=" +
9+
[assembly: InternalsVisibleTo("Serilog.Sinks.RollingFile.Tests, PublicKey=" +
1010
"0024000004800000940000000602000000240000525341310004000001000100fb8d13fd344a1c" +
1111
"6fe0fe83ef33c1080bf30690765bc6eb0df26ebfdf8f21670c64265b30db09f73a0dea5b3db4c9" +
1212
"d18dbf6d5a25af5ce9016f281014d79dc3b4201ac646c451830fc7e61a2dfd633d34c39f87b818" +

Diff for: src/Serilog.Sinks.RollingFile/RollingFileLoggerConfigurationExtensions.cs

+43-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@
1616
using Serilog.Configuration;
1717
using Serilog.Core;
1818
using Serilog.Events;
19+
using Serilog.Formatting;
1920
using Serilog.Formatting.Display;
2021
using Serilog.Sinks.RollingFile;
2122

2223
namespace Serilog
2324
{
25+
/// <summary>
26+
/// Extends <see cref="LoggerSinkConfiguration"/> with rolling file configuration methods.
27+
/// </summary>
2428
public static class RollingFileLoggerConfigurationExtensions
2529
{
2630
const int DefaultRetainedFileCountLimit = 31; // A long month of logs
@@ -62,9 +66,46 @@ public static LoggerConfiguration RollingFile(
6266
LoggingLevelSwitch levelSwitch = null,
6367
bool buffered = false)
6468
{
65-
if (sinkConfiguration == null) throw new ArgumentNullException(nameof(sinkConfiguration));
66-
if (outputTemplate == null) throw new ArgumentNullException(nameof(outputTemplate));
6769
var formatter = new MessageTemplateTextFormatter(outputTemplate, formatProvider);
70+
return RollingFile(sinkConfiguration, formatter, pathFormat, restrictedToMinimumLevel, fileSizeLimitBytes,
71+
retainedFileCountLimit, levelSwitch, buffered);
72+
}
73+
74+
/// <summary>
75+
/// Write log events to a series of files. Each file will be named according to
76+
/// the date of the first log entry written to it. Only simple date-based rolling is
77+
/// currently supported.
78+
/// </summary>
79+
/// <param name="sinkConfiguration">Logger sink configuration.</param>
80+
/// <param name="formatter">Formatter to control how events are rendered into the file. To control
81+
/// plain text formatting, use the overload that accepts an output template instead.</param>
82+
/// <param name="pathFormat">String describing the location of the log files,
83+
/// with {Date} in the place of the file date. E.g. "Logs\myapp-{Date}.log" will result in log
84+
/// files such as "Logs\myapp-2013-10-20.log", "Logs\myapp-2013-10-21.log" and so on.</param>
85+
/// <param name="restrictedToMinimumLevel">The minimum level for
86+
/// events passed through the sink. Ignored when <paramref name="levelSwitch"/> is specified.</param>
87+
/// <param name="levelSwitch">A switch allowing the pass-through minimum level
88+
/// to be changed at runtime.</param>
89+
/// <param name="fileSizeLimitBytes">The maximum size, in bytes, to which any single log file will be allowed to grow.
90+
/// For unrestricted growth, pass null. The default is 1 GB.</param>
91+
/// <param name="retainedFileCountLimit">The maximum number of log files that will be retained,
92+
/// including the current log file. For unlimited retention, pass null. The default is 31.</param>
93+
/// <param name="buffered">Indicates if flushing to the output file can be buffered or not. The default
94+
/// is false.</param>
95+
/// <returns>Configuration object allowing method chaining.</returns>
96+
/// <remarks>The file will be written using the UTF-8 character set.</remarks>
97+
public static LoggerConfiguration RollingFile(
98+
this LoggerSinkConfiguration sinkConfiguration,
99+
ITextFormatter formatter,
100+
string pathFormat,
101+
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
102+
long? fileSizeLimitBytes = DefaultFileSizeLimitBytes,
103+
int? retainedFileCountLimit = DefaultRetainedFileCountLimit,
104+
LoggingLevelSwitch levelSwitch = null,
105+
bool buffered = false)
106+
{
107+
if (sinkConfiguration == null) throw new ArgumentNullException(nameof(sinkConfiguration));
108+
if (formatter == null) throw new ArgumentNullException(nameof(formatter));
68109
var sink = new RollingFileSink(pathFormat, formatter, fileSizeLimitBytes, retainedFileCountLimit, buffered: buffered);
69110
return sinkConfiguration.Sink(sink, restrictedToMinimumLevel, levelSwitch);
70111
}

Diff for: src/Serilog.Sinks.RollingFile/project.json

+4-2
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 rolling file sink for Serilog - Simple .NET logging with fully-structured events",
44
"authors": [ "Serilog Contributors" ],
55
"packOptions": {
@@ -13,7 +13,9 @@
1313
"Serilog.Sinks.File": "2.0.0"
1414
},
1515
"buildOptions": {
16-
"keyFile": "../../assets/Serilog.snk"
16+
"keyFile": "../../assets/Serilog.snk",
17+
"xmlDoc": true,
18+
"warningsAsErrors": true
1719
},
1820
"frameworks": {
1921
"net4.5": {},

Diff for: test/Serilog.Sinks.RollingFile.Tests/Sinks/RollingFile/RollingFileSinkTests.cs renamed to test/Serilog.Sinks.RollingFile.Tests/RollingFileSinkTests.cs

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
#if FILE_IO && INTERNAL_TESTS
2-
3-
using System;
1+
using System;
42
using System.Collections.Generic;
53
using System.IO;
64
using Xunit;
5+
using Serilog;
76
using Serilog.Events;
87
using Serilog.Sinks.RollingFile;
98
using Serilog.Tests.Support;
109

11-
namespace Serilog.Tests.Sinks.RollingFile
10+
namespace Serilog.Sinks.RollingFile.Tests
1211
{
1312
public class RollingFileSinkTests
1413
{
@@ -37,9 +36,9 @@ public void WhenRetentionCountIsSetOldFilesAreDeleted()
3736
files =>
3837
{
3938
Assert.Equal(3, files.Count);
40-
Assert.True(!File.Exists(files[0]));
41-
Assert.True(File.Exists(files[1]));
42-
Assert.True(File.Exists(files[2]));
39+
Assert.True(!System.IO.File.Exists(files[0]));
40+
Assert.True(System.IO.File.Exists(files[1]));
41+
Assert.True(System.IO.File.Exists(files[2]));
4342
});
4443
}
4544

@@ -99,7 +98,7 @@ static void TestRollingEventSequence(
9998
log.Write(@event);
10099

101100
var expected = pathFormat.Replace("{Date}", @event.Timestamp.ToString("yyyyMMdd"));
102-
Assert.True(File.Exists(expected));
101+
Assert.True(System.IO.File.Exists(expected));
103102

104103
verified.Add(expected);
105104
}
@@ -113,4 +112,3 @@ static void TestRollingEventSequence(
113112
}
114113
}
115114
}
116-
#endif

Diff for: test/Serilog.Sinks.RollingFile.Tests/Sinks/RollingFile/TemplatedPathRollerTests.cs renamed to test/Serilog.Sinks.RollingFile.Tests/TemplatedPathRollerTests.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
#if INTERNAL_TESTS
2-
3-
using System;
1+
using System;
42
using System.IO;
53
using System.Linq;
64
using Xunit;
75
using Serilog.Sinks.RollingFile;
86

9-
namespace Serilog.Tests.Sinks.RollingFile
7+
namespace Serilog.Sinks.RollingFile.Tests
108
{
119
public class TemplatedPathRollerTests
1210
{
@@ -129,4 +127,3 @@ public void MatchingParsesDates()
129127
}
130128
}
131129

132-
#endif

Diff for: test/Serilog.Sinks.RollingFile.Tests/project.json

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
"dotnet-test-xunit": "1.0.0-rc2-build10025",
88
"Serilog.Sinks.File": "2.0.0"
99
},
10+
"buildOptions": {
11+
"keyFile": "../../assets/Serilog.snk",
12+
"warningsAsErrors": true
13+
},
1014
"frameworks": {
1115
"net4.5.2": {},
1216
"netcoreapp1.0": {

0 commit comments

Comments
 (0)