Skip to content

Commit

Permalink
tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
dlidstrom committed Mar 17, 2022
1 parent 7353759 commit 8978503
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Snittlistan.Test/Domain/MatchResult_MatchCommentary.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#nullable enable

using Castle.Core.Logging;
using EventStoreLite;
using Moq;
using NUnit.Framework;
Expand Down Expand Up @@ -173,7 +174,8 @@ await Transact(async session =>
Container.Resolve<EventStore>(),
CurrentTenant,
Container.Resolve<IEmailService>(),
Mock.Of<IBitsClient>(MockBehavior.Strict));
Mock.Of<IBitsClient>(MockBehavior.Strict),
NullLogger.Instance);
CommandExecutor commandExecutor = new(
compositionRoot,
Databases,
Expand Down
24 changes: 21 additions & 3 deletions Snittlistan.Web/Infrastructure/CompositionRoot.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#nullable enable

using Castle.Core.Logging;
using Castle.MicroKernel;
using EventStoreLite;
using Postal;
Expand All @@ -20,7 +21,8 @@ public record CompositionRoot(
EventStore EventStore,
Tenant CurrentTenant,
IEmailService EmailService,
IBitsClient BitsClient)
IBitsClient BitsClient,
ILogger Logger)
{
public Guid CorrelationId
{
Expand All @@ -42,7 +44,23 @@ public async Task<TenantFeatures> GetFeatures()
KeyValueProperty? settingsProperty =
await Databases.Snittlistan.KeyValueProperties.SingleOrDefaultAsync(
x => x.Key == TenantFeatures.Key && x.TenantId == CurrentTenant.TenantId);
return settingsProperty?.Value as TenantFeatures
?? TenantFeatures.Default;
do
{
if (settingsProperty is null)
{
Logger.Info("no tenant features found");
break;
}

if (settingsProperty.Value is TenantFeatures tenantFeatures)
{
Logger.InfoFormat("found tenant features {@tenantFeatures}", tenantFeatures);
return tenantFeatures;
}
}
while (false);

Logger.Warn("no tenant features found, or unusable");
return TenantFeatures.Default;
}
}

0 comments on commit 8978503

Please sign in to comment.