Skip to content

Commit 2889d14

Browse files
committed
Preview8 support
1 parent 675bf5b commit 2889d14

File tree

6 files changed

+155
-155
lines changed

6 files changed

+155
-155
lines changed

README.md

Lines changed: 91 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,91 @@
1-
[![Build status](https://dotnet-ci.visualstudio.com/DotnetCI/_apis/build/status/Blazor-Extensions-Logging-CI?branch=master)](https://dotnet-ci.visualstudio.com/DotnetCI/_build/latest?definitionId=10&branch=master)
2-
[![Package Version](https://img.shields.io/nuget/v/Blazor.Extensions.Logging.svg)](https://www.nuget.org/packages/Blazor.Extensions.Logging)
3-
[![NuGet Downloads](https://img.shields.io/nuget/dt/Blazor.Extensions.Logging.svg)](https://www.nuget.org/packages/Blazor.Extensions.Logging)
4-
[![License](https://img.shields.io/github/license/BlazorExtensions/Logging.svg)](https://github.com/BlazorExtensions/Logging/blob/master/LICENSE)
5-
6-
# Blazor Extensions
7-
8-
Blazor Extensions is a set of packages with the goal of adding useful features to [Blazor](https://blazor.net).
9-
10-
# Blazor Extensions Logging
11-
12-
This package is an implementation for the [Microsoft Extensions Logging](https://github.com/aspnet/Logging) abstraction to support
13-
using the ```ILogger``` interface in your Blazor code.
14-
15-
When the component is configured, all the log statements will appear in the browser's developer tools console.
16-
17-
# Features
18-
19-
## Content to log
20-
21-
The logger supports the same string formatting that MEL provides, together with named parameter replacement in the message.
22-
23-
Additionaly, you're able to log an object in the browser console. You can expand members and hierachies to see what's contained within.
24-
25-
If you want to log an enumerable list of objects, then the browser side component will display it by calling ```console.table```.
26-
27-
## Filtering
28-
29-
The implementation supports the ```ILoggerFactory```-based filtering configuration that is supplied by the Microsoft Extension Logging abstraction.
30-
31-
To keep it lightweight, [Microsoft Extensions Configuration](https://github.com/aspnet/Configuration) based configuration is not supported; the logger can be only configured in code.
32-
33-
## Log levels
34-
35-
The logger supports the [LogLevels](https://github.com/aspnet/Logging/blob/master/src/Microsoft.Extensions.Logging.Abstractions/LogLevel.cs) defined in MEL.
36-
37-
Some of the log levels are not available as distinct methods in the browser's developer tool, so the browser side component does some [mapping](https://github.com/BlazorExtensions/Logging/blob/master/src/Blazor.Extensions.Logging.JS/src/Initialize.ts#L35).
38-
39-
# Sample configuration
40-
41-
## Setup
42-
43-
The following snippet shows how to setup the browser console logger by registering it for dependency injection in the ```Startup.cs``` of the application.
44-
45-
```c#
46-
public void ConfigureServices(IServiceCollection services)
47-
{
48-
services.AddLogging(builder => builder
49-
.AddBrowserConsole() // Add Blazor.Extensions.Logging.BrowserConsoleLogger
50-
.SetMinimumLevel(LogLevel.Trace)
51-
);
52-
}
53-
```
54-
55-
## Usage
56-
57-
The following snippet shows how to consume the logger in a Blazor component.
58-
59-
```c#
60-
@inject ILogger<Index> logger
61-
62-
@functions {
63-
protected override async Task OnInitAsync()
64-
{
65-
logger.LogDebug("MyComponent init");
66-
}
67-
}
68-
```
69-
70-
If you want to consume it outside of a ```cshtml``` based component, then you can use the ```Inject``` attribute to inject it into the class.
71-
72-
```c#
73-
[Inject]
74-
protected ILogger<MyClass> Logger {get;set;}
75-
76-
public void LogSomething()
77-
{
78-
Logger.LogDebug("Inside LogSomething");
79-
}
80-
```
81-
82-
# Contributions and feedback
83-
84-
Please feel free to use the component, open issues, fix bugs or provide feedback.
85-
86-
# Contributors
87-
88-
The following people are the maintainers of the Blazor Extensions projects:
89-
90-
- [Attila Hajdrik](https://github.com/attilah)
91-
- [Gutemberg Ribiero](https://github.com/galvesribeiro)
1+
[![Build status](https://dotnet-ci.visualstudio.com/DotnetCI/_apis/build/status/Blazor-Extensions-Logging-CI?branch=master)](https://dotnet-ci.visualstudio.com/DotnetCI/_build/latest?definitionId=10&branch=master)
2+
[![Package Version](https://img.shields.io/nuget/v/Blazor.Extensions.Logging.svg)](https://www.nuget.org/packages/Blazor.Extensions.Logging)
3+
[![NuGet Downloads](https://img.shields.io/nuget/dt/Blazor.Extensions.Logging.svg)](https://www.nuget.org/packages/Blazor.Extensions.Logging)
4+
[![License](https://img.shields.io/github/license/BlazorExtensions/Logging.svg)](https://github.com/BlazorExtensions/Logging/blob/master/LICENSE)
5+
6+
# Blazor Extensions
7+
8+
Blazor Extensions is a set of packages with the goal of adding useful features to [Blazor](https://blazor.net).
9+
10+
# Blazor Extensions Logging
11+
12+
This package is an implementation for the [Microsoft Extensions Logging](https://github.com/aspnet/Logging) abstraction to support
13+
using the ```ILogger``` interface in your Blazor code.
14+
15+
When the component is configured, all the log statements will appear in the browser's developer tools console.
16+
17+
# Features
18+
19+
## Content to log
20+
21+
The logger supports the same string formatting that MEL provides, together with named parameter replacement in the message.
22+
23+
Additionaly, you're able to log an object in the browser console. You can expand members and hierachies to see what's contained within.
24+
25+
If you want to log an enumerable list of objects, then the browser side component will display it by calling ```console.table```.
26+
27+
## Filtering
28+
29+
The implementation supports the ```ILoggerFactory```-based filtering configuration that is supplied by the Microsoft Extension Logging abstraction.
30+
31+
To keep it lightweight, [Microsoft Extensions Configuration](https://github.com/aspnet/Configuration) based configuration is not supported; the logger can be only configured in code.
32+
33+
## Log levels
34+
35+
The logger supports the [LogLevels](https://github.com/aspnet/Logging/blob/master/src/Microsoft.Extensions.Logging.Abstractions/LogLevel.cs) defined in MEL.
36+
37+
Some of the log levels are not available as distinct methods in the browser's developer tool, so the browser side component does some [mapping](https://github.com/BlazorExtensions/Logging/blob/master/src/Blazor.Extensions.Logging.JS/src/Initialize.ts#L35).
38+
39+
# Sample configuration
40+
41+
## Setup
42+
43+
The following snippet shows how to setup the browser console logger by registering it for dependency injection in the ```Startup.cs``` of the application.
44+
45+
```c#
46+
public void ConfigureServices(IServiceCollection services)
47+
{
48+
services.AddLogging(builder => builder
49+
.AddBrowserConsole() // Add Blazor.Extensions.Logging.BrowserConsoleLogger
50+
.SetMinimumLevel(LogLevel.Trace)
51+
);
52+
}
53+
```
54+
55+
## Usage
56+
57+
The following snippet shows how to consume the logger in a Blazor component.
58+
59+
```c#
60+
@inject ILogger<Index> logger
61+
62+
@functions {
63+
protected override async Task OnInitializedAsync()
64+
{
65+
logger.LogDebug("MyComponent init");
66+
}
67+
}
68+
```
69+
70+
If you want to consume it outside of a ```cshtml``` based component, then you can use the ```Inject``` attribute to inject it into the class.
71+
72+
```c#
73+
[Inject]
74+
protected ILogger<MyClass> Logger {get;set;}
75+
76+
public void LogSomething()
77+
{
78+
Logger.LogDebug("Inside LogSomething");
79+
}
80+
```
81+
82+
# Contributions and feedback
83+
84+
Please feel free to use the component, open issues, fix bugs or provide feedback.
85+
86+
# Contributors
87+
88+
The following people are the maintainers of the Blazor Extensions projects:
89+
90+
- [Attila Hajdrik](https://github.com/attilah)
91+
- [Gutemberg Ribiero](https://github.com/galvesribeiro)
Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
2-
3-
<PropertyGroup>
4-
<OutputType>Library</OutputType>
5-
<IsPackable>false</IsPackable>
6-
<BlazorLinkOnBuild>false</BlazorLinkOnBuild>
7-
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
8-
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
9-
<DefaultItemExcludes>${DefaultItemExcludes};dist\**;node_modules\**</DefaultItemExcludes>
10-
<NoWarn>CS2008</NoWarn>
11-
12-
<!-- VS's FastUpToDateCheck doesn't consider .ts file changes, so it's necessary to disable it to get incremental builds to work correctly (albeit not as fast as if FastUpToDateCheck did work for them) -->
13-
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
14-
</PropertyGroup>
15-
16-
<ItemGroup>
17-
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview7.19365.7" PrivateAssets="all" />
18-
<WebpackInputs Include="**\*.ts" Exclude="dist\**;node_modules\**" />
19-
</ItemGroup>
20-
21-
<Target Name="EnsureNpmRestored" Condition="!Exists('node_modules')">
22-
<Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
23-
<Exec Command="npm install" />
24-
</Target>
25-
26-
<Target Name="RunWebpack" AfterTargets="ResolveReferences" Inputs="@(WebpackInputs)" Outputs="dist\blazor.extensions.logging.js" DependsOnTargets="EnsureNpmRestored">
27-
<RemoveDir Directories="dist" />
28-
<Exec Command="npm run build" />
29-
<ItemGroup>
30-
<EmbeddedResource Include="dist\**\*.js" LogicalName="blazor:js:%(RecursiveDir)%(Filename)%(Extension)" />
31-
</ItemGroup>
32-
</Target>
33-
</Project>
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<OutputType>Library</OutputType>
5+
<IsPackable>false</IsPackable>
6+
<BlazorLinkOnBuild>false</BlazorLinkOnBuild>
7+
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
8+
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
9+
<DefaultItemExcludes>${DefaultItemExcludes};dist\**;node_modules\**</DefaultItemExcludes>
10+
<NoWarn>CS2008</NoWarn>
11+
12+
<!-- VS's FastUpToDateCheck doesn't consider .ts file changes, so it's necessary to disable it to get incremental builds to work correctly (albeit not as fast as if FastUpToDateCheck did work for them) -->
13+
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
14+
</PropertyGroup>
15+
16+
<ItemGroup>
17+
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview8.19405.7" PrivateAssets="all" />
18+
<WebpackInputs Include="**\*.ts" Exclude="dist\**;node_modules\**" />
19+
</ItemGroup>
20+
21+
<Target Name="EnsureNpmRestored" Condition="!Exists('node_modules')">
22+
<Message Importance="high" Text="Restoring dependencies using 'npm'. This may take several minutes..." />
23+
<Exec Command="npm install" />
24+
</Target>
25+
26+
<Target Name="RunWebpack" AfterTargets="ResolveReferences" Inputs="@(WebpackInputs)" Outputs="dist\blazor.extensions.logging.js" DependsOnTargets="EnsureNpmRestored">
27+
<RemoveDir Directories="dist" />
28+
<Exec Command="npm run build" />
29+
<ItemGroup>
30+
<EmbeddedResource Include="dist\**\*.js" LogicalName="blazor:js:%(RecursiveDir)%(Filename)%(Extension)" />
31+
</ItemGroup>
32+
</Target>
33+
</Project>

src/Blazor.Extensions.Logging/Blazor.Extensions.Logging.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77

88
<PropertyGroup>
99
<TargetFramework>netstandard2.0</TargetFramework>
10-
<IsPackable>true</IsPackable>
10+
<IsPackable>true</IsPackable>
1111
<LangVersion>7.3</LangVersion>
1212
<RazorLangVersion>3.0</RazorLangVersion>
1313
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
1414
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);IncludeP2POutput</TargetsForTfmSpecificBuildOutput>
1515
</PropertyGroup>
1616

1717
<ItemGroup>
18-
<PackageReference Include="Microsoft.AspNetCore.Components.Browser" Version="3.0.0-preview7.19365.7" />
18+
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.0.0-preview8.19405.7" />
1919
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.0.0-preview7.19362.4" />
2020
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
2121
</ItemGroup>
Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
2-
3-
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
5-
<LangVersion>7.3</LangVersion>
6-
<RazorLangVersion>3.0</RazorLangVersion>
7-
</PropertyGroup>
8-
9-
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview7.19365.7" />
11-
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview7.19365.7" PrivateAssets="all" />
12-
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.0.0-preview7.19365.7" PrivateAssets="all" />
13-
</ItemGroup>
14-
15-
<ItemGroup>
16-
<ProjectReference Include="..\..\src\Blazor.Extensions.Logging.JS\Blazor.Extensions.Logging.JS.csproj" />
17-
<ProjectReference Include="..\..\src\Blazor.Extensions.Logging\Blazor.Extensions.Logging.csproj" />
18-
</ItemGroup>
19-
20-
</Project>
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<LangVersion>7.3</LangVersion>
6+
<RazorLangVersion>3.0</RazorLangVersion>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview8.19405.7" />
11+
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview8.19405.7" PrivateAssets="all" />
12+
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.0.0-preview8.19405.7" PrivateAssets="all" />
13+
<PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.0.0-preview8.19405.7" />
14+
</ItemGroup>
15+
16+
<ItemGroup>
17+
<ProjectReference Include="..\..\src\Blazor.Extensions.Logging.JS\Blazor.Extensions.Logging.JS.csproj" />
18+
<ProjectReference Include="..\..\src\Blazor.Extensions.Logging\Blazor.Extensions.Logging.csproj" />
19+
</ItemGroup>
20+
21+
</Project>

test/Blazor.Extensions.Logging.Test/Pages/Index.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
@functions {
88
WeatherForecast[] forecasts;
99

10-
protected override async Task OnInitAsync()
10+
protected override async Task OnInitializedAsync()
1111
{
1212
forecasts = await Http.GetJsonAsync<WeatherForecast[]>("weather.json");
1313

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
@using System.Net.Http
2-
@using Microsoft.AspNetCore.Components.Layouts
3-
@using Microsoft.AspNetCore.Components.Routing
4-
@using Microsoft.JSInterop
5-
@using Microsoft.Extensions.Logging
6-
@using Blazor.Extensions.Logging
7-
@using Blazor.Extensions.Logging.Test
8-
@using Blazor.Extensions.Logging.Test.Shared
1+
@using System.Net.Http
2+
@using Microsoft.AspNetCore.Components.Routing
3+
@using Microsoft.JSInterop
4+
@using Microsoft.Extensions.Logging
5+
@using Blazor.Extensions.Logging
6+
@using Blazor.Extensions.Logging.Test
7+
@using Blazor.Extensions.Logging.Test.Shared

0 commit comments

Comments
 (0)