Skip to content

Extensions for `ILogger` implementations to measure execution times for a named scope.

License

Notifications You must be signed in to change notification settings

dailydevops/logging.measurement

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NetEvolve.Logging.Measurement

NuGet NuGet Downloads License

A lightweight extension library for Microsoft.Extensions.Logging that enables simple and efficient time measurement of code blocks with automatic logging.

Features

  • ⏱️ Simple Time Measurement - Measure execution time of code blocks using intuitive using statements
  • 📊 Configurable Log Levels - Control log output granularity with customizable completion levels
  • 🔍 Debug Information - Optional caller information (member name, file path, line number) for detailed diagnostics
  • 🎯 Zero Overhead - Minimal performance impact with efficient measurement implementation
  • 🔧 Flexible Integration - Seamlessly integrates with existing ILogger implementations

Installation

dotnet add package NetEvolve.Logging.Measurement

Quick Start

using Microsoft.Extensions.Logging;
using NetEvolve.Logging.Measurement;

public sealed class Example
{
    private readonly ILogger<Example> _logger;

    public Example(ILogger<Example> logger)
    {
        _logger = logger;
    }

    public void ProcessData()
    {
        using (_logger.StartMeasurement("Data Processing"))
        {
            // Your code here
            // Execution time will be logged automatically when the scope is disposed
        }
    }
}

Documentation

For detailed usage examples and advanced scenarios, see the package documentation.

Requirements

  • .NET 8.0 or later
  • Microsoft.Extensions.Logging.Abstractions 10.0.0 or compatible version

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Extensions for `ILogger` implementations to measure execution times for a named scope.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 6