Skip to content

Commit

Permalink
Log persistence connection
Browse files Browse the repository at this point in the history
  • Loading branch information
kbilsted committed Feb 7, 2024
1 parent cbebca1 commit f4b3bb4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Product/GreenFeetWorkFlow.AdoPersistence/AdoDb.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using GreenFeetWorkflow;
using Microsoft.Data.SqlClient;
using System.Data;
using System.Text.RegularExpressions;

namespace GreenFeetWorkFlow.AdoMsSql;

Expand Down Expand Up @@ -47,6 +48,8 @@ public object CreateTransaction()
return transaction;
}

public string GetConnectionInfoForLogging() => "SqlServer persister: " + Regex.Replace(connectionString, "Password=[^;]*", "");

public T InTransaction<T>(Func<T> code, object? outsideTransaction = null)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ public void SetTransaction(object transaction)
{
}

public string GetConnectionInfoForLogging() => "InMemory Demo Persister";

public T InTransaction<T>(Func<T> code, object? transaction = null)
{
return code();
Expand Down
2 changes: 2 additions & 0 deletions src/Product/GreenFeetWorkFlow/Interfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public interface IWorkflowIocContainer
/// </summary>
public interface IStepPersister : IDisposable
{
string GetConnectionInfoForLogging();

T InTransaction<T>(Func<T> code, object? transaction = null);
object CreateTransaction();
/// <summary> You can either set the transaction explicitly or create one using <see cref="CreateTransaction"/> </summary>
Expand Down
5 changes: 4 additions & 1 deletion src/Product/GreenFeetWorkFlow/WorkflowEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ static string MakeEngineName()
void Init(WorkflowConfiguration configuration, string? engineName, CancellationToken? token)
{
if (logger.InfoLoggingEnabled)
logger.LogInfo($"{nameof(WorkflowEngine)}: starting engine {engineName}", null, null);
{
logger.LogInfo($"{nameof(WorkflowEngine)}: starting engine: {engineName}", null, null);
logger.LogInfo($"{nameof(WorkflowEngine)}: starting persister connection: {iocContainer.GetInstance<IStepPersister>().GetConnectionInfoForLogging()}", null, null);
}

Configuration = configuration;
configuration.LoggerConfiguration = logger.Configuration;
Expand Down

0 comments on commit f4b3bb4

Please sign in to comment.