Add logging to Timer
This commit is contained in:
parent
4ce94ee01a
commit
1aee05d82f
|
|
@ -3,6 +3,7 @@ using Elsa.ActivityResults;
|
|||
using Elsa.Attributes;
|
||||
using Elsa.Services;
|
||||
using Elsa.Services.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NodaTime;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
|
|
@ -12,10 +13,12 @@ namespace Elsa.Activities.Timers
|
|||
public class Timer : Activity, IReschedule
|
||||
{
|
||||
private readonly IClock _clock;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public Timer(IClock clock)
|
||||
public Timer(IClock clock, ILogger<Timer> logger)
|
||||
{
|
||||
_clock = clock;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[ActivityProperty(Hint = "The time interval at which this activity should tick.")]
|
||||
|
|
@ -34,9 +37,12 @@ namespace Elsa.Activities.Timers
|
|||
|
||||
var now = _clock.GetCurrentInstant();
|
||||
ExecuteAt = now.Plus(Timeout);
|
||||
|
||||
|
||||
if (ExecuteAt <= now)
|
||||
{
|
||||
_logger.LogDebug("Scheduled trigger time lies in the past ('{Delta}'). Skipping scheduling.", now - ExecuteAt);
|
||||
return Done();
|
||||
}
|
||||
|
||||
return Combine(Suspend(), new ScheduleWorkflowResult(ExecuteAt.Value));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue