FractalDataWorks.MessageLogging.Abstractions 0.4.0-preview.6

This is a prerelease version of FractalDataWorks.MessageLogging.Abstractions.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package FractalDataWorks.MessageLogging.Abstractions --version 0.4.0-preview.6
                    
NuGet\Install-Package FractalDataWorks.MessageLogging.Abstractions -Version 0.4.0-preview.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="FractalDataWorks.MessageLogging.Abstractions" Version="0.4.0-preview.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FractalDataWorks.MessageLogging.Abstractions" Version="0.4.0-preview.6" />
                    
Directory.Packages.props
<PackageReference Include="FractalDataWorks.MessageLogging.Abstractions" />
                    
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 FractalDataWorks.MessageLogging.Abstractions --version 0.4.0-preview.6
                    
#r "nuget: FractalDataWorks.MessageLogging.Abstractions, 0.4.0-preview.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 FractalDataWorks.MessageLogging.Abstractions@0.4.0-preview.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=FractalDataWorks.MessageLogging.Abstractions&version=0.4.0-preview.6&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=FractalDataWorks.MessageLogging.Abstractions&version=0.4.0-preview.6&prerelease
                    
Install as a Cake Tool

FractalDataWorks.MessageLogging.Abstractions

Attribute definitions for source-generated logging methods that return IGenericMessage.

Overview

This package provides the [MessageLogging] attribute used to mark partial methods for source generation. The source generator (FractalDataWorks.MessageLogging.SourceGenerators) generates implementations that both log messages AND return them as IGenericMessage instances. This enables the FractalDataWorks pattern: every logged message is returned in the result.

Based on Microsoft's LoggerMessageAttribute with extensions for IGenericMessage return types.

Target Framework

  • netstandard2.0

Installation

<PackageReference Include="FractalDataWorks.MessageLogging.Abstractions" />
<PackageReference Include="FractalDataWorks.MessageLogging.SourceGenerators"
                  OutputItemType="Analyzer"
                  ReferenceOutputAssembly="false" />

Dependencies

  • FractalDataWorks.Messages - Provides IGenericMessage and MessageSeverity
  • Microsoft.Extensions.Logging.Abstractions - Provides ILogger and LogLevel

API Reference

MessageLoggingAttribute

From MessageLoggingAttribute.cs:24-116:

[AttributeUsage(AttributeTargets.Method)]
public sealed class MessageLoggingAttribute : Attribute
{
    public MessageLoggingAttribute() { }
    public MessageLoggingAttribute(int eventId, LogLevel level, string message) { ... }
    public MessageLoggingAttribute(LogLevel level, string message) { ... }
    public MessageLoggingAttribute(LogLevel level) { ... }
    public MessageLoggingAttribute(string message) { ... }

    public int EventId { get; set; } = -1;
    public string? EventName { get; set; }
    public LogLevel Level { get; set; } = LogLevel.None;
    public string Message { get; set; } = string.Empty;
    public bool SkipEnabledCheck { get; set; }
    public MessageSeverity Severity { get; set; } = MessageSeverity.Information;
    public bool AutoMapSeverity { get; set; } = true;
}

Properties:

Property Type Default Description
EventId int -1 Event ID for the log message
EventName string? null Event name for the log message
Level LogLevel None Log level for Microsoft.Extensions.Logging
Message string "" Message template with placeholders
SkipEnabledCheck bool false Skip checking if log level is enabled
Severity MessageSeverity Information Severity for returned IGenericMessage
AutoMapSeverity bool true Auto-map Severity from LogLevel

Method Requirements

From MessageLoggingAttribute.cs:12-22:

Methods decorated with [MessageLogging]:

  • Must be a partial method
  • Must return IGenericMessage or a type that implements it
  • Must not be generic
  • Must have an ILogger as one of its parameters
  • None of the parameters can be generic

Usage

From Reference Solution OrderLog.cs:31-37:

[MessageLogging(
    EventId = 8001,
    Level = LogLevel.Debug,
    Message = "Starting order processing for order '{orderId}'")]
public static partial IGenericMessage ProcessingStarted(
    ILogger logger,
    string orderId);

From Reference Solution OrderLog.cs:114-120:

[MessageLogging(
    EventId = 8030,
    Level = LogLevel.Error,
    Message = "Order '{orderId}' not found")]
public static partial IGenericMessage OrderNotFound(
    ILogger logger,
    string orderId);

Log AND Return Pattern

From Reference Solution OrderService.cs:77-80:

// Log AND return success
// The message is logged internally AND returned in the result
var successMessage = OrderLog.OrderCreated(_logger, orderId, customerId);
return GenericResult<Order>.Success(order, successMessage);

From Reference Solution OrderService.cs:82-88:

catch (Exception ex)
{
    // CRITICAL PATTERN: Catch -> Log -> Return (never rethrow!)
    // The message is logged AND returned
    return GenericResult<Order>.Failure(
        OrderLog.ProcessingException(_logger, ex, orderId));
}

Next Steps

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (11)

Showing the top 5 NuGet packages that depend on FractalDataWorks.MessageLogging.Abstractions:

Package Downloads
FractalDataWorks.Commands.Abstractions

Development tools and utilities for the FractalDataWorks ecosystem. Build:

FractalDataWorks.Commands.Data.Abstractions

Development tools and utilities for the FractalDataWorks ecosystem. Build:

FractalDataWorks.Calculations.Aggregations

Development tools and utilities for the FractalDataWorks ecosystem. Build:

FractalDataWorks.Configuration.MsSql

Development tools and utilities for the FractalDataWorks ecosystem. Build:

CyberdyneDevelopment.Mc3Po.Tools.Abstractions

Tool abstractions for FractalDataWorks Roslyn development tools. Provides TypeCollections for tool categories and parameter types.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
Loading failed