Skip to content

Commit eeaa870

Browse files
authored
Merge pull request #21 from serilog/dev
3.0.0 Release
2 parents e8d1557 + e1f90ac commit eeaa870

27 files changed

+1258
-1093
lines changed

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
root = true
2+
3+
[*]
4+
trim_trailing_whitespace = true
5+
insert_final_newline = true
6+
indent_style = space
7+
indent_size = 4
8+
9+
[*.{csproj,json,config,yml}]
10+
indent_size = 2
11+
12+
[*.sh]
13+
end_of_line = lf
14+
15+
[*.{cmd, bat}]
16+
end_of_line = crlf

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

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
### Serilog.Sinks.AzureTableStorage
1+
# Serilog.Sinks.AzureTableStorage [![Build status](https://ci.appveyor.com/api/projects/status/bb9v4y9dguyn7w9a/branch/master?svg=true)](https://ci.appveyor.com/project/serilog/serilog-sinks-azuretablestorage/branch/master)
22

3-
[![Build status](https://ci.appveyor.com/api/projects/status/bb9v4y9dguyn7w9a/branch/master?svg=true)](https://ci.appveyor.com/project/serilog/serilog-sinks-azuretablestorage/branch/master)
4-
5-
Writes to a table in [Windows Azure Table Storage](http://www.windowsazure.com/en-us/develop/net/how-to-guides/table-services/).
3+
Writes to a table in [Windows Azure Table Storage](https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-how-to-use-tables/).
64

75
**Package** - [Serilog.Sinks.AzureTableStorage](http://nuget.org/packages/serilog.sinks.azuretablestorage) | **Platforms** - .NET 4.5
86

@@ -13,3 +11,17 @@ var log = new LoggerConfiguration()
1311
.WriteTo.AzureTableStorage(storage)
1412
.CreateLogger();
1513
```
14+
15+
### JSON configuration
16+
17+
It is possible to configure the sink using [Serilog.Settings.Configuration](https://github.com/serilog/serilog-settings-configuration) by specifying the table name and connection string in `appsettings.json`:
18+
19+
```json
20+
"Serilog": {
21+
"WriteTo": [
22+
{"Name": "AzureTableStorage", "Args": {"storageTableName": "", "connectionString": ""}}
23+
]
24+
}
25+
```
26+
27+
JSON configuration must be enabled using `ReadFrom.Configuration()`; see the [documentation of the JSON configuration package](https://github.com/serilog/serilog-settings-configuration) for details.

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-azuretablestorage.sln

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Sinks.AzureTableSto
77
EndProject
88
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Serilog.Sinks.AzureTableStorageWithProperties.Tests", "test\Serilog.Sinks.AzureTableStorageWithProperties.Tests\Serilog.Sinks.AzureTableStorageWithProperties.Tests.xproj", "{2740763E-959A-4AAD-BFC9-5B428393DFDE}"
99
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Artifacts", "Artifacts", "{40D1EC3F-DCD9-47EB-8629-54D71AC31757}"
11+
ProjectSection(SolutionItems) = preProject
12+
.editorconfig = .editorconfig
13+
appveyor.yml = appveyor.yml
14+
Build.ps1 = Build.ps1
15+
CHANGES.md = CHANGES.md
16+
global.json = global.json
17+
README.md = README.md
18+
EndProjectSection
19+
EndProject
1020
Global
1121
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1222
Debug|Any CPU = Debug|Any CPU

src/Serilog.Sinks.AzureTableStorage/LoggerConfigurationAzureTableStorageExtensions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Copyright 2014 Serilog Contributors
2-
//
2+
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
6-
//
6+
//
77
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
8+
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -37,7 +37,7 @@ public static class LoggerConfigurationAzureTableStorageExtensions
3737
/// </summary>
3838
public static readonly TimeSpan DefaultPeriod = TimeSpan.FromSeconds(2);
3939

40-
/// <summary>
40+
/// <summary>
4141
/// Adds a sink that writes log events as records in the 'LogEventEntity' Azure Table Storage table in the given storage account.
4242
/// </summary>
4343
/// <param name="loggerConfiguration">The logger configuration.</param>
@@ -67,7 +67,7 @@ public static LoggerConfiguration AzureTableStorage(
6767
var sink = writeInBatches ?
6868
(ILogEventSink)new AzureBatchingTableStorageSink(storageAccount, formatProvider, batchPostingLimit ?? DefaultBatchPostingLimit, period ?? DefaultPeriod, storageTableName) :
6969
new AzureTableStorageSink(storageAccount, formatProvider, storageTableName);
70-
70+
7171
return loggerConfiguration.Sink(sink, restrictedToMinimumLevel);
7272
}
7373

Lines changed: 82 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// Copyright 2014 Serilog Contributors
2-
//
2+
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
6-
//
6+
//
77
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
8+
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,95 +18,91 @@
1818
using Serilog.Events;
1919
using Serilog.Sinks.AzureTableStorage;
2020
using System;
21-
using System.Collections.Generic;
22-
using System.Linq;
23-
using System.Text;
24-
using System.Threading.Tasks;
2521

2622
namespace Serilog
2723
{
28-
/// <summary>
29-
/// Adds the WriteTo.AzureTableStorageWithProperties() extension method to <see cref="LoggerConfiguration"/>.
30-
/// </summary>
31-
public static class LoggerConfigurationAzureTableStorageWithPropertiesExtensions
32-
{
33-
/// <summary>
34-
/// A reasonable default for the number of events posted in
35-
/// each batch.
36-
/// </summary>
37-
public const int DefaultBatchPostingLimit = 50;
24+
/// <summary>
25+
/// Adds the WriteTo.AzureTableStorageWithProperties() extension method to <see cref="LoggerConfiguration"/>.
26+
/// </summary>
27+
public static class LoggerConfigurationAzureTableStorageWithPropertiesExtensions
28+
{
29+
/// <summary>
30+
/// A reasonable default for the number of events posted in
31+
/// each batch.
32+
/// </summary>
33+
public const int DefaultBatchPostingLimit = 50;
3834

39-
/// <summary>
40-
/// A reasonable default time to wait between checking for event batches.
41-
/// </summary>
42-
public static readonly TimeSpan DefaultPeriod = TimeSpan.FromSeconds(2);
35+
/// <summary>
36+
/// A reasonable default time to wait between checking for event batches.
37+
/// </summary>
38+
public static readonly TimeSpan DefaultPeriod = TimeSpan.FromSeconds(2);
4339

44-
/// <summary>
45-
/// Adds a sink that writes log events as records in the 'LogEventEntity' Azure Table Storage table in the given storage account.
46-
/// </summary>
47-
/// <param name="loggerConfiguration">The logger configuration.</param>
48-
/// <param name="storageAccount">The Cloud Storage Account to use to insert the log entries to.</param>
49-
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
50-
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
51-
/// <param name="storageTableName">Table name that log entries will be written to. Note: Optional, setting this may impact performance</param>
52-
/// <param name="writeInBatches">Use a periodic batching sink, as opposed to a synchronous one-at-a-time sink; this alters the partition
53-
/// key used for the events so is not enabled by default.</param>
54-
/// <param name="batchPostingLimit">The maximum number of events to post in a single batch.</param>
55-
/// <param name="period">The time to wait between checking for event batches.</param>
56-
/// <param name="additionalRowKeyPostfix">Additional postfix string that will be appended to row keys</param>
57-
/// <returns>Logger configuration, allowing configuration to continue.</returns>
58-
/// <exception cref="ArgumentNullException">A required parameter is null.</exception>
59-
public static LoggerConfiguration AzureTableStorageWithProperties(
60-
this LoggerSinkConfiguration loggerConfiguration,
61-
CloudStorageAccount storageAccount,
62-
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
63-
IFormatProvider formatProvider = null,
64-
string storageTableName = null,
65-
bool writeInBatches = false,
66-
TimeSpan? period = null,
67-
int? batchPostingLimit = null,
68-
string additionalRowKeyPostfix = null)
69-
{
70-
if (loggerConfiguration == null) throw new ArgumentNullException("loggerConfiguration");
71-
if (storageAccount == null) throw new ArgumentNullException("storageAccount");
40+
/// <summary>
41+
/// Adds a sink that writes log events as records in the 'LogEventEntity' Azure Table Storage table in the given storage account.
42+
/// </summary>
43+
/// <param name="loggerConfiguration">The logger configuration.</param>
44+
/// <param name="storageAccount">The Cloud Storage Account to use to insert the log entries to.</param>
45+
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
46+
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
47+
/// <param name="storageTableName">Table name that log entries will be written to. Note: Optional, setting this may impact performance</param>
48+
/// <param name="writeInBatches">Use a periodic batching sink, as opposed to a synchronous one-at-a-time sink; this alters the partition
49+
/// key used for the events so is not enabled by default.</param>
50+
/// <param name="batchPostingLimit">The maximum number of events to post in a single batch.</param>
51+
/// <param name="period">The time to wait between checking for event batches.</param>
52+
/// <param name="additionalRowKeyPostfix">Additional postfix string that will be appended to row keys</param>
53+
/// <returns>Logger configuration, allowing configuration to continue.</returns>
54+
/// <exception cref="ArgumentNullException">A required parameter is null.</exception>
55+
public static LoggerConfiguration AzureTableStorageWithProperties(
56+
this LoggerSinkConfiguration loggerConfiguration,
57+
CloudStorageAccount storageAccount,
58+
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
59+
IFormatProvider formatProvider = null,
60+
string storageTableName = null,
61+
bool writeInBatches = false,
62+
TimeSpan? period = null,
63+
int? batchPostingLimit = null,
64+
string additionalRowKeyPostfix = null)
65+
{
66+
if (loggerConfiguration == null) throw new ArgumentNullException("loggerConfiguration");
67+
if (storageAccount == null) throw new ArgumentNullException("storageAccount");
7268

73-
var sink = writeInBatches ?
74-
(ILogEventSink)new AzureBatchingTableStorageWithPropertiesSink(storageAccount, formatProvider, batchPostingLimit ?? DefaultBatchPostingLimit, period ?? DefaultPeriod, storageTableName, additionalRowKeyPostfix) :
75-
new AzureTableStorageWithPropertiesSink(storageAccount, formatProvider, storageTableName, additionalRowKeyPostfix);
69+
var sink = writeInBatches ?
70+
(ILogEventSink)new AzureBatchingTableStorageWithPropertiesSink(storageAccount, formatProvider, batchPostingLimit ?? DefaultBatchPostingLimit, period ?? DefaultPeriod, storageTableName, additionalRowKeyPostfix) :
71+
new AzureTableStorageWithPropertiesSink(storageAccount, formatProvider, storageTableName, additionalRowKeyPostfix);
7672

77-
return loggerConfiguration.Sink(sink, restrictedToMinimumLevel);
78-
}
73+
return loggerConfiguration.Sink(sink, restrictedToMinimumLevel);
74+
}
7975

80-
/// <summary>
81-
/// Adds a sink that writes log events as records in the 'LogEventEntity' Azure Table Storage table in the given storage account.
82-
/// </summary>
83-
/// <param name="loggerConfiguration">The logger configuration.</param>
84-
/// <param name="connectionString">The Cloud Storage Account connection string to use to insert the log entries to.</param>
85-
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
86-
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
87-
/// <param name="storageTableName">Table name that log entries will be written to. Note: Optional, setting this may impact performance</param>
88-
/// <param name="writeInBatches">Use a periodic batching sink, as opposed to a synchronous one-at-a-time sink; this alters the partition
89-
/// key used for the events so is not enabled by default.</param>
90-
/// <param name="batchPostingLimit">The maximum number of events to post in a single batch.</param>
91-
/// <param name="period">The time to wait between checking for event batches.</param>
92-
/// <param name="additionalRowKeyPostfix">Additional postfix string that will be appended to row keys</param>
93-
/// <returns>Logger configuration, allowing configuration to continue.</returns>
94-
/// <exception cref="ArgumentNullException">A required parameter is null.</exception>
95-
public static LoggerConfiguration AzureTableStorageWithProperties(
96-
this LoggerSinkConfiguration loggerConfiguration,
97-
string connectionString,
98-
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
99-
IFormatProvider formatProvider = null,
100-
string storageTableName = null,
101-
bool writeInBatches = false,
102-
TimeSpan? period = null,
103-
int? batchPostingLimit = null,
104-
string additionalRowKeyPostfix = null)
105-
{
106-
if (loggerConfiguration == null) throw new ArgumentNullException("loggerConfiguration");
107-
if (String.IsNullOrEmpty(connectionString)) throw new ArgumentNullException("connectionString");
108-
var storageAccount = CloudStorageAccount.Parse(connectionString);
109-
return AzureTableStorageWithProperties(loggerConfiguration, storageAccount, restrictedToMinimumLevel, formatProvider, storageTableName, writeInBatches, period, batchPostingLimit, additionalRowKeyPostfix);
110-
}
111-
}
76+
/// <summary>
77+
/// Adds a sink that writes log events as records in the 'LogEventEntity' Azure Table Storage table in the given storage account.
78+
/// </summary>
79+
/// <param name="loggerConfiguration">The logger configuration.</param>
80+
/// <param name="connectionString">The Cloud Storage Account connection string to use to insert the log entries to.</param>
81+
/// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
82+
/// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
83+
/// <param name="storageTableName">Table name that log entries will be written to. Note: Optional, setting this may impact performance</param>
84+
/// <param name="writeInBatches">Use a periodic batching sink, as opposed to a synchronous one-at-a-time sink; this alters the partition
85+
/// key used for the events so is not enabled by default.</param>
86+
/// <param name="batchPostingLimit">The maximum number of events to post in a single batch.</param>
87+
/// <param name="period">The time to wait between checking for event batches.</param>
88+
/// <param name="additionalRowKeyPostfix">Additional postfix string that will be appended to row keys</param>
89+
/// <returns>Logger configuration, allowing configuration to continue.</returns>
90+
/// <exception cref="ArgumentNullException">A required parameter is null.</exception>
91+
public static LoggerConfiguration AzureTableStorageWithProperties(
92+
this LoggerSinkConfiguration loggerConfiguration,
93+
string connectionString,
94+
LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
95+
IFormatProvider formatProvider = null,
96+
string storageTableName = null,
97+
bool writeInBatches = false,
98+
TimeSpan? period = null,
99+
int? batchPostingLimit = null,
100+
string additionalRowKeyPostfix = null)
101+
{
102+
if (loggerConfiguration == null) throw new ArgumentNullException("loggerConfiguration");
103+
if (String.IsNullOrEmpty(connectionString)) throw new ArgumentNullException("connectionString");
104+
var storageAccount = CloudStorageAccount.Parse(connectionString);
105+
return AzureTableStorageWithProperties(loggerConfiguration, storageAccount, restrictedToMinimumLevel, formatProvider, storageTableName, writeInBatches, period, batchPostingLimit, additionalRowKeyPostfix);
106+
}
107+
}
112108
}

0 commit comments

Comments
 (0)