Skip to content

Repository files navigation

dingtalkrus

DingTalk Hook for Logrus.

Use

package main
import (
"github.com/leafney/dingtalkrus""github.com/sirupsen/logrus""os"
)
funcmain() {
logrus.SetFormatter(&logrus.JSONFormatter{})
logrus.SetOutput(os.Stderr)
logrus.SetLevel(logrus.DebugLevel)
logrus.AddHook(dingtalkrus.NewHook(
"", // dingtalk token"", // dingtalk secretdingtalkrus.LevelThreshold(logrus.ErrorLevel)),
)
logrus.Info("This is the info test message.")
logrus.WithFields(dingtalkrus.SendTextMsg("This is the warn test message.",[]string{},false)).Warn()
logrus.WithFields(dingtalkrus.SendMarkdownMsg("杭州天气","#### 杭州天气 \n 9度,西北风1级,空气良89,相对温度73%\n",[]string{},false)).Error()
}

Installation

go get github.com/leafney/dingtalkrus

Message parameters

SendTextMsg

参数参数类型必须说明
contentString消息内容
atMobilesArray被@人的手机号(在content里添加@人的手机号)
isAtAllBoolean是否@所有人

SendMarkdownMsg

参数参数类型必须说明
titleString首屏会话透出的展示内容
textStringmarkdown格式的消息
atMobilesArray被@人的手机号(在text内容里需要有@手机号)
isAtAllBoolean是否@所有人

SendLinkMsg

参数参数类型必须说明
titleString消息标题
textString 是消息内容。如果太长只会部分展示
messageUrlString点击消息跳转的URL
picUrlString图片URL

Reference

About

dingtalk logrus hook

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages