/// <summary> /// Creates the message. /// </summary> /// <param name="logEvent">The log event.</param> /// <returns>A message card.</returns> private MicrosoftTeamsMessageCard CreateMessage(ExtendedLogEvent logEvent) { var renderedMessage = logEvent.LogEvent.RenderMessage(this.options.FormatProvider); var request = new MicrosoftTeamsMessageCard { Title = this.options.Title, Text = renderedMessage, Color = GetAttachmentColor(logEvent.LogEvent.Level), Sections = this.options.OmitPropertiesSection ? null : new[] { new MicrosoftTeamsMessageSection { Title = "Properties", Facts = this.GetFacts(logEvent).ToArray() } }, PotentialActions = null }; // Add static URL button(s) from options if (this.options.Buttons.Any()) { request.PotentialActions = new List <MicrosoftTeamsMessageAction>(); this.options.Buttons.ToList().ForEach(btn => request.PotentialActions.Add(new MicrosoftTeamsMessageAction("OpenUri", btn.Name, new MicrosoftTeamsMessageActionTargetUri(btn.Uri)))); } return(request); }
/// <summary> /// Creates the message. /// </summary> /// <param name="logEvent">The log event.</param> /// <returns>A message card.</returns> private MicrosoftTeamsMessageCard CreateMessage(MicrosoftExtendedLogEvent logEvent) { string renderedMessage; if (string.IsNullOrWhiteSpace(this.options.OutputTemplate)) { renderedMessage = logEvent.LogEvent.RenderMessage(this.options.FormatProvider); } else { var formatter = new MessageTemplateTextFormatter(this.options.OutputTemplate, this.options.FormatProvider); var stringWriter = new StringWriter(); formatter.Format(logEvent.LogEvent, stringWriter); renderedMessage = stringWriter.ToString(); } var request = new MicrosoftTeamsMessageCard { Title = this.options.Title, Text = renderedMessage, Color = GetAttachmentColor(logEvent.LogEvent.Level), Sections = this.options.OmitPropertiesSection ? null : new[] { new MicrosoftTeamsMessageSection { Title = "Properties", Facts = this.GetFacts(logEvent).ToArray() } }, PotentialActions = null }; // Add static URL buttons from the options if (this.options.Buttons.IsNullOrEmpty()) { return(request); } request.PotentialActions = new List <MicrosoftTeamsMessageAction>(); this.options.Buttons.ToList().ForEach(btn => request.PotentialActions.Add(new MicrosoftTeamsMessageAction("OpenUri", btn.Name, new MicrosoftTeamsMessageActionTarget(btn.Uri)))); return(request); }
/// <summary> /// Creates the message. /// </summary> /// <param name="logEvent">The log event.</param> /// <returns>A message card.</returns> private MicrosoftTeamsMessageCard CreateMessage(ExtendedLogEvent logEvent) { var renderedMessage = logEvent.LogEvent.RenderMessage(this.options.FormatProvider); var request = new MicrosoftTeamsMessageCard { Title = this.options.Title, Text = renderedMessage, Color = GetAttachmentColor(logEvent.LogEvent.Level), Sections = this.options.OmitPropertiesSection ? null : new[] { new MicrosoftTeamsMessageSection { Title = "Properties", Facts = this.GetFacts(logEvent).ToArray() } } }; return(request); }
private MicrosoftTeamsMessageCard CreateMessage(LogEvent logEvent) { var renderedMessage = logEvent.RenderMessage(_options.FormatProvider); var request = new MicrosoftTeamsMessageCard { Title = _options.Title, Text = renderedMessage, Color = GetAttachmentColor(logEvent.Level), Sections = _options.RenderProperties ? new[] { new MicrosoftTeamsMessageSection { Title = "Properties", Facts = GetFacts(logEvent).ToArray() } } : Enumerable.Empty <MicrosoftTeamsMessageSection>().ToArray() }; return(request); }