Files
ClawdDotNet/src/ClawdDotNet.Core/Logging/LoggingExtensions.cs
T
RichardandClaude Opus 4.8 2fed388c99 Initial commit: ClawdDotNet
Import des bestehenden Projektstands in Git.
- .NET 10 WinForms Anwendung (Multi-Agent / Tool-System)
- .gitignore fuer Build-Artefakte, Secrets und Runtime-Daten ergaenzt

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-26 18:21:46 +02:00

43 lines
1.3 KiB
C#

using Microsoft.Extensions.Logging;
namespace ClawdDotNet.Core.Logging;
public static class LoggingExtensions
{
public static ILoggerFactory AddClawdFileLogging(
this ILoggerFactory factory,
FileLoggerOptions? options = null)
{
factory.AddProvider(new FileLoggerProvider(options ?? new FileLoggerOptions()));
return factory;
}
public static ILoggerFactory CreateClawdLoggerFactory(
string logDirectory = "./Logs",
LogLevel minimumLevel = LogLevel.Info)
{
var options = new FileLoggerOptions
{
LogDirectory = logDirectory,
MinimumLevel = minimumLevel
};
var factory = LoggerFactory.Create(builder =>
{
builder.SetMinimumLevel(MapToMelLevel(minimumLevel));
});
factory.AddClawdFileLogging(options);
return factory;
}
private static Microsoft.Extensions.Logging.LogLevel MapToMelLevel(LogLevel level) => level switch
{
LogLevel.Debug => Microsoft.Extensions.Logging.LogLevel.Debug,
LogLevel.Info => Microsoft.Extensions.Logging.LogLevel.Information,
LogLevel.Warn => Microsoft.Extensions.Logging.LogLevel.Warning,
LogLevel.Error => Microsoft.Extensions.Logging.LogLevel.Error,
_ => Microsoft.Extensions.Logging.LogLevel.Information
};
}