Skip to content

Commit a83c52b

Browse files
committed
Update README.md
1 parent 72d4fa6 commit a83c52b

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

README.md

Lines changed: 16 additions & 17 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,7 +11,7 @@ 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`.
@@ -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,14 +90,14 @@ 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
100+
Along with standard properties for the event timestamp (`@t`), level (`@l`) and so on, "holes" in expression templates can include complex
102101
expressions over the first-class properties of the event, like `{SourceContex}` and `{Cart[0]}` in the example..
103102

104103
Templates support customizable color themes when used with the `Console` sink:
@@ -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.

0 commit comments

Comments
 (0)