Skip to content

Commit 7d86a4c

Browse files
authored
Merge pull request #54 from serilog/dev
3.2.1 Release
2 parents 1390311 + 3096f84 commit 7d86a4c

File tree

77 files changed

+287
-290
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+287
-290
lines changed

Build.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $commitHash = $(git rev-parse --short HEAD)
1616
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
1717

1818
echo "build: Package version suffix is $suffix"
19-
echo "build: Build version suffix is $buildSuffix"
19+
echo "build: Build version suffix is $buildSuffix"
2020

2121
foreach ($src in ls src/*) {
2222
Push-Location $src
@@ -30,7 +30,7 @@ foreach ($src in ls src/*) {
3030
} else {
3131
& dotnet pack -c Release --include-source --no-build -o ..\..\artifacts
3232
}
33-
if($LASTEXITCODE -ne 0) { exit 1 }
33+
if($LASTEXITCODE -ne 0) { exit 1 }
3434

3535
Pop-Location
3636
}

README.md

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# _Serilog Expressions_ [![Build status](https://ci.appveyor.com/api/projects/status/vmcskdk2wjn1rpps/branch/dev?svg=true)](https://ci.appveyor.com/project/serilog/serilog-expressions/branch/dev) [![NuGet Package](https://img.shields.io/nuget/vpre/serilog.expressions)](https://nuget.org/packages/serilog.expressions)
22

3-
An embeddable mini-language for filtering, enriching, and formatting Serilog
3+
An embeddable mini-language for filtering, enriching, and formatting Serilog
44
events, ideal for use with JSON or XML configuration.
55

66
## Getting started
@@ -11,14 +11,14 @@ Install the package from NuGet:
1111
dotnet add package Serilog.Expressions
1212
```
1313

14-
The package adds extension methods to Serilog's `Filter`, `WriteTo`, and
14+
The package adds extension methods to Serilog's `Filter`, `WriteTo`, and
1515
`Enrich` configuration objects, along with an `ExpressionTemplate`
1616
type that's compatible with Serilog sinks accepting an
1717
`ITextFormatter`.
1818

1919
### Filtering example
2020

21-
_Serilog.Expressions_ adds `ByExcluding()` and `ByIncludingOnly()`
21+
_Serilog.Expressions_ adds `ByExcluding()` and `ByIncludingOnly()`
2222
overloads to the `Filter` configuration object that accept filter
2323
expressions:
2424

@@ -38,8 +38,7 @@ in the package. To check expression syntax without throwing, see the
3838

3939
#### An `appSettings.json` JSON configuration example
4040

41-
In [`appSettings.json`
42-
configuration](https://github.com/serilog/serilog-settings-configuration)
41+
In [`appSettings.json` configuration](https://github.com/serilog/serilog-settings-configuration)
4342
this is written as:
4443

4544
```json
@@ -68,7 +67,7 @@ this is written as:
6867
<add key="serilog:using:Expressions" value="Serilog.Expressions" />
6968
<add key="serilog:filter:ByExcluding.expression" value="RequestPath like '/health%'" />
7069
</appSettings>
71-
```
70+
```
7271

7372
## Supported configuration APIs
7473

@@ -91,15 +90,15 @@ Log.Logger = new LoggerConfiguration()
9190
.WriteTo.Console(new ExpressionTemplate(
9291
"[{@t:HH:mm:ss} {@l:u3} ({SourceContext})] {@m} (first item is {Cart[0]})\n{@x}"))
9392
.CreateLogger();
94-
93+
9594
// Produces log events like:
9695
// [21:21:40 INF (Sample.Program)] Cart contains ["Tea","Coffee"] (first item is Tea)
9796
```
9897

9998
Templates are based on .NET format strings, and support standard padding, alignment, and format specifiers.
10099

101-
Along with standard properties for the event timestamp (`@t`), level (`@l`) and so on, "holes" in expression templates can include complex
102-
expressions over the first-class properties of the event, like `{SourceContex}` and `{Cart[0]}` in the example..
100+
Along with standard properties for the event timestamp (`@t`), level (`@l`) and so on, "holes" in expression templates can include complex
101+
expressions over the first-class properties of the event, like `{SourceContext}` and `{Cart[0]}` in the example..
103102

104103
Templates support customizable color themes when used with the `Console` sink:
105104

@@ -165,7 +164,7 @@ A typical set of operators is supported:
165164
* Indexers `a['b']` and `a[0]`
166165
* Wildcard indexing - `a[?]` any, and `a[*]` all
167166
* Conditional `if a then b else c` (all branches required; see also the section below on _conditional blocks_)
168-
167+
169168
Comparision operators that act on text all accept an optional postfix `ci` modifier to select case-insensitive comparisons:
170169

171170
```
@@ -176,7 +175,7 @@ User.Name like 'n%' ci
176175

177176
Functions are called using typical `Identifier(args)` syntax.
178177

179-
Except for the `IsDefined()` function, the result of
178+
Except for the `IsDefined()` function, the result of
180179
calling a function will be undefined if:
181180

182181
* any argument is undefined, or
@@ -223,10 +222,10 @@ Log.Logger = new LoggerConfiguration()
223222
.WriteTo.Console(new ExpressionTemplate(
224223
"[{@t:HH:mm:ss} {@l:u3}{#if SourceContext is not null} ({SourceContext}){#end}] {@m}\n{@x}"))
225224
.CreateLogger();
226-
225+
227226
// Produces log events like:
228227
// [21:21:45 INF] Starting up
229-
// [21:21:46 INF (Sample.Program)] Firing engines
228+
// [21:21:46 INF (Sample.Program)] Firing engines
230229
```
231230

232231
The block between the `{#if <expr>}` and `{#end}` directives will only appear in the output if `<expr>` is `true` - in the example, events with a `SourceContext` include this in parentheses, while those without, don't.
@@ -302,7 +301,7 @@ ElementAt(@p, 'someName') ci
302301
{ {Timestamp: @t, Username: User.Name} }\n
303302
```
304303

305-
This output template shows the use of a space between the opening `{` of a hole, and the enclosed object literal with `Timestamp` and
304+
This output template shows the use of a space between the opening `{` of a hole, and the enclosed object literal with `Timestamp` and
306305
`Username` fields. The object will be formatted as JSON. The trailing `\n` is a C# or JSON newline literal (don't escape this any further, as
307306
it's not part of the output template syntax).
308307

@@ -336,8 +335,8 @@ else
336335
Compiled expression delegates return `LogEventPropertyValue` because this is the most
337336
convenient type to work with in many Serilog scenarios (enrichers, sinks, ...). To
338337
convert the result to plain-old-.NET-types like `string`, `bool`, `Dictionary<K,V>` and
339-
`Array`, use the functions in the `Serilog.Expressions.ExpressionResult` class:
340-
338+
`Array`, use the functions in the `Serilog.Expressions.ExpressionResult` class:
339+
341340
```csharp
342341
var result = compiled(someEvent);
343342

@@ -356,12 +355,12 @@ User-defined functions can be plugged in by implementing static methods that:
356355
* Have arguments of type `LogEventPropertyValue?` or `LogEvent`,
357356
* If the `ci` modifier is supported, accept a `StringComparison`, and
358357
* If culture-specific formatting or comparisons are used, accepts an `IFormatProvider`.
359-
358+
360359
For example:
361360

362361
```csharp
363362
public static class MyFunctions
364-
{
363+
{
365364
public static LogEventPropertyValue? IsHello(
366365
StringComparison comparison,
367366
LogEventPropertyValue? maybeHello)
@@ -388,5 +387,5 @@ var expr = SerilogExpression.Compile("IsHello(User.Name)", new[] { myFunctions }
388387

389388
## Acknowledgements
390389

391-
Includes the parser combinator implementation from [Superpower](https://github.com/datalust/superpower), copyright Datalust,
390+
Includes the parser combinator implementation from [Superpower](https://github.com/datalust/superpower), copyright Datalust,
392391
Superpower Contributors, and Sprache Contributors; licensed under the Apache License, 2.0.

example/Sample/Program.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ static void TextFormattingExample1()
3232
.CreateLogger();
3333

3434
log.Information("Running {Example}", nameof(TextFormattingExample1));
35-
35+
3636
log.ForContext<Program>()
3737
.Information("Cart contains {@Items}", new[] { "Tea", "Coffee" });
38-
38+
3939
log.ForContext<Program>()
4040
.Information("Cart contains {@Items}", new[] { "Apricots" });
4141
}
@@ -49,10 +49,10 @@ static void JsonFormattingExample()
4949
.CreateLogger();
5050

5151
log.Information("Running {Example}", nameof(JsonFormattingExample));
52-
52+
5353
log.ForContext<Program>()
5454
.Information("Cart contains {@Items}", new[] { "Tea", "Coffee" });
55-
55+
5656
log.ForContext<Program>()
5757
.Warning("Cart is empty");
5858
}
@@ -67,20 +67,20 @@ static void PipelineComponentExample()
6767
.WriteTo.Console(outputTemplate:
6868
"[{Timestamp:HH:mm:ss} {Level:u3} ({SourceContext})] {Message:lj} (first item is {FirstItem}){NewLine}{Exception}")
6969
.CreateLogger();
70-
70+
7171
log.Information("Running {Example}", nameof(PipelineComponentExample));
72-
72+
7373
log.ForContext<Program>()
7474
.Information("Cart contains {@Items}", new[] { "Tea", "Coffee" });
75-
75+
7676
log.ForContext<Program>()
7777
.Information("Cart contains {@Items}", new[] { "Apricots" });
7878
}
79-
79+
8080
static void TextFormattingExample2()
8181
{
8282
// Emulates `Microsoft.Extensions.Logging`'s `ConsoleLogger`.
83-
83+
8484
var melon = new TemplateTheme(TemplateTheme.Literate, new Dictionary<TemplateThemeStyle, string>
8585
{
8686
// `Information` is dark green in MEL.
@@ -102,11 +102,11 @@ static void TextFormattingExample2()
102102

103103
var program = log.ForContext<Program>();
104104
program.Information("Host listening at {ListenUri}", "https://hello-world.local");
105-
105+
106106
program
107107
.ForContext("Scope", new[] {"Main", "TextFormattingExample2()"})
108108
.Information("HTTP {Method} {Path} responded {StatusCode} in {Elapsed:0.000} ms", "GET", "/api/hello", 200, 1.23);
109-
109+
110110
program.Warning("We've reached the end of the line");
111111
}
112112
}

src/Serilog.Expressions/Expressions/Ast/CallExpression.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public CallExpression(bool ignoreCase, string operatorName, params Expression[]
2727
}
2828

2929
public bool IgnoreCase { get; }
30-
30+
3131
public string OperatorName { get; }
3232

3333
public Expression[] Operands { get; }

src/Serilog.Expressions/Expressions/Ast/ConstantExpression.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
using Serilog.Events;
1818

1919
namespace Serilog.Expressions.Ast
20-
{
20+
{
2121
class ConstantExpression : Expression
2222
{
2323
public ConstantExpression(LogEventPropertyValue constant)
@@ -26,7 +26,7 @@ public ConstantExpression(LogEventPropertyValue constant)
2626
}
2727

2828
public LogEventPropertyValue Constant { get; }
29-
29+
3030
public override string ToString()
3131
{
3232
if (Constant is ScalarValue sv)

src/Serilog.Expressions/Expressions/Ast/ObjectExpression.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public ObjectExpression(Member[] members)
2222
{
2323
Members = members;
2424
}
25-
25+
2626
public Member[] Members { get; }
2727

2828
public override string ToString()

src/Serilog.Expressions/Expressions/Ast/PropertyMember.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public PropertyMember(string name, Expression value)
2626
Name = name;
2727
Value = value;
2828
}
29-
29+
3030
public override string ToString()
3131
{
3232
return $"{new ScalarValue(Name)}: {Value}";

src/Serilog.Expressions/Expressions/Compilation/Arrays/ConstantArrayEvaluator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace Serilog.Expressions.Compilation.Arrays
2222
class ConstantArrayEvaluator : IdentityTransformer
2323
{
2424
static readonly ConstantArrayEvaluator Instance = new ConstantArrayEvaluator();
25-
25+
2626
public static Expression Evaluate(Expression expression)
2727
{
2828
return Instance.Transform(expression);

src/Serilog.Expressions/Expressions/Compilation/ExpressionCompiler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static Expression Translate(Expression expression)
3636
actual = WildcardComprehensionTransformer.Expand(actual);
3737
return actual;
3838
}
39-
39+
4040
public static Evaluatable Compile(Expression expression, IFormatProvider? formatProvider,
4141
NameResolver nameResolver)
4242
{

src/Serilog.Expressions/Expressions/Compilation/Linq/ExpressionConstantMapper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public ExpressionConstantMapper(IDictionary<object, Expression> mapping)
2929

3030
protected override Expression VisitConstant(ConstantExpression node)
3131
{
32-
if (node.Value != null &&
32+
if (node.Value != null &&
3333
node.Value is ScalarValue sv &&
3434
_mapping.TryGetValue(sv.Value, out var substitute))
3535
return substitute;

0 commit comments

Comments
 (0)