Innovian.Aspects.Logging.Fabric
2024.9.30.3
See the version list below for details.
dotnet add package Innovian.Aspects.Logging.Fabric --version 2024.9.30.3
NuGet\Install-Package Innovian.Aspects.Logging.Fabric -Version 2024.9.30.3
<PackageReference Include="Innovian.Aspects.Logging.Fabric" Version="2024.9.30.3" />
paket add Innovian.Aspects.Logging.Fabric --version 2024.9.30.3
#r "nuget: Innovian.Aspects.Logging.Fabric, 2024.9.30.3"
// Install Innovian.Aspects.Logging.Fabric as a Cake Addin #addin nuget:?package=Innovian.Aspects.Logging.Fabric&version=2024.9.30.3 // Install Innovian.Aspects.Logging.Fabric as a Cake Tool #tool nuget:?package=Innovian.Aspects.Logging.Fabric&version=2024.9.30.3
<a href="https://innovian.net"> <p align="center"> <img src="https://innovian.net/img/bluelogo.svg" width="100px"/> </p> </a>
Innovian.Aspets.Logging
Innovian.Aspects.Logging.Fabric
Aspect and Fabric package pipeline
This project is provided to the larger open-source community by Innovian.
This solution implements an aspect using Metalama targeting .NET 8 that provides logging capabilities to projects targeting Microsoft.Extensions.Logging
using ILoggerFactory
and/or ILogger
. This project
includes a single aspect intended for direct use, InjectLoggerAttribute
(intended to be applied to a class) and a fabric that automatically applies this attribute to every non-static class and non-static method across whatever project that
targets it.
The attribute performs the following:
- Automatically wraps eligible methods in try/catch blocks
- Injects an optional instance of
ILoggerFactory
into all constructors of an eligible class - Injects and instantiates an
ILogger
as a private field on the class from theILoggerFactory
or from aNullLoggerFactory
instance if the injectedILoggerFactory
is null - Creates a stopwatch in each method that times and records, via the
ILogger
field, how long it takes a given method to execute
Direct usage of the attribute
The following instructions detail how to use the InjectLoggerAttribute
directly in those project. It's intended to be applied as an attribute to any classes (not records) in your project and will automatically apply the other attributes
in the project. Direct usage of these other attributes isn't intended.
Installation
Using the .NET CLI tools:
dotnet add package Innovian.Aspects.Logging
Using the Package Manager Console:
Install-Package Innovian.Aspects.Logging
From within Visual Studio:
- Open the Solution Explorer.
- Right-click on the project within your solution you wish to add the attribute to.
- Click on "Manage NuGet Packages...".
- Click on the "Browse" tab and search for "Innovian.Aspects.Logging".
- Click on the "Innovian.Aspects.Logging" package, select the appropriate version in the right-tab and click Install.
Usage
Simply apply the [InjectLogger]
attribute to any non-static class you would like the logging capabilities added to. It's recommended that the class be marked with the partial
keyword so that you're able to access the ILogger
field on the
type named _logger
, but this isn't required.
Indirect usage via a Fabric
The following instructions detail how to use the Fabric-based approach to applying the InjectLoggerAttribute
automatically throughout the project referencing this package. This fabric will automatically apply the aspect to
all non-static classes and non-static methods.
Installation
Using the .NET CLI tools:
dotnet add package Innovian.Aspects.Logging.Fabric
Using the Package Manager Console:
Install-Package Innovian.Aspects.Logging.Fabric
From within Visual Studio:
- Open the Solution Explorer.
- Right-click on the project within your solution you wish to add the attribute to.
- Click on "Manage NuGet Packages...".
- Click on the "Browse" tab and search for "Innovian.Aspects.Logging.Fabric".
- Click on the "Innovian.Aspects.Logging.Fabric" package, select the appropriate version in the right-tab and click Install.
Usage
No additional effort is necessary beyond installation of the Innovian.Aspects.Logging.Fabric
package on the project. It will automatically identify all non-static classes to apply the [InjectLogger]
attribute to automatically. In turn, this
will perform the code generation functionality described above.
Notes
The fabric will only install to classes that have at least one method as there's little point to it being on the class otherwise.
Further, ecause we at Innovian also build functionality around Dapr Workflows and the Workflow
base type requires parameterless constructors, the fabric will
also neglect to apply to any type that implements an abstract base type called "Workflow".
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
- Innovian.Aspects.Logging (>= 2024.9.30.3)
- Metalama.Framework (>= 2024.2.24)
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 |
---|---|---|
2024.10.29.1 | 83 | 10/29/2024 |
2024.10.15.1 | 92 | 10/15/2024 |
2024.10.4.1 | 93 | 10/4/2024 |
2024.10.2.1 | 98 | 10/2/2024 |
2024.9.30.3 | 98 | 9/30/2024 |
2024.8.9.2 | 130 | 8/9/2024 |
2024.8.9.1 | 117 | 8/9/2024 |
2024.8.4.4 | 90 | 8/4/2024 |
2024.8.4.3 | 88 | 8/4/2024 |
2024.8.4.2 | 85 | 8/4/2024 |
2024.8.3.3 | 83 | 8/3/2024 |