Lambda.Core.LogNotificator 1.0.6

dotnet add package Lambda.Core.LogNotificator --version 1.0.6
                    
NuGet\Install-Package Lambda.Core.LogNotificator -Version 1.0.6
                    
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="Lambda.Core.LogNotificator" Version="1.0.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Lambda.Core.LogNotificator" Version="1.0.6" />
                    
Directory.Packages.props
<PackageReference Include="Lambda.Core.LogNotificator" />
                    
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 Lambda.Core.LogNotificator --version 1.0.6
                    
#r "nuget: Lambda.Core.LogNotificator, 1.0.6"
                    
#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 Lambda.Core.LogNotificator@1.0.6
                    
#: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=Lambda.Core.LogNotificator&version=1.0.6
                    
Install as a Cake Addin
#tool nuget:?package=Lambda.Core.LogNotificator&version=1.0.6
                    
Install as a Cake Tool

Lambda.Core.LogNotificator

Lambda.Core.LogNotificator é um pacote NuGet para facilitar o registro estruturado de logs e notificações em aplicações .NET, com suporte a repositórios de persistência e integração com padrões de correlação de logs (Correlation ID).


📦 Instalação

Via NuGet Package Manager:

Install-Package Lambda.Core.LogNotificator

Via .NET CLI:

dotnet add package Lambda.Core.LogNotificator

✅ Funcionalidades

  • Registro de logs estruturados com níveis: Debug, Information, Warning e Error.
  • Correlação de logs via Correlation ID.
  • Registro de notificações categorizadas: Informações, Alertas e Erros.
  • Persistência de logs utilizando ILogRepository com suporte a transações.
  • Serviço central NotificationLogService para registrar notificações como logs.
  • Implementação do padrão Unit of Work para controle de transações.

📂 Estrutura de Classes

Entities

  • Log: Representa um log estruturado.
  • Notification: Representa uma notificação categorizada (Informação, Alerta, Erro).

Interfaces

  • ILoggerProvider: Interface para abstração de provedores de log.
  • ILogRepository: Interface para persistência de logs.
  • INotificator: Interface para gerenciamento de notificações.

Repositories

  • LogRepository: Implementação de ILogRepository utilizando IUnitOfWork para persistência transacional dos logs.

Services

  • LoggerProvider: Implementação padrão de ILoggerProvider, escreve logs no console e suporta Correlation ID.
  • NotificationLogService: Serviço para converter notificações em logs persistentes.
  • Notificator: Implementação padrão de INotificator, gerencia notificações em memória.

🚀 Exemplo de Uso

// Instanciar o Notificator
var notificator = new Notificator();

// Adicionar notificações
notificator.AddInformation("INFO001", "Processo concluído com sucesso.");
notificator.AddWarning("WARN001", "Limite de tentativas quase atingido.");
notificator.AddError("ERR001", "Falha ao processar solicitação.");

// Instanciar o LogRepository com UnitOfWork
var unitOfWork = new UnitOfWork(connection);
var logRepository = new LogRepository(unitOfWork);

// Criar o NotificationLogService
var notificationLogService = new NotificationLogService(notificator, logRepository);

// Registrar notificações como logs
await notificationLogService.RegistrarNotificacoesInformationsAsync();
await notificationLogService.RegistrarNotificacoesWarnings();
await notificationLogService.RegistrarNotificacoesErrors();

🛠️ Dependências

  • Dapper para execução de comandos SQL.
  • IUnitOfWork para controle transacional.
  • Banco de dados relacional com tabela Logs com colunas: Message, MessageTemplate, Level, TimeStamp, Exception, Properties, LogEvent.

📝 Tabela de Logs (SQL)

CREATE TABLE Logs (
    Id INT PRIMARY KEY IDENTITY,
    Message NVARCHAR(MAX),
    MessageTemplate NVARCHAR(MAX),
    Level NVARCHAR(50),
    TimeStamp DATETIMEOFFSET,
    Exception NVARCHAR(MAX),
    Properties NVARCHAR(MAX),
    LogEvent NVARCHAR(100)
);

🎯 Principais Benefícios

✅ Facilidade para estruturar logs e notificações.
✅ Integração simples com qualquer sistema de persistência.
✅ Padronização de logs com correlação de eventos.
✅ Flexível e extensível via injeção de dependência.


⚖️ Licença

Este projeto é distribuído sob a licença MIT.


🙌 Contribuições

Contribuições são bem-vindas! Sinta-se à vontade para abrir Issues ou enviar Pull Requests.


👤 Autor

Desenvolvido por [Marcelo P. Matos].

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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.6 203 6/3/2025
1.0.5 186 6/3/2025
1.0.3 192 6/3/2025
1.0.2 186 6/3/2025
1.0.1 190 6/2/2025
1.0.0 392 3/27/2025