Skip to content

Commit

Permalink
Added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dotnetKyle committed Sep 20, 2022
1 parent 195644b commit 5de90bf
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
59 changes: 58 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,59 @@
# WASM.Console
A Blazor library for writing to the console

A Blazor library for writing to the browser console in C#
using .

Supports: `console.log`, `console.debug`, `console.info`, `console.warn`, `console.error`, `console.dir`, and more.

Add the following nuget package:

```powershell
nuget install WASM.Console
```

Example:

```csharp
using WASM.Console;

var console = new BrowserConsole();

// The different log message types
await console.LogAsync("A simple log message.");
// you may need to turn on Verbose to see debug level messages
await console.DebugAsync("Logs an Debug level message.");
await console.InfoAsync("Logs an Info level message.");
await console.WarnAsync("Logs an Warning level message.");
await console.ErrorAsync("Logs an Error level message.");

// group messages together:
using(await console.GroupAsync())
{
await console.LogAsync("Grouped log message 1.");
await console.LogAsync("Grouped log message 2.");
await console.LogAsync("Grouped log message 3.");
// when the group is disposed console.GroupEnd() will automatically be called.
}

// print an object's properties
var obj = new {
Prop1 = "Test Property 1",
Prop2 = "Test Property 2"
};
await console.DirAsync(obj);

// print a table
var objArray = new[]
{
new { Id = Guid.NewGuid(), Prop1 = "test prop 1" },
new { Id = Guid.NewGuid(), Prop1 = "test prop 2" },
new { Id = Guid.NewGuid(), Prop1 = "test prop 3" },
new { Id = Guid.NewGuid(), Prop1 = "test prop 4" },
new { Id = Guid.NewGuid(), Prop1 = "test prop 5" }
}
await console.TableAsync(objArray);

// start and end a timer
await console.TimeAsync("timer 1");
await console.TimeEndAsync("timer 1");
```
12 changes: 12 additions & 0 deletions src/WASM.Console/WASM.Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,20 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<Title>WASM Console</Title>
<Description>A WASM library for logging messages to the browsers console.</Description>
<RepositoryUrl>https://github.com/dotnetKyle/WASM.Console</RepositoryUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>WASM;console;JavaScript;Logger;Blazor;Web</PackageTags>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.JSInterop.WebAssembly" Version="6.0.9" />
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/WASM.Console/WASM.Console.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{94EC3588-7461-4066-B734-1BF4AB2F598A}"
ProjectSection(SolutionItems) = preProject
..\..\.github\workflows\cd-build.yml = ..\..\.github\workflows\cd-build.yml
..\..\README.md = ..\..\README.md
EndProjectSection
EndProject
Global
Expand Down

0 comments on commit 5de90bf

Please sign in to comment.