Skip to content

2.1.0 Release #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,28 @@ Push-Location $PSScriptRoot

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

& dotnet restore
& dotnet restore --no-cache

$revision = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
$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-$revision"}[$branch -eq "master" -and $revision -ne "local"]

Push-Location src/Serilog.Sinks.RollingFile
foreach ($src in ls src/Serilog.*) {
Push-Location $src

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

Pop-Location
Push-Location test/Serilog.Sinks.RollingFile.Tests
Pop-Location
}

& dotnet test -c Release
if($LASTEXITCODE -ne 0) { exit 2 }
foreach ($test in ls test/Serilog.*.Tests) {
Push-Location $test

& dotnet test -c Release
if($LASTEXITCODE -ne 0) { exit 2 }

Pop-Location
}

Pop-Location
Pop-Location
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Serilog.Sinks.RollingFile
# 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)

The rolling file sink for Serilog.

[![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/)

Writes log events to a set of text files, one per day.
Writes [Serilog](https://serilog.net) events to a set of text files, one per day.

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

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

> **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.

* [Documentation](https://github.com/serilog/serilog/wiki)

Copyright © 2016 Serilog Contributors - Provided under the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0.html).
_Copyright © 2016 Serilog Contributors - Provided under the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0.html)._
11 changes: 9 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
version: '{build}'
skip_tags: true
image: Visual Studio 2015
configuration: Release
install:
Expand All @@ -18,5 +19,11 @@ deploy:
secure: nvZ/z+pMS91b3kG4DgfES5AcmwwGoBYQxr9kp4XiJHj25SAlgdIxFx++1N0lFH2x
skip_symbols: true
on:
branch: /^(dev|master)$/

branch: /^(master|dev)$/
- provider: GitHub
auth_token:
secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
artifact: /Serilog.*\.nupkg/
tag: v$(appveyor_build_version)
on:
branch: master
2 changes: 1 addition & 1 deletion src/Serilog.Sinks.RollingFile/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

[assembly: CLSCompliant(true)]

[assembly: InternalsVisibleTo("Serilog.Tests, PublicKey=" +
[assembly: InternalsVisibleTo("Serilog.Sinks.RollingFile.Tests, PublicKey=" +
"0024000004800000940000000602000000240000525341310004000001000100fb8d13fd344a1c" +
"6fe0fe83ef33c1080bf30690765bc6eb0df26ebfdf8f21670c64265b30db09f73a0dea5b3db4c9" +
"d18dbf6d5a25af5ce9016f281014d79dc3b4201ac646c451830fc7e61a2dfd633d34c39f87b818" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@
using Serilog.Configuration;
using Serilog.Core;
using Serilog.Events;
using Serilog.Formatting;
using Serilog.Formatting.Display;
using Serilog.Sinks.RollingFile;

namespace Serilog
{
/// <summary>
/// Extends <see cref="LoggerSinkConfiguration"/> with rolling file configuration methods.
/// </summary>
public static class RollingFileLoggerConfigurationExtensions
{
const int DefaultRetainedFileCountLimit = 31; // A long month of logs
Expand Down Expand Up @@ -62,9 +66,46 @@ public static LoggerConfiguration RollingFile(
LoggingLevelSwitch levelSwitch = null,
bool buffered = false)
{
if (sinkConfiguration == null) throw new ArgumentNullException(nameof(sinkConfiguration));
if (outputTemplate == null) throw new ArgumentNullException(nameof(outputTemplate));
var formatter = new MessageTemplateTextFormatter(outputTemplate, formatProvider);
return RollingFile(sinkConfiguration, formatter, pathFormat, restrictedToMinimumLevel, fileSizeLimitBytes,
retainedFileCountLimit, levelSwitch, buffered);
}

/// <summary>
/// Write log events to a series of files. Each file will be named according to
/// the date of the first log entry written to it. Only simple date-based rolling is
/// currently supported.
/// </summary>
/// <param name="sinkConfiguration">Logger sink configuration.</param>
/// <param name="formatter">Formatter to control how events are rendered into the file. To control
/// plain text formatting, use the overload that accepts an output template instead.</param>
/// <param name="pathFormat">String describing the location of the log files,
/// with {Date} in the place of the file date. E.g. "Logs\myapp-{Date}.log" will result in log
/// files such as "Logs\myapp-2013-10-20.log", "Logs\myapp-2013-10-21.log" and so on.</param>
/// <param name="restrictedToMinimumLevel">The minimum level for
/// events passed through the sink. Ignored when <paramref name="levelSwitch"/> is specified.</param>
/// <param name="levelSwitch">A switch allowing the pass-through minimum level
/// to be changed at runtime.</param>
/// <param name="fileSizeLimitBytes">The maximum size, in bytes, to which any single log file will be allowed to grow.
/// For unrestricted growth, pass null. The default is 1 GB.</param>
/// <param name="retainedFileCountLimit">The maximum number of log files that will be retained,
/// including the current log file. For unlimited retention, pass null. The default is 31.</param>
/// <param name="buffered">Indicates if flushing to the output file can be buffered or not. The default
/// is false.</param>
/// <returns>Configuration object allowing method chaining.</returns>
/// <remarks>The file will be written using the UTF-8 character set.</remarks>
public static LoggerConfiguration RollingFile(
this LoggerSinkConfiguration sinkConfiguration,
ITextFormatter formatter,
string pathFormat,
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
long? fileSizeLimitBytes = DefaultFileSizeLimitBytes,
int? retainedFileCountLimit = DefaultRetainedFileCountLimit,
LoggingLevelSwitch levelSwitch = null,
bool buffered = false)
{
if (sinkConfiguration == null) throw new ArgumentNullException(nameof(sinkConfiguration));
if (formatter == null) throw new ArgumentNullException(nameof(formatter));
var sink = new RollingFileSink(pathFormat, formatter, fileSizeLimitBytes, retainedFileCountLimit, buffered: buffered);
return sinkConfiguration.Sink(sink, restrictedToMinimumLevel, levelSwitch);
}
Expand Down
6 changes: 4 additions & 2 deletions src/Serilog.Sinks.RollingFile/project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.0.0",
"version": "2.1.0-*",
"description": "The rolling file sink for Serilog - Simple .NET logging with fully-structured events",
"authors": [ "Serilog Contributors" ],
"packOptions": {
Expand All @@ -13,7 +13,9 @@
"Serilog.Sinks.File": "2.0.0"
},
"buildOptions": {
"keyFile": "../../assets/Serilog.snk"
"keyFile": "../../assets/Serilog.snk",
"xmlDoc": true,
"warningsAsErrors": true
},
"frameworks": {
"net4.5": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#if FILE_IO && INTERNAL_TESTS

using System;
using System;
using System.Collections.Generic;
using System.IO;
using Xunit;
using Serilog;
using Serilog.Events;
using Serilog.Sinks.RollingFile;
using Serilog.Tests.Support;

namespace Serilog.Tests.Sinks.RollingFile
namespace Serilog.Sinks.RollingFile.Tests
{
public class RollingFileSinkTests
{
Expand Down Expand Up @@ -37,9 +36,9 @@ public void WhenRetentionCountIsSetOldFilesAreDeleted()
files =>
{
Assert.Equal(3, files.Count);
Assert.True(!File.Exists(files[0]));
Assert.True(File.Exists(files[1]));
Assert.True(File.Exists(files[2]));
Assert.True(!System.IO.File.Exists(files[0]));
Assert.True(System.IO.File.Exists(files[1]));
Assert.True(System.IO.File.Exists(files[2]));
});
}

Expand Down Expand Up @@ -99,7 +98,7 @@ static void TestRollingEventSequence(
log.Write(@event);

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

verified.Add(expected);
}
Expand All @@ -113,4 +112,3 @@ static void TestRollingEventSequence(
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#if INTERNAL_TESTS

using System;
using System;
using System.IO;
using System.Linq;
using Xunit;
using Serilog.Sinks.RollingFile;

namespace Serilog.Tests.Sinks.RollingFile
namespace Serilog.Sinks.RollingFile.Tests
{
public class TemplatedPathRollerTests
{
Expand Down Expand Up @@ -129,4 +127,3 @@ public void MatchingParsesDates()
}
}

#endif
4 changes: 4 additions & 0 deletions test/Serilog.Sinks.RollingFile.Tests/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"dotnet-test-xunit": "1.0.0-rc2-build10025",
"Serilog.Sinks.File": "2.0.0"
},
"buildOptions": {
"keyFile": "../../assets/Serilog.snk",
"warningsAsErrors": true
},
"frameworks": {
"net4.5.2": {},
"netcoreapp1.0": {
Expand Down