Laqus.Logs 1.0.2

dotnet add package Laqus.Logs --version 1.0.2
                    
NuGet\Install-Package Laqus.Logs -Version 1.0.2
                    
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="Laqus.Logs" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Laqus.Logs" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Laqus.Logs" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Laqus.Logs --version 1.0.2
                    
#r "nuget: Laqus.Logs, 1.0.2"
                    
#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.
#:package Laqus.Logs@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Laqus.Logs&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Laqus.Logs&version=1.0.2
                    
Install as a Cake Tool

Laqus.Logs

Instalação

dotnet add package Laqus.Logs

Uso

A lib oferece duas formas de log em formato json, um log que implementa a interface ILogger e foi criado para ser injetado via provider e usado pelos logs de sistema e outro que tem o proposito de ser injetado e usado pelo codigo da aplicação.

Para cadastrar os dois logs, inclua esse trecho no Program.cs:

using Laqus.Logs;

//...

builder.Logging.ClearProviders();
builder.Services.AddSingleton<ILoggerProvider, LaqusLoggerProvider>();
builder.Services.AddSingleton(typeof(LaqusLogger<>), typeof(LaqusLogger<>));

E dependa da interface dentro dos serviços:

    using Laqus.Logs;

    //...

    public class CheckoutService : BaseService
    {
        private readonly LaqusLogger<CheckoutService> logger;

        public CheckoutService(LaqusLogger<CheckoutService> logger)
        {
            this.logger = logger;
        }

        public async void Execute(string id, User user) {
            this.logger.Debug("Processing checkout", DefaultLaqusLogBuilder
                .Build()
                .WithCorrelationId(id)
                .WithSubject(user)
                .WithObscuredFields(new() { "email" })
            );
            //...
            this.logger.Info("Checkout Processed", DefaultLaqusLogBuilder
                .Build()
                .WithCorrelationId(id)
                .WithSubject(new { userId = user.id, orderId = order.id })
            );
            //...
        }
    }

Alêm do uso do DefaultLaqusLogBuilder, também é possivel gerar logs nos seguintes formatos:

Mensagem simples:

    this.logger.Debug("Meu log");

Logando um erro:

    this.logger.Warn("Timeout na requisicao", err)

Implementando a interface ILaqusLog:

    public class OnGetLog : ILaqusLog {
        //...
    }

    public void OnGet()
    { 
        this._logger.Info("New log", new OnGetLog( ... ))
    }

Product 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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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 Laqus.Logs:

Package Downloads
Laqus.Auth

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 2,253 10/1/2024
1.0.1 2,100 8/11/2023
1.0.0 262 8/11/2023