PvWay.LoggerService.Abstractions.nc6 2.0.0

dotnet add package PvWay.LoggerService.Abstractions.nc6 --version 2.0.0
NuGet\Install-Package PvWay.LoggerService.Abstractions.nc6 -Version 2.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PvWay.LoggerService.Abstractions.nc6" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PvWay.LoggerService.Abstractions.nc6 --version 2.0.0
#r "nuget: PvWay.LoggerService.Abstractions.nc6, 2.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PvWay.LoggerService.Abstractions.nc6 as a Cake Addin
#addin nuget:?package=PvWay.LoggerService.Abstractions.nc6&version=2.0.0

// Install PvWay.LoggerService.Abstractions.nc6 as a Cake Tool
#tool nuget:?package=PvWay.LoggerService.Abstractions.nc6&version=2.0.0

pvWay LoggerService abstractions for dotNet Core 6

Description

This nuget provides the interfaces and enums definitions for the PvWayLoggerService. This will enable you to abstract the LoggerService (and the LogWriter)

Severity enum

For the sake of simplicity not all Microsoft LogLevels are implemented.

public enum SeverityEnum
{
    Ok,         // "O"
    Debug,      // "D"
    Info,       // "I"
    Warning,    // "W"
    Error,      // "E"
    Fatal,      // "F"
}

Methods

All methods include both a synchronous and an asynchronous signature.

See here after the main methods:

void Log(
    string message,
    SeverityEnum severity = SeverityEnum.Debug,
    [CallerMemberName] string memberName = "",
    [CallerFilePath] string filePath = "",
    [CallerLineNumber] int lineNumber = -1);

Task LogAsync(
    string message,
    SeverityEnum severity = SeverityEnum.Debug,
    [CallerMemberName] string memberName = "",
    [CallerFilePath] string filePath = "",
    [CallerLineNumber] int lineNumber = -1);
        
void Log(
    IEnumerable<string> messages,
    SeverityEnum severity,
    [CallerMemberName] string memberName = "",
    [CallerFilePath] string filePath = "",
    [CallerLineNumber] int lineNumber = -1);

Task LogAsync(
    IEnumerable<string> messages,
    SeverityEnum severity,
    [CallerMemberName] string memberName = "",
    [CallerFilePath] string filePath = "",
    [CallerLineNumber] int lineNumber = -1);

void Log(
    Exception e,
    SeverityEnum severity = SeverityEnum.Fatal,
    [CallerMemberName] string memberName = "",
    [CallerFilePath] string filePath = "",
    [CallerLineNumber] int lineNumber = -1);

Task LogAsync(
    Exception e,
    SeverityEnum severity = SeverityEnum.Fatal,
    [CallerMemberName] string memberName = "",
    [CallerFilePath] string filePath = "",
    [CallerLineNumber] int lineNumber = -1);

void Log(
    IMethodResult result,
    string? topic,
    [CallerMemberName] string memberName = "",
    [CallerFilePath] string filePath = "",
    [CallerLineNumber] int lineNumber = -1);

Task LogAsync(
    IMethodResult result,
    string? topic,
    [CallerMemberName] string memberName = "",
    [CallerFilePath] string filePath = "",
    [CallerLineNumber] int lineNumber = -1);


Usage

using PvWay.LoggerService.Abstractions.nc6;
using PvWay.LoggerService.nc6;

// ConsoleLogger is an implementation of 
// the logger service that output colorful
// messages to the standard out
var ls = new ConsoleLogger();

// sync logging a simple debug message to the console
// --------------------------------------------------
ls.Log("simple debug message);

// async logging a warning message to the console
// ----------------------------------------------
async ls.LogAsync("this is a warning", SeverityEnum.Warning);

// logging an exception to the console
// -----------------------------------
try 
{
    var x = y / 0;
}
catch (Exception e) 
{
    ls.Log(e);}
}

See Also

The following nuGet packages implement the LoggerService

  • pvWay.LoggerService.nc6

    • ConsoleLogger: Colorful console implementation
    • MuteLogger: Silent logger for uTesting
    • MicrosoftLogger: uses the Microsoft.Extensions.Logger
    • MicrosoftConsoleLogger: uses the Ms AddConsole extension
    • MultiChannelLogger: writes to multiple logs in one shot
  • pvWay.MsSqlLogWriter.nc6 Implementation for Ms SQL Database

  • pvWay.PgSqlLogWriter.nc6 Implementation for PostgreSQL Database

Take also a look to the MethodResultWrapper nuGet

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on PvWay.LoggerService.Abstractions.nc6:

Package Downloads
PvWay.LoggerService.nc6

Several implementations of the pvWay.LoggerService.Abstractions.nc6 such as ConsoleLogger, MuteLogger, MsLogger...

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 250 8/25/2023
1.0.1 136 8/25/2023
1.0.0 218 6/7/2023

MethodResult now support in LoggerService