Skip to content

Commit 25c6920

Browse files
authored
Merge pull request #92 from serilog-contrib/dev
version 8 release
2 parents e613f7b + 5c84597 commit 25c6920

34 files changed

+1149
-1938
lines changed

.editorconfig

Lines changed: 35 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,52 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
13
root = true
24

5+
# All Files
36
[*]
4-
trim_trailing_whitespace = true
5-
insert_final_newline = true
7+
charset = utf-8
68
indent_style = space
79
indent_size = 4
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
812

9-
[*.{csproj,json,config,yml}]
13+
# XML Configuration Files
14+
[*.{xml,config,props,targets,nuspec,resx,ruleset,vsixmanifest,vsct}]
1015
indent_size = 2
1116

12-
[*.sh]
13-
end_of_line = lf
14-
15-
[*.{cmd, bat}]
16-
end_of_line = crlf
17+
# JSON Files
18+
[*.{json,json5,webmanifest}]
19+
indent_size = 2
1720

18-
[*.cs]
21+
# Project Files
22+
[*.{csproj,sqlproj}]
23+
indent_size = 2
1924

20-
#Core editorconfig formatting - indentation
25+
# YAML Files
26+
[*.{yml,yaml}]
27+
indent_size = 2
2128

22-
#use soft tabs (spaces) for indentation
23-
indent_style = space
29+
# Markdown Files
30+
[*.md]
31+
trim_trailing_whitespace = false
2432

25-
#Formatting - new line options
33+
# Web Files
34+
[*.{htm,html,js,jsm,ts,tsx,css,sass,scss,less,pcss,svg,vue}]
35+
indent_size = 2
2636

27-
#place catch statements on a new line
28-
csharp_new_line_before_catch = true
29-
#place else statements on a new line
30-
csharp_new_line_before_else = true
31-
#require finally statements to be on a new line after the closing brace
32-
csharp_new_line_before_finally = true
33-
#require braces to be on a new line for methods, control_blocks, types, object_collection, and properties (also known as "Allman" style)
34-
csharp_new_line_before_open_brace = methods, control_blocks, types, object_collection, properties
37+
# Batch Files
38+
[*.{cmd,bat}]
39+
end_of_line = crlf
3540

36-
#Formatting - organize using options
41+
# Bash Files
42+
[*.sh]
43+
end_of_line = lf
3744

38-
#sort System.* using directives alphabetically, and place them before other usings
45+
[*.{cs,vb}]
3946
dotnet_sort_system_directives_first = true
47+
dotnet_separate_import_directive_groups = true
48+
dotnet_style_namespace_match_folder = true
4049

41-
#Formatting - spacing options
42-
43-
#require NO space between a cast and the value
44-
csharp_space_after_cast = false
45-
#require a space before the colon for bases or interfaces in a type declaration
46-
csharp_space_after_colon_in_inheritance_clause = true
47-
#require a space after a keyword in a control flow statement such as a for loop
48-
csharp_space_after_keywords_in_control_flow_statements = true
49-
#require a space before the colon for bases or interfaces in a type declaration
50-
csharp_space_before_colon_in_inheritance_clause = true
51-
#remove space within empty argument list parentheses
52-
csharp_space_between_method_call_empty_parameter_list_parentheses = false
53-
#remove space between method call name and opening parenthesis
54-
csharp_space_between_method_call_name_and_opening_parenthesis = false
55-
#do not place space characters after the opening parenthesis and before the closing parenthesis of a method call
56-
csharp_space_between_method_call_parameter_list_parentheses = false
57-
#remove space within empty parameter list parentheses for a method declaration
58-
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
59-
#place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list.
60-
csharp_space_between_method_declaration_parameter_list_parentheses = false
61-
62-
#Formatting - wrapping options
63-
64-
#leave code block on single line
65-
csharp_preserve_single_line_blocks = true
66-
#leave statements and member declarations on the same line
67-
csharp_preserve_single_line_statements = true
68-
69-
#Style - expression bodied member options
70-
71-
#prefer expression-bodied members for accessors
72-
csharp_style_expression_bodied_accessors = true:suggestion
73-
#prefer block bodies for methods
74-
csharp_style_expression_bodied_methods = false:suggestion
75-
#prefer expression-bodied members for properties
76-
csharp_style_expression_bodied_properties = true:suggestion
77-
78-
#Style - expression level options
79-
80-
#prefer out variables to be declared inline in the argument list of a method call when possible
81-
csharp_style_inlined_variable_declaration = true:suggestion
82-
#prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them
83-
dotnet_style_predefined_type_for_member_access = true:suggestion
84-
85-
#Style - implicit and explicit types
86-
87-
#prefer var is used to declare variables with built-in system types such as int
88-
csharp_style_var_for_built_in_types = true:suggestion
89-
#prefer var when the type is already mentioned on the right-hand side of a declaration expression
90-
csharp_style_var_when_type_is_apparent = true:suggestion
91-
92-
#Style - language keyword and framework type options
93-
94-
#prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them
95-
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
96-
97-
#Style - qualification options
98-
99-
#prefer fields not to be prefaced with this. or Me. in Visual Basic
100-
dotnet_style_qualification_for_field = false:suggestion
101-
#prefer methods not to be prefaced with this. or Me. in Visual Basic
102-
dotnet_style_qualification_for_method = false:suggestion
103-
#prefer properties not to be prefaced with this. or Me. in Visual Basic
104-
dotnet_style_qualification_for_property = false:suggestion
50+
[*.cs]
51+
csharp_using_directive_placement = outside_namespace
52+
csharp_style_namespace_declarations = file_scoped:warning

