From 0c74bc4cea2cefb9fc0340d7998c6de2717f5674 Mon Sep 17 00:00:00 2001 From: jetsparrow Date: Sat, 16 Oct 2021 22:28:01 +0300 Subject: [PATCH] LeakyBucket: Replace Console.Write with ILogger --- JetHerald/LeakyBucket.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/JetHerald/LeakyBucket.cs b/JetHerald/LeakyBucket.cs index 58cd14d..060658c 100644 --- a/JetHerald/LeakyBucket.cs +++ b/JetHerald/LeakyBucket.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; +using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; namespace JetHerald @@ -9,10 +10,12 @@ namespace JetHerald { private readonly ConcurrentDictionary expiryDates = new(); private readonly Options.Timeout config; + private readonly ILogger log; - public LeakyBucket(IOptions cfgOptions) + public LeakyBucket(IOptions cfgOptions, ILogger log) { config = cfgOptions.Value; + this.log = log; } public bool IsTimedOut(uint key) @@ -20,7 +23,7 @@ namespace JetHerald var now = DateTime.UtcNow; var debtLimit = now.AddSeconds(config.DebtLimitSeconds); var time = expiryDates.GetValueOrDefault(key, now); - Console.WriteLine(time); + log.LogTrace("{key} had current timedebt of {time}", key, time); return time > debtLimit; }