BotSharp/src/Infrastructure/BotSharp.Core/Evaluations/ExecutionLogger.cs

32 lines
913 B
C#
Raw Normal View History

2023-10-23 00:31:49 +00:00
using BotSharp.Abstraction.Evaluations;
using BotSharp.Abstraction.Repositories;
using BotSharp.Abstraction.Utilities;
using System.IO;
namespace BotSharp.Core.Evaluations;
public class ExecutionLogger : IExecutionLogger
{
private readonly BotSharpDatabaseSettings _dbSettings;
private readonly IServiceProvider _services;
public ExecutionLogger(
BotSharpDatabaseSettings dbSettings,
IServiceProvider services)
{
_dbSettings = dbSettings;
_services = services;
}
public void Append(string conversationId, string content)
{
var file = GetStorageFile(conversationId);
File.AppendAllLines(file, new[] { content });
}
private string GetStorageFile(string conversationId)
{
var dir = Path.Combine(_dbSettings.FileRepository, "conversations", conversationId);
return Path.Combine(dir, "execution.log");
}
}