.github/workflows/build.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: Build
22

33
env:
4-
BUILD_VERSION: "7.0.${{github.run_number}}${{github.ref != 'refs/heads/master' && '-beta' || ''}}"
5-
BUILD_INFORMATION: "7.0.${{github.run_number}}${{github.ref != 'refs/heads/master' && '-beta' || ''}}+Branch.${{github.ref_name}}.Sha.${{github.sha}}"
4+
BUILD_VERSION: "8.0.${{github.run_number}}${{github.ref != 'refs/heads/master' && '-beta' || ''}}"
5+
BUILD_INFORMATION: "8.0.${{github.run_number}}${{github.ref != 'refs/heads/master' && '-beta' || ''}}+Branch.${{github.ref_name}}.Sha.${{github.sha}}"
66

77
on:
88
push:
@@ -60,20 +60,20 @@ jobs:
6060
name: artifacts
6161
path: '${{github.workspace}}/artifacts'
6262

63-
- name: Publish Build Packages
63+
- name: Publish GitHub Packages
6464
if: success() && github.event_name != 'pull_request'
6565
run: dotnet nuget push ./artifacts/*.nupkg --source https://nuget.pkg.github.com/serilog-contrib/index.json --api-key ${GITHUB_TOKEN} --skip-duplicate
6666
env:
6767
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6868

69+
- name: Publish NuGet Packages
70+
if: success() && github.event_name != 'pull_request'
71+
run: dotnet nuget push ./artifacts/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${NUGET_API_KEY} --skip-duplicate
72+
env:
73+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
74+
6975
- name: Create Release
70-
if: success() && startsWith(github.ref, 'refs/heads/master')
76+
if: success() && github.event_name != 'pull_request' && startsWith(github.ref, 'refs/heads/master')
7177
run: 'gh release create "${{env.BUILD_VERSION}}" ./artifacts/*.nupkg --title "v${{env.BUILD_VERSION}}"'
7278
env:
7379
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74-
75-
- name: Publish Release Packages
76-
if: success() && startsWith(github.ref, 'refs/heads/master')
77-
run: dotnet nuget push ./artifacts/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${NUGET_API_KEY} --skip-duplicate
78-
env:
79-
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}

Build.ps1

Lines changed: 0 additions & 38 deletions
This file was deleted.

CHANGES.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
8.0.0
2+
* Breaking: major refactor to simplify code base
3+
* Removed: AzureTableStorageWithProperties extension removed, use equivalent AzureTableStorage
4+
* Removed: ICloudTableProvider provider removed
5+
* Added: IDocumentFactory to allow control over table document
6+
* Change: PartitionKey and RowKey changed to new implementation
7+
8+
7.0.0
9+
* Update dependencies: repace Microsoft.Azure.Cosmos.Table with Azure.Data.Tables
10+
111
6.0.0
212
* Updated dependencies: replace deprecated package WindowsAzure.Storage with Microsoft.Azure.Cosmos.Table 1.0.8
313
* Updated dependencies: Serilog 2.10.0

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,89 @@ In your application's `App.config` or `Web.config` file, specify the file sink a
5454
### Async approach
5555
It is possible to configure the collector using [Serilog.Sinks.Async](https://github.com/serilog/serilog-sinks-async) to have an async approach.
5656

57+
### Example Configuration for ASP.NET
58+
59+
```c#
60+
public static class Program
61+
{
62+
private const string OutputTemplate = "{Timestamp:HH:mm:ss.fff} [{Level:u1}] {Message:lj}{NewLine}{Exception}";
63+
64+
public static async Task<int> Main(string[] args)
65+
{
66+
// azure home directory
67+
var homeDirectory = Environment.GetEnvironmentVariable("HOME") ?? ".";
68+
var logDirectory = Path.Combine(homeDirectory, "LogFiles");
69+
70+
Log.Logger = new LoggerConfiguration()
71+
.MinimumLevel.Verbose()
72+
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
73+
.Enrich.FromLogContext()
74+
.WriteTo.Console(outputTemplate: OutputTemplate)
75+
.WriteTo.File(
76+
path: $"{logDirectory}/boot.txt",
77+
rollingInterval: RollingInterval.Day,
78+
shared: true,
79+
flushToDiskInterval: TimeSpan.FromSeconds(1),
80+
outputTemplate: OutputTemplate,
81+
retainedFileCountLimit: 10
82+
)
83+
.CreateBootstrapLogger();
84+
85+
try
86+
{
87+
Log.Information("Starting web host");
88+
89+
var builder = Microsoft.AspNetCore.Builder.WebApplication.CreateBuilder(args);
90+
91+
builder.Host
92+
.UseSerilog((context, services, configuration) => configuration
93+
.ReadFrom.Configuration(context.Configuration)
94+
.ReadFrom.Services(services)
95+
.Enrich.FromLogContext()
96+
.Enrich.WithProperty("ApplicationName", builder.Environment.ApplicationName)
97+
.Enrich.WithProperty("EnvironmentName", builder.Environment.EnvironmentName)
98+
.WriteTo.Console(outputTemplate: OutputTemplate)
99+
.WriteTo.File(
100+
path: $"{logDirectory}/log.txt",
101+
rollingInterval: RollingInterval.Day,
102+
shared: true,
103+
flushToDiskInterval: TimeSpan.FromSeconds(1),
104+
outputTemplate: OutputTemplate,
105+
retainedFileCountLimit: 10
106+
)
107+
.WriteTo.AzureTableStorage(
108+
connectionString: context.Configuration.GetConnectionString("StorageAccount"),
109+
propertyColumns: new[] { "SourceContext", "RequestId", "RequestPath", "ConnectionId", "ApplicationName", "EnvironmentName" }
110+
)
111+
);
112+
113+
ConfigureServices(builder);
114+
115+
var app = builder.Build();
116+
117+
ConfigureMiddleware(app);
118+
119+
await app.RunAsync();
120+
121+
return 0;
122+
}
123+
catch (Exception ex)
124+
{
125+
Log.Fatal(ex, "Host terminated unexpectedly");
126+
return 1;
127+
}
128+
finally
129+
{
130+
await Log.CloseAndFlushAsync();
131+
}
132+
}
133+
134+
private static void ConfigureServices(WebApplicationBuilder builder)
135+
{
136+
}
137+
138+
private static void ConfigureMiddleware(Microsoft.AspNetCore.Builder.WebApplication app)
139+
{
140+
}
141+
}
142+
```

serilog-sinks-azuretablestorage.sln

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Artifacts", "Artifacts", "{40D1EC3F-DCD9-47EB-8629-54D71AC31757}"
77
ProjectSection(SolutionItems) = preProject
88
.editorconfig = .editorconfig
9-
Build.ps1 = Build.ps1
109
.github\workflows\build.yml = .github\workflows\build.yml
1110
CHANGES.md = CHANGES.md
1211
README.md = README.md

src/Serilog.Sinks.AzureTableStorage/AzureTableStorageExtensions.cs

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)