Example #1
0
        protected virtual LogUpdate ToUpdateModel(TimerBaseInformation info, int maxLength)
        {
            var model = new LogUpdate
            {
                Identifier = info.Identifier,
                Elapsed    = info.GetElapsed()
            };

            if (IncludeHigh)
            {
                foreach (var(key, value) in info.HighProperties)
                {
                    model.Other.Add(key, value.ShortenWithEllipses(maxLength));
                }
            }

            if (IncludeMed)
            {
                foreach (var(key, value) in info.MedProperties)
                {
                    model.Other.Add(key, value.ShortenWithEllipses(maxLength));
                }
            }

            // ReSharper disable once InvertIf
            if (IncludeLow)
            {
                foreach (var(key, value) in info.LowProperties)
                {
                    model.Other.Add(key, value.ShortenWithEllipses(maxLength));
                }
            }

            return(model);
        }
Example #2
0
 public virtual void Entry(TimerBaseInformation info, Action errorAction = null)
 {
     if (EnabledPreCheck(info))
     {
         DoLog(info, errorAction);
     }
 }
Example #3
0
        protected override Task DoUpdate(LogUpdate model, TimerBaseInformation info, int maxLength)
        {
            var subject = $"[{model.Identifier}] Completed";
            var body    = $@"
{info.Type} Complete!
{info.IdentifierStr}
{info.GetElapsedStr()}
{string.Join("\r\n", model.Other)}
";

            return(Email.SendAsync(EmailImpl, EmailType.Logging, subject, body));
        }
Example #4
0
 /// <summary>
 /// Actual implementation of updating a logged record
 /// </summary>
 /// <param name="model">The model containing everything to be logged</param>
 /// <param name="info">The log information class</param>
 /// <param name="maxLength">When to truncate items</param>
 protected abstract Task DoUpdate(LogUpdate model, TimerBaseInformation info, int maxLength);
Example #5
0
 /// <summary>
 /// Called by the logger, this is when a logged record needs to be updated
 /// </summary>
 /// <remarks>Do not override this one - you should instead customize in DoInsert</remarks>
 /// <param name="info">The log information class</param>
 /// <param name="maxLength">When to truncate items</param>
 public virtual Task Update(TimerBaseInformation info, int maxLength)
 => DoUpdate(ToUpdateModel(info, maxLength), info, maxLength);
Example #6
0
 public virtual void Exit(TimerBaseInformation info, Action errorAction = null)
 => DoUpdate(info, errorAction);
Example #7
0
 protected override Task DoUpdate(LogUpdate model, TimerBaseInformation info, int maxLength)
 {
     Debug.WriteLine(info.Message, $"{info.CategoryStr} {info.GetElapsedStr()}");
     WriteOther(model.Other);
     return(Task.CompletedTask);
 }
Example #8
0
 public void Exit(TimerBaseInformation info, Action errorAction = null)
 {
 }