Skip to content

Commit 6bce34b

Browse files
authored
Merge pull request #16 from serilog/dev
1.0.0 Release
2 parents 00b0c70 + 1bd6af4 commit 6bce34b

Some content is hidden

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

54 files changed

+2376
-2
lines changed

Build.ps1

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
echo "build: Build started"
2+
3+
Push-Location $PSScriptRoot
4+
5+
if(Test-Path .\artifacts) {
6+
echo "build: Cleaning .\artifacts"
7+
Remove-Item .\artifacts -Force -Recurse
8+
}
9+
10+
& dotnet restore --no-cache
11+
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 "main" -and $revision -ne "local"]
15+
$commitHash = $(git rev-parse --short HEAD)
16+
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
17+
18+
echo "build: Package version suffix is $suffix"
19+
echo "build: Build version suffix is $buildSuffix"
20+
21+
foreach ($src in ls src/*) {
22+
Push-Location $src
23+
24+
echo "build: Packaging project in $src"
25+
26+
& dotnet build -c Release --version-suffix=$buildSuffix
27+
28+
if($suffix) {
29+
& dotnet pack -c Release --no-build -o ..\..\artifacts --version-suffix=$suffix
30+
} else {
31+
& dotnet pack -c Release --no-build -o ..\..\artifacts
32+
}
33+
if($LASTEXITCODE -ne 0) { exit 1 }
34+
35+
Pop-Location
36+
}
37+
38+
foreach ($test in ls test/*.Tests) {
39+
Push-Location $test
40+
41+
echo "build: Testing project in $test"
42+
43+
& dotnet test -c Release
44+
if($LASTEXITCODE -ne 0) { exit 3 }
45+
46+
Pop-Location
47+
}
48+
49+
Pop-Location

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,25 @@
1-
# serilog-sinks-browserconsole
2-
A console sink for the Blazor/WASM environment
1+
# Serilog.Sinks.BrowserConsole [![Build status](https://ci.appveyor.com/api/projects/status/s458q719m2pfwnyk?svg=true)](https://ci.appveyor.com/project/serilog/serilog-sinks-browserconsole) [![NuGet Pre Release](https://img.shields.io/nuget/vpre/Serilog.Sinks.BrowserConsole.svg)](https://nuget.org/packages/Serilog.Sinks.BrowserConsole)
2+
3+
A console sink for the Blazor/Wasm environment.
4+
5+
### What's it do?
6+
7+
The sink writes log events to the browser console. Unlike the normal Serilog console sink, which writes out formatted text, this sink takes advantage of the unique capabilities of the browser console to print interactive, fully-structured data.
8+
9+
![Serilog.Sinks.BrowserConsole](https://raw.githubusercontent.com/serilog/serilog-sinks-browserconsole/dev/assets/Screenshot.png)
10+
11+
### Getting started
12+
13+
Configure the logging pipeline in `Program.Main()`:
14+
15+
```csharp
16+
// dotnet add package Serilog.Sinks.BrowserConsole -v ...
17+
18+
Log.Logger = new LoggerConfiguration()
19+
.WriteTo.BrowserConsole()
20+
.CreateLogger();
21+
22+
Log.Information("Hello, browser!");
23+
```
24+
25+
A more detailed example is available [in this repository](https://github.com/serilog/serilog-sinks-browserconsole/tree/dev/example/ExampleClient).

appveyor.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: '{build}'
2+
skip_tags: true
3+
image: Visual Studio 2019
4+
configuration: Release
5+
test: off
6+
build_script:
7+
- ps: ./Build.ps1
8+
artifacts:
9+
- path: artifacts/Serilog.*.nupkg
10+
deploy:
11+
- provider: NuGet
12+
api_key:
13+
secure: rbdBqxBpLt4MkB+mrDOYNDOd8aVZ1zMkysaVNAXNKnC41FYifzX3l9LM8DCrUWU5
14+
skip_symbols: true
15+
on:
16+
branch: /^(main|dev)$/
17+
- provider: GitHub
18+
auth_token:
19+
secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
20+
artifact: /Serilog.*\.nupkg/
21+
tag: v$(appveyor_build_version)
22+
on:
23+
branch: main

assets/Screenshot.png

121 KB
Loading

assets/icon.png

19.9 KB
Loading

example/ExampleClient/App.razor

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Router AppAssembly="@typeof(Program).Assembly">
2+
<Found Context="routeData">
3+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
4+
</Found>
5+
<NotFound>
6+
<LayoutView Layout="@typeof(MainLayout)">
7+
<p>Sorry, there's nothing at this address.</p>
8+
</LayoutView>
9+
</NotFound>
10+
</Router>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net5.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.0-rc.1.*" />
9+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.0-rc.1.*" />
10+
<PackageReference Include="System.Net.Http.Json" Version="5.0.0-rc.1.*" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<ProjectReference Include="..\..\src\Serilog.Sinks.BrowserConsole\Serilog.Sinks.BrowserConsole.csproj" />
15+
</ItemGroup>
16+
17+
</Project>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
@using Serilog
2+
@page "/counter"
3+
4+
<h1>Counter</h1>
5+
6+
<p>Current count: @currentCount</p>
7+
8+
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
9+
10+
@code {
11+
int currentCount = 0;
12+
13+
void IncrementCount()
14+
{
15+
currentCount++;
16+
17+
if (currentCount < 5)
18+
Log.ForContext<Counter>().Information("Incremented count to {CurrentCount}", currentCount);
19+
else
20+
try
21+
{
22+
throw new NotSupportedException("Too many clicks!");
23+
}
24+
catch (Exception ex)
25+
{
26+
Log.Error(ex, "Failed at {CurrentCount}", currentCount);
27+
}
28+
}
29+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
@page "/fetchdata"
2+
@inject HttpClient _http
3+
4+
<h1>Weather forecast</h1>
5+
6+
<p>This component demonstrates fetching data from the server.</p>
7+
8+
@if (forecasts == null)
9+
{
10+
<p><em>Loading...</em></p>
11+
}
12+
else
13+
{
14+
<table class="table">
15+
<thead>
16+
<tr>
17+
<th>Date</th>
18+
<th>Temp. (C)</th>
19+
<th>Temp. (F)</th>
20+
<th>Summary</th>
21+
</tr>
22+
</thead>
23+
<tbody>
24+
@foreach (var forecast in forecasts)
25+
{
26+
<tr>
27+
<td>@forecast.Date.ToShortDateString()</td>
28+
<td>@forecast.TemperatureC</td>
29+
<td>@forecast.TemperatureF</td>
30+
<td>@forecast.Summary</td>
31+
</tr>
32+
}
33+
</tbody>
34+
</table>
35+
}
36+
37+
@code {
38+
WeatherForecast[] forecasts;
39+
40+
protected override async Task OnInitializedAsync()
41+
{
42+
forecasts = await _http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
43+
}
44+
45+
public class WeatherForecast
46+
{
47+
public DateTime Date { get; set; }
48+
49+
public int TemperatureC { get; set; }
50+
51+
public string Summary { get; set; }
52+
53+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
54+
}
55+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@page "/"
2+
3+
<h1>Hello, world!</h1>
4+
5+
Welcome to your new app.
6+
7+
<SurveyPrompt Title="How is Blazor working for you?" />

0 commit comments

Comments
 (0)