Skip to content

Commit

Permalink
add more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
aspriddell committed Dec 21, 2023
1 parent 415cbae commit 592f008
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions DragonFruit.OnionFruit.Web.Worker/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ private async Task PerformUpdate()
{
var source = (IDataSource)ActivatorUtilities.CreateInstance(scope.ServiceProvider, sourceType);

_logger.LogInformation("Checking if {source} has been updated", sourceType.Name);

sourceInstances[sourceType] = source;
dataSourceUpdated |= await source.HasDataChanged(lastVersion).ConfigureAwait(false);
}
Expand All @@ -81,6 +83,7 @@ private async Task PerformUpdate()
}

// fetch all data sources
_logger.LogInformation("Waiting for {count} sources to be fetched...", sourceInstances.Count);
await Task.WhenAll(sourceInstances.Select(x => x.Value.CollectData())).ConfigureAwait(false);

// file sink used to store static-generated assets for uploading to s3 or saving to a local path
Expand All @@ -92,19 +95,19 @@ private async Task PerformUpdate()

try
{
_logger.LogInformation("Running generator for {name}...", generatorDescriptor.OutputFormat.Name);
_logger.LogInformation("Running {name}...", generatorDescriptor.OutputFormat.Name);

var instanceSources = generatorDescriptor.SourceTypes.Select(x => (object)sourceInstances[x]).ToArray();
var generatorInstance = (IDatabaseGenerator)ActivatorUtilities.CreateInstance(scope.ServiceProvider, generatorDescriptor.OutputFormat, instanceSources);

disposableGeneratorInstance = generatorInstance as IDisposable;

await generatorInstance.GenerateDatabase(fileSink).ConfigureAwait(false);
_logger.LogInformation("Generator finished successfully");
_logger.LogInformation("{name} finished successfully", generatorDescriptor.OutputFormat.Name);
}
catch (Exception e)
{
_logger.LogError(e, "Database Generator {x} has failed: {err}", generatorDescriptor.OutputFormat.Name, e.Message);
_logger.LogError(e, "{x} has failed: {err}", generatorDescriptor.OutputFormat.Name, e.Message);
}
finally
{
Expand Down

0 comments on commit 592f008

Please sign in to comment.