Skip to content

Commit 8341975

Browse files
Merge pull request #4 from attilah/0.1.1-fixes
0.1.1 Release fixes
2 parents e9f685e + c4ff64c commit 8341975

File tree

7 files changed

+106
-22
lines changed

7 files changed

+106
-22
lines changed

Directory.Build.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<PropertyGroup>
44
<Authors>Blazor Extensions Contributors</Authors>
55
<Product>Blazor Extensions</Product>
6-
<Copyright>© Blazor Extensions Contributors. All rights reserved.</Copyright>
6+
<Copyright>(c) Blazor Extensions Contributors. All rights reserved.</Copyright>
77
<PackageLicenseUrl>https://github.com/BlazorExtensions/Logging#license</PackageLicenseUrl>
88
<PackageProjectUrl>https://github.com/BlazorExtensions/Logging</PackageProjectUrl>
9-
<PackageIconUrl>https://avatars2.githubusercontent.com/u/38994076?s%3D128%3Dv%3D4</PackageIconUrl>
10-
<PackageTags>Microsoft Blazor Extensions Logging</PackageTags>
9+
<PackageIconUrl>https://avatars2.githubusercontent.com/u/38994076?s%3D128%26v%3D4</PackageIconUrl>
10+
<PackageTags>Microsoft ASP.NET Core Blazor Extensions Logging</PackageTags>
1111
<PackageReleaseNotes></PackageReleaseNotes>
1212
<RepositoryUrl>https://github.com/BlazorExtensions/Logging</RepositoryUrl>
1313
<RepositoryType>git</RepositoryType>
@@ -30,7 +30,7 @@
3030

3131
<!-- Versioning properties -->
3232
<PropertyGroup>
33-
<VersionPrefix Condition=" '$(VersionPrefix)'=='' ">0.1.0</VersionPrefix>
33+
<VersionPrefix Condition=" '$(VersionPrefix)'=='' ">0.1.1</VersionPrefix>
3434
<VersionSuffix Condition=" '$(VersionSuffix)'=='' ">dev</VersionSuffix>
3535
</PropertyGroup>
3636

README.md

Lines changed: 93 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,94 @@
1-
# Blazor.Eetensions.Logger
2-
Microsoft Extension Logging implementation for ASP.NET Blazor.
1+
<!---[![Build status](https://img.shields.io/circleci/project/github/BlazorExtensions/Logging.svg)](https://ci.dot.net/job/dotnet_orleans/job/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)
35

4-
> Note: This is a work in progress.
6+
# Blazor Extensions
7+
8+
Blazor Extensions are a set of packages with the goal of adding useful things to [Blazor](https://blazor.net).
9+
10+
# Blazor Extensions Logging
11+
12+
This package is a 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 developmer tool console.
16+
17+
# Features
18+
19+
## Content to log
20+
21+
The logger supports the same string formatting what MEL provides, altogether with named parameter replacement in the message.
22+
23+
In addition to that if you like to log an object then in the browser console you'll see an object displayed, and on that you can expand
24+
members, hierarchies to see what is in them.
25+
26+
If you want to log an enumerable list of objects, then the browser side component will display iy be calling ```console.table```.
27+
28+
## Filtering
29+
30+
The implementation supports the ```ILoggerFactory``` based filtering configuration that is supplied by the Microsoft Extension Logging abstraction.
31+
32+
To keep it lightweight [Microsoft Extensions Configuration](https://github.com/aspnet/Configuration) based configuration is not supported, the logger
33+
can be only configured in code.
34+
35+
## Log levels
36+
37+
The logger supports the [LogLevels](https://github.com/aspnet/Logging/blob/dev/src/Microsoft.Extensions.Logging.Abstractions/LogLevel.cs) defined in MEL.
38+
39+
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).
40+
41+
# Sample configuration
42+
43+
## Setup
44+
45+
The following snippet shows how to setup the browser console logger by registering it for dependency injection in the ```Program.cs``` of the application.
46+
47+
```c#
48+
var serviceProvider = new BrowserServiceProvider(services =>
49+
{
50+
// Add Blazor.Extensions.Logging.BrowserConsoleLogger
51+
services.AddLogging(builder => builder
52+
.AddBrowserConsole() // Register the logger with the ILoggerBuilder
53+
.SetMinimumLevel(LogLevel.Information) // Set the minimum log level to Information
54+
);
55+
});
56+
```
57+
58+
## Usage
59+
60+
The following snippet shows how to consume the logger in a Blazor component.
61+
62+
```c#
63+
@inject ILogger<Index> logger
64+
65+
@functions {
66+
protected override async Task OnInitAsync()
67+
{
68+
logger.LogDebug("MyCompoent init");
69+
}
70+
}
71+
```
72+
73+
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.
74+
75+
```c#
76+
[Inject]
77+
protected ILogger<MyClass> logger;
78+
79+
public void LogSomething()
80+
{
81+
logger.LogDebug("Inside LogSomething");
82+
}
83+
```
84+
85+
# Contributions and feedback
86+
87+
Please feel free to use the component, open issues, fix bugs or provide feedback.
88+
89+
# Contributors
90+
91+
The following people are the maintainers of the Blazor Extensions projects:
92+
93+
- [Attila Hajdrik](https://github.com/attilah)
94+
- [Gutemberg Ribiero](https://github.com/galvesribeiro)

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "2.1.300-preview2-008533"
3+
"version": "2.1.300-rc1-008673"
44
}
55
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<OutputType>Library</OutputType>
6-
<IsPackable>true</IsPackable>
6+
<IsPackable>false</IsPackable>
77
<BlazorLinkOnBuild>false</BlazorLinkOnBuild>
88
<LangVersion>latest</LangVersion>
99
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
@@ -16,7 +16,7 @@
1616
</PropertyGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="2.0.0" />
19+
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="2.0.1" />
2020
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.3.0" />
2121
<WebpackInputs Include="**\*.ts" Exclude="dist\**;node_modules\**" />
2222
</ItemGroup>

src/Blazor.Extensions.Logging.JS/src/Initialize.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,4 @@ function initialize() {
6060
});
6161
}
6262

63-
//async function boot() {
64-
// // Read startup config from the <script> element that's importing this file
65-
// const allScriptElems = document.getElementsByTagName('script');
66-
// const thisScriptElem = (document.currentScript || allScriptElems[allScriptElems.length - 1]) as HTMLScriptElement;
67-
//}
68-
6963
initialize();

src/Blazor.Extensions.Logging.JS/src/LogObjectType.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3+
<PropertyGroup>
4+
<Title>Blazor Extensions Logging</Title>
5+
<Description>Microsoft Extension Logging implementation for ASP.NET Core Blazor.</Description>
6+
</PropertyGroup>
7+
38
<PropertyGroup>
49
<OutputType>library</OutputType>
510
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);IncludeP2POutput</TargetsForTfmSpecificBuildOutput>
611
</PropertyGroup>
712

813
<ItemGroup>
914
<PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="0.3.0" />
10-
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.1" />
15+
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.2" />
1116
</ItemGroup>
1217

1318
<ItemGroup>

0 commit comments

Comments
 (0)