mirror of
https://github.com/temporal-community/temporal-ai-agent.git
synced 2026-03-15 22:18:09 +01:00
Added logger factory to worker and logging to activities (#26)
Signed-off-by: Keith Tenzer <ktenzer@keiths-mbp.lan> Co-authored-by: Keith Tenzer <ktenzer@keiths-mbp.lan>
This commit is contained in:
@@ -2,10 +2,19 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using Temporalio.Client;
|
||||
using Temporalio.Worker;
|
||||
using TrainSearchWorker.Activities;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging.Console;
|
||||
|
||||
// Set up dependency injection
|
||||
var services = new ServiceCollection();
|
||||
|
||||
var loggerFactory = LoggerFactory.Create(builder =>
|
||||
{
|
||||
builder
|
||||
.AddSimpleConsole(options => options.TimestampFormat = "[HH:mm:ss] ")
|
||||
.SetMinimumLevel(LogLevel.Information);
|
||||
});
|
||||
|
||||
// Add HTTP client
|
||||
services.AddHttpClient("TrainApi", client =>
|
||||
{
|
||||
@@ -31,7 +40,10 @@ Console.WriteLine($"Connecting to Temporal at address: {address}");
|
||||
Console.WriteLine($"Using namespace: {ns}");
|
||||
|
||||
// Create worker options
|
||||
var options = new TemporalWorkerOptions("agent-task-queue-legacy");
|
||||
var options = new TemporalWorkerOptions("agent-task-queue-legacy")
|
||||
{
|
||||
LoggerFactory = loggerFactory
|
||||
};
|
||||
|
||||
// Register activities
|
||||
var activities = serviceProvider.GetRequiredService<TrainActivities>();
|
||||
|
||||
Reference in New Issue
Block a user