Frank.PulseFlow.Logging
2.0.0
See the version list below for details.
dotnet add package Frank.PulseFlow.Logging --version 2.0.0
NuGet\Install-Package Frank.PulseFlow.Logging -Version 2.0.0
<PackageReference Include="Frank.PulseFlow.Logging" Version="2.0.0" />
paket add Frank.PulseFlow.Logging --version 2.0.0
#r "nuget: Frank.PulseFlow.Logging, 2.0.0"
// Install Frank.PulseFlow.Logging as a Cake Addin #addin nuget:?package=Frank.PulseFlow.Logging&version=2.0.0 // Install Frank.PulseFlow.Logging as a Cake Tool #tool nuget:?package=Frank.PulseFlow.Logging&version=2.0.0
Frank.PulseFlow.Logging
This library provides a simple logger for use in .NET applications. It uses the Microsoft.Extensions.Logging
library
backed by Frank.PulseFlow
for logging. It will log to the console by default, but can add one or more IFlow
's to do
whatever you want with the log messages. A common use case is to log to a file or a database, and because Frank.PulseFlow
is thread-safe, you can do so without worrying about concurrency issues like file locks, or the overhead of waiting for a lock.
Usage
using Frank.PulseFlow.Logging;
public class Program
{
public static async Task Main(string[] args)
{
var builder = new HostBuilder()
.ConfigureLogging((hostContext, logging) =>
{
logging.AddPulseFlow();
})
.ConfigureServices((hostContext, services) =>
{
services.AddPulseFlow<FileLoggerFlow>();
});
.Build();
await builder.RunAsync();
}
}
public class FileLoggerFlow(IOptions<FileLoggerSettings> options) : IFlow
{
private readonly FileLoggerSettings _settings = options.Value;
public async Task HandleAsync(IPulse pulse, CancellationToken cancellationToken)
{
var thing = pulse as LogPulse;
await File.AppendAllTextAsync(_settings.LogPath, thing! + Environment.NewLine, cancellationToken);
}
public bool CanHandle(Type pulseType) => pulseType == typeof(LogPulse);
}
public class FileLoggerSettings
{
public string LogPath { get; set; } = "../../../../logs.log";
}
Configuration
The AddPulseFlow
method has a few overloads that allow you to configure the logger. The default configuration is to log
to the console, but you can add one or more IFlow
's to the logger to do whatever you want with the log messages. A common
use case is to log to a file or a database, and because Frank.PulseFlow
is thread-safe, you can do so without worrying
about concurrency issues like file locks, or the overhead of waiting for a lock.
Contributing
Contributions are welcome! Please see create an issue before submitting a pull request to discuss the changes you would like to make.
License
This library is licensed under the MIT license. See the LICENSE file for more information.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Frank.PulseFlow (>= 2.0.0)
- Microsoft.Extensions.Logging (>= 8.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Frank.PulseFlow.Logging:
Package | Downloads |
---|---|
Frank.Testing.Logging
Loggers for the Microsoft.Extensions.Logging framework wrapping the xUnit.net ITestOutputHelper. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.0.8-preview | 121 | 3/3/2024 |
2.0.0 | 294 | 2/4/2024 |
1.7.7-preview | 99 | 2/4/2024 |
1.7.0 | 502 | 1/21/2024 |
1.6.5-preview | 90 | 1/21/2024 |
1.6.4-preview | 95 | 1/21/2024 |
1.6.3-preview | 87 | 1/19/2024 |
1.6.0 | 260 | 1/14/2024 |
1.5.0 | 556 | 12/31/2023 |
1.4.1-preview | 107 | 12/31/2023 |