This repository has been archived by the owner on Feb 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from serilog/dev
1.0.0 Release
- Loading branch information
Showing
82 changed files
with
3,988 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Auto detect text files and perform LF normalization | ||
|
||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
echo "build: Build started" | ||
|
||
Push-Location $PSScriptRoot | ||
|
||
if(Test-Path .\artifacts) { | ||
echo "build: Cleaning .\artifacts" | ||
Remove-Item .\artifacts -Force -Recurse | ||
} | ||
|
||
& dotnet restore --no-cache | ||
|
||
$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.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"] | ||
|
||
echo "build: Version suffix is $suffix" | ||
|
||
foreach ($src in ls src/*) { | ||
Push-Location $src | ||
|
||
echo "build: Packaging project in $src" | ||
|
||
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix | ||
if($LASTEXITCODE -ne 0) { exit 1 } | ||
|
||
Pop-Location | ||
} | ||
|
||
foreach ($test in ls test/*.PerformanceTests) { | ||
Push-Location $test | ||
|
||
echo "build: Building performance test project in $test" | ||
|
||
& dotnet build -c Release | ||
if($LASTEXITCODE -ne 0) { exit 2 } | ||
|
||
Pop-Location | ||
} | ||
|
||
foreach ($test in ls test/*.Tests) { | ||
Push-Location $test | ||
|
||
echo "build: Testing project in $test" | ||
|
||
& dotnet test -c Release | ||
if($LASTEXITCODE -ne 0) { exit 3 } | ||
|
||
Pop-Location | ||
} | ||
|
||
Pop-Location |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,61 @@ | ||
# Serilog.Filters.Expressions | ||
Expression-based event filtering for Serilog. | ||
# Serilog.Filters.Expressions [![Build status](https://ci.appveyor.com/api/projects/status/wnh0ig2udlld9oe4?svg=true)](https://ci.appveyor.com/project/serilog/serilog-filters-expressions) [![NuGet Pre Release](https://img.shields.io/nuget/vpre/Serilog.Filters.Expressions.svg)](https://nuget.org/packages/serilog.filters.expressions) | ||
|
||
Expression-based event filtering for [Serilog](https://serilog.net). | ||
|
||
```csharp | ||
var expr = "@Level = 'Information' and AppId is not null and Items[?] like 'C%'"; | ||
|
||
Log.Logger = new LoggerConfiguration() | ||
.Enrich.WithProperty("AppId", 10) | ||
.Filter.ByIncludingOnly(expr) | ||
.WriteTo.LiterateConsole() | ||
.CreateLogger(); | ||
|
||
// Printed | ||
Log.Information("Cart contains {@Items}", new[] { "Tea", "Coffee" }); | ||
Log.Information("Cart contains {@Items}", new[] { "Peanuts", "Chocolate" }); | ||
|
||
// Not printed | ||
Log.Warning("Cart contains {@Items}", new[] { "Tea", "Coffee" }); | ||
Log.Information("Cart contains {@Items}", new[] { "Apricots" }); | ||
|
||
Log.CloseAndFlush(); | ||
``` | ||
|
||
### Getting started | ||
|
||
Install _Serilog.Filters.Expressions_ from NuGet: | ||
|
||
```powershell | ||
Install-Package Serilog.Filters.Expressions -Pre | ||
``` | ||
|
||
Add `Filter.ByIncludingOnly(fiterExpression)` or `Filter.ByExcluding(fiterExpression)` calls to `LoggerConfiguration`. | ||
|
||
### Syntax | ||
|
||
The syntax is based on SQL, with added support for object structures, arrays, and regular expressions. | ||
|
||
| Category | Examples | | ||
| :--- | :--- | | ||
| **Literals** | `123`, `123.4`, `'Hello'`, `true`, `false`, `null` | | ||
| **Properties** | `A`, `A.B`, `@Level`, `@Timestamp`, `@Exception`, `@Message`, `@MessageTemplate`, `@Properties['A-b-c']` | | ||
| **Comparisons** | `A = B`, `A <> B`, `A > B`, `A >= B`, `A is null`, `A is not null` | | ||
| **Text** | `A like 'H%'`, `A not like 'H%'`, `A like 'Hel_o'`, `Contains(A, 'H')`, `StartsWith(A, 'H')`, `EndsWith(A, 'H')`, `IndexOf(A, 'H')` | | ||
| **Regular expressions** | `A = /H.*o/`, `Contains(A, /[lL]/)`, other string functions | | ||
| **Collections** | `A[0] = 'Hello'`, `A[?] = 'Hello'` (any), `StartsWith(A[*], 'H')` (all) | | ||
| **Maths** | `A + 2`, `A - 2`, `A * 2`, `A % 2` | | ||
| **Logic** | `not A`, `A and B`, `A or B` | | ||
| **Grouping** | `A * (B + C)` | | ||
| **Other** | `Has(A)`, `TypeOf(A)` | | ||
|
||
### XML configuration | ||
|
||
**Note, the syntax below depends on [an unreleased Serilog version](https://github.com/serilog/serilog/pull/925).** | ||
|
||
```xml | ||
<add key="serilog:using:FilterExpressions" value="Serilog.Filters.Expressions" /> | ||
<add key="serilog:Filter:ByExcluding.expression" value="Name = 'World'" /> | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Push-Location $PSScriptRoot | ||
|
||
./Build.ps1 | ||
|
||
foreach ($test in ls test/*.PerformanceTests) { | ||
Push-Location $test | ||
|
||
echo "perf: Running performance test project in $test" | ||
|
||
& dotnet test -c Release | ||
if($LASTEXITCODE -ne 0) { exit 2 } | ||
|
||
Pop-Location | ||
} | ||
|
||
Pop-Location |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
version: '{build}' | ||
skip_tags: true | ||
image: Visual Studio 2015 | ||
configuration: Release | ||
install: | ||
- ps: mkdir -Force ".\build\" | Out-Null | ||
- ps: Invoke-WebRequest "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0-preview2/scripts/obtain/dotnet-install.ps1" -OutFile ".\build\installcli.ps1" | ||
- ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetcli" | ||
- ps: '& .\build\installcli.ps1 -InstallDir "$env:DOTNET_INSTALL_DIR" -NoPath -Version 1.0.0-preview2-003131' | ||
- ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path" | ||
build_script: | ||
- ps: ./Build.ps1 | ||
test: off | ||
artifacts: | ||
- path: artifacts/Serilog.*.nupkg | ||
deploy: | ||
- provider: NuGet | ||
api_key: | ||
secure: nvZ/z+pMS91b3kG4DgfES5AcmwwGoBYQxr9kp4XiJHj25SAlgdIxFx++1N0lFH2x | ||
skip_symbols: true | ||
on: | ||
branch: /^(master|dev)$/ | ||
- provider: GitHub | ||
auth_token: | ||
secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX | ||
artifact: /Serilog.*\.nupkg/ | ||
tag: v$(appveyor_build_version) | ||
on: | ||
branch: master |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Serilog; | ||
|
||
namespace Sample | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
var expr = "@Level = 'Information' and AppId is not null and Items[?] like 'C%'"; | ||
|
||
Log.Logger = new LoggerConfiguration() | ||
.Enrich.WithProperty("AppId", 10) | ||
.Filter.ByIncludingOnly(expr) | ||
.WriteTo.LiterateConsole() | ||
.CreateLogger(); | ||
|
||
Log.Information("Cart contains {@Items}", new[] { "Tea", "Coffee" }); | ||
Log.Warning("Cart contains {@Items}", new[] { "Tea", "Coffee" }); | ||
Log.Information("Cart contains {@Items}", new[] { "Apricots" }); | ||
Log.Information("Cart contains {@Items}", new[] { "Peanuts", "Chocolate" }); | ||
|
||
Log.CloseAndFlush(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("Sample")] | ||
[assembly: AssemblyTrademark("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("776eecac-3c50-45ea-847d-0ebe5158e51e")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
</PropertyGroup> | ||
|
||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>776eecac-3c50-45ea-847d-0ebe5158e51e</ProjectGuid> | ||
<RootNamespace>Sample</RootNamespace> | ||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> | ||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> | ||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
</PropertyGroup> | ||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"version": "1.0.0-*", | ||
"buildOptions": { | ||
"emitEntryPoint": true | ||
}, | ||
|
||
"dependencies": { | ||
"Microsoft.NETCore.App": { | ||
"type": "platform", | ||
"version": "1.0.1" | ||
}, | ||
"Serilog.Filters.Expressions": {"target": "project"}, | ||
"Serilog": "2.3.0", | ||
"Serilog.Sinks.Literate": "2.0.0", | ||
"Superpower": "1.0.0" | ||
}, | ||
|
||
"frameworks": { | ||
"netcoreapp1.0": { | ||
"imports": "dnxcore50" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"projects": [ "src", "test", "example" ], | ||
"sdk": { | ||
"version": "1.0.0-preview2-003131" | ||
} | ||
} |
Oops, something went wrong.