Skip to content

Option to preformat messages by wrapping it with triple backquotes #87

Open
@aeroastro

Description

Summary

Since log messages often contains special characters in markdown, I would like to forward messages in code blocks.

some error messages lib/foo.rb:100:in `initialize'

(NOTE: This is an example for GitHub flavored markdown, and we need to use different format for Slack.)

Background

I am using Slack now, and this Plugin is really useful to forward messages. I am mainly using the plugin to send some error messages to Slack.

The problem here is that since the message often contains special characters, we often see some malformated messages.

Current Message Example

Following are the sample messages sent to Slack (Ruby error message with backtrace and URL path). Although this is formatted with GitHub flavored markdown, it still shows the underlying problems on Slack notification.

ERROR -- : Faraday::ConnectionFailed (execution expired) at lib/foo.rb:100:in initialize' <<< lib/bar.rb:7:in initialize', path: /path/to/api?matcher1=&matcher2=hoge&matcher3=

Here, we can see the following problems, and I believe this is pretty common when handling log messages.

  • line numbers is converted into emoji 💯
  • backquotes indicating method make mispaired inline code
  • asterisks in path make partial text italic

Proposed Solution

I just would like to make the message preformatted with ``` like the GitHub app for Slack.

image

This can be achieved by improving the following line and adding some options.

return String.format("%s*%s in Graylog stream %s*:\n> %s", audience, messageLink, titleLink, msg.getMessage());

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions