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); }
public virtual void Entry(TimerBaseInformation info, Action errorAction = null) { if (EnabledPreCheck(info)) { DoLog(info, errorAction); } }
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)); }
/// <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);
/// <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);
public virtual void Exit(TimerBaseInformation info, Action errorAction = null) => DoUpdate(info, errorAction);
protected override Task DoUpdate(LogUpdate model, TimerBaseInformation info, int maxLength) { Debug.WriteLine(info.Message, $"{info.CategoryStr} {info.GetElapsedStr()}"); WriteOther(model.Other); return(Task.CompletedTask); }
public void Exit(TimerBaseInformation info, Action errorAction = null) { }