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>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
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
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user