A lightweight extension library for Microsoft.Extensions.Logging that enables simple and efficient time measurement of code blocks with automatic logging.
- ⏱️ Simple Time Measurement - Measure execution time of code blocks using intuitive
usingstatements - 📊 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
ILoggerimplementations
dotnet add package NetEvolve.Logging.Measurementusing 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
}
}
}For detailed usage examples and advanced scenarios, see the package documentation.
- .NET 8.0 or later
- Microsoft.Extensions.Logging.Abstractions 10.0.0 or compatible version
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.