MatthL.ResultLogger
0.9.0
dotnet add package MatthL.ResultLogger --version 0.9.0
NuGet\Install-Package MatthL.ResultLogger -Version 0.9.0
<PackageReference Include="MatthL.ResultLogger" Version="0.9.0" />
<PackageVersion Include="MatthL.ResultLogger" Version="0.9.0" />
<PackageReference Include="MatthL.ResultLogger" />
paket add MatthL.ResultLogger --version 0.9.0
#r "nuget: MatthL.ResultLogger, 0.9.0"
#:package MatthL.ResultLogger@0.9.0
#addin nuget:?package=MatthL.ResultLogger&version=0.9.0
#tool nuget:?package=MatthL.ResultLogger&version=0.9.0
ResultLogger
Simple result pattern with integrated logging for .NET. Handle success/failure cases with automatic logging and debugging information.
Installation
dotnet add package MatthL.ResultFlow
📖 Overview
The Result class is the class that allows logging while a good way to transmit objects in failable methods. When a new Result class is created it is automatically logged with the optional parameters and informations from the line and function that called it, allowing a better debugging.
⚙️ Configuration
Configure the logging destination at application startup:
LogManager.Configure(
destination: LogDestination.Memory, // Memory, TempFiles, or CustomPath
customPath: @"C:\Logs\MyApp", // Required if CustomPath selected
maxMemoryLogs: 1000 // Limit memory usage (default: unlimited)
);
💡 Usage
Basic Success/Failure
// Success case
public Result<User> GetUser(int id)
{
var user = database.Find(id);
if (user != null)
{
return Result<User>.Success(user, "User found successfully");
}
return Result<User>.Failure($"User {id} not found", "NotFound", LogLevel.Warning);
}
Chaining Operations
public Result ProcessOrder(Order order)
{
var validation = ValidateOrder(order);
if (!validation.IsSuccess)
return validation; // Propagate failure
var payment = ProcessPayment(order);
if (!payment.IsSuccess)
return payment; // Propagate failure
return Result.Success("Order processed successfully");
}
Retrieving Logs
// Get last 100 logs
var recentLogs = LogManager.GetLogs(100);
// Get all logs
var allLogs = LogManager.GetLogs(-1);
// Display logs
foreach (var log in recentLogs)
{
Console.WriteLine($"[{log.Level}] {log.TimeStamp}: {log.Message}");
}
🎯 Features
✅ Automatic Logging - Every Result is logged with context ✅ Failure Tracking - Line numbers and method names included ✅ Flexible Storage - Memory, temp files, or custom path ✅ Type-Safe - Generic Result<T> for any return type ✅ Memory Efficient - Configurable log retention
📝 Example: Complete Flow
public class UserService
{
public Result<User> CreateUser(string email, string password)
{
// Validate input
if (string.IsNullOrEmpty(email))
return Result<User>.Failure("Email is required", "ValidationError");
if (!IsValidEmail(email))
return Result<User>.Failure("Invalid email format", "ValidationError");
// Check if exists
if (UserExists(email))
return Result<User>.Failure("User already exists", "Conflict");
// Create user
try
{
var user = new User { Email = email };
database.Save(user);
return Result<User>.Success(user, $"User {email} created");
}
catch (Exception ex)
{
return Result<User>.Failure($"Database error: {ex.Message}", "DatabaseError", LogLevel.Error);
}
}
}
🔍 Log Output Example
[INFO] 2024-01-24 10:15:23 | CreateUser:45 | User test@example.com created
[WARN] 2024-01-24 10:15:45 | CreateUser:35 | User already exists
[ERROR] 2024-01-24 10:16:02 | CreateUser:52 | Database error: Connection timeout
📄 License
MIT License - see LICENSE file for details.
<div align="center"> Made with ❤️ by <a href="https://github.com/matthieu-x">Matthieu L</a> </div>
Product | Versions 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 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. |
.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. |
-
.NETStandard 2.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on MatthL.ResultLogger:
Package | Downloads |
---|---|
MatthL.ResultLogger.WPF
Logviewer WPF View integration |
|
MatthL.SqliteEF
Reduce drastically the boilerplate for Sqlite + Entity framework |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
0.9.0 | 138 | 9/25/2025 |