Using Slack to … log error

Tram Ho

I have joined viblo for a long time but this is my first time writing this article. What’s wrong looking forward to the only physician

Just now, my brother in the company made an app to log errors on Slack. Looks also more intuitive and fun than reading mail. Enlist me to stop by and lick and write 1 article.

Mechanism of action

The mechanism is quite simple: Slack lets us create apps in the workspace. From this app create a webhook link to a channel. When firing a post request in Slack format, Slack will send a message to the channel

Flow

Perform

Create slack app

First, we need to create the slack app. Visit Slack API homepage: https://api.slack.com/ , click on Start building . A dialog box appears as shown below.

create slack app

You enter the name of the app you want to create + select the workspace for the app and then click submit.

This next screen Slack lists quite a few features. For the purposes of this article, we just created a bot to log simple errors. So only use the Incoming webhook feature. You click on Incoming webhook setup incoming webhook

You will be redirected to the screen below. Set the status bar to enable active incoming webhook. Turn on incoming webhook

Scroll down, click on Add new webhook to workspace . You are redirected to the Authorize page. Here, select the channel you want to message and then click authorize Choose channel and authorize

Now Slack will generate for you a webhook URL so you can send a message. Copy webhook url

Try using postman to test: Test send message in postman

Basically, here you can create your own simple app to log the error. Whenever you encounter an error, make a POST request and fire at the URL of the other error message (error by the guy, how much, the error message details, … blah … blah) is very intuitive. Do not have to read the log in cmd to make eye contact: facepalm: However, you can refer to the message format section and mention below to make the error log more fun. ? )

Message format

To make the message look more vivid, you can use the message format in slack. I often use the message format like this to log errors:

Your message looks like this message

You can read more here to customize more interesting and more suitable formats:

https://api.slack.com/docs/message-formatting

Mention in slack

Sometimes, to focus on work, I only turn on notifications for messages that mention. So sometimes I miss some fatal errors. To overcome this situation, we use the mention function via the user id with fatal errors.

To get a person’s ID, first click on View Profile -> More Action -> Copy MemberID to get the ID

Get id to mention

To get your own ID, I don’t know how to get it, so the easiest way is to have another guy copy your ID and send it back to you quickly: v

Add mention of this person’s ID to the slack we use < @user_id >. So with an ID of UC0CE05JP, my message looks like this

And the result looks like this: mention message

Hope the article helps you. If there is anything wrong in the post or you need support due to an error, please let me know ^^ Thanks for reading ^^

Source of article from my blog: https://minhphong306.wordpress.com/2018/09/22/huong-dan-su-dung-slack-de-log-error/

Share the news now

Source : Viblo