@@ -58,6 +58,11 @@ public abstract class TaskOrchestrationContext
58
58
/// </value>
59
59
public abstract bool IsReplaying { get ; }
60
60
61
+ /// <summary>
62
+ /// Gets the logger factory for this context.
63
+ /// </summary>
64
+ protected abstract ILoggerFactory LoggerFactory { get ; }
65
+
61
66
/// <summary>
62
67
/// Gets the deserialized input of the orchestrator.
63
68
/// </summary>
@@ -364,18 +369,20 @@ public Task CallSubOrchestratorAsync(
364
369
/// Returns an instance of <see cref="ILogger"/> that is replay-safe, meaning that the logger only
365
370
/// writes logs when the orchestrator is not replaying previous history.
366
371
/// </summary>
367
- /// <remarks>
368
- /// This method wraps the provider <paramref name="logger"/> instance with a new <see cref="ILogger"/>
369
- /// implementation that only writes log messages when <see cref="IsReplaying"/> is <c>false</c>.
370
- /// The resulting logger can be used normally in orchestrator code without needing to worry about duplicate
371
- /// log messages caused by orchestrator replays.
372
- /// </remarks>
373
- /// <param name="logger">The <see cref="ILogger"/> to be wrapped for use by the orchestration.</param>
374
- /// <returns>An instance of <see cref="ILogger"/> that wraps the specified <paramref name="logger"/>.</returns>
375
- public ILogger CreateReplaySafeLogger ( ILogger logger )
376
- {
377
- return new ReplaySafeLogger ( this , logger ) ;
378
- }
372
+ /// <param name="categoryName">The logger's category name.</param>
373
+ /// <returns>An instance of <see cref="ILogger"/> that is replay-safe.</returns>
374
+ public ILogger CreateReplaySafeLogger ( string categoryName )
375
+ => new ReplaySafeLogger ( this , this . LoggerFactory . CreateLogger ( categoryName ) ) ;
376
+
377
+ /// <inheritdoc cref="CreateReplaySafeLogger(string)" />
378
+ /// <param name="type">The type to derive the category name from.</param>
379
+ public virtual ILogger CreateReplaySafeLogger ( Type type )
380
+ => new ReplaySafeLogger ( this , this . LoggerFactory . CreateLogger ( type ) ) ;
381
+
382
+ /// <inheritdoc cref="CreateReplaySafeLogger(string)" />
383
+ /// <typeparam name="T">The type to derive category name from.</typeparam>
384
+ public virtual ILogger CreateReplaySafeLogger < T > ( )
385
+ => new ReplaySafeLogger ( this , this . LoggerFactory . CreateLogger < T > ( ) ) ;
379
386
380
387
class ReplaySafeLogger : ILogger
381
388
{
0 commit comments