From 7ef008dc4f068901f85a1795350e3fd00135a6a7 Mon Sep 17 00:00:00 2001 From: c9s Date: Mon, 19 Sep 2022 14:55:58 +0800 Subject: [PATCH] telegramnotifier: show error message in the telegram log --- pkg/notifier/telegramnotifier/logrus_look.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/notifier/telegramnotifier/logrus_look.go b/pkg/notifier/telegramnotifier/logrus_look.go index eb93e9e20..8cfa229a4 100644 --- a/pkg/notifier/telegramnotifier/logrus_look.go +++ b/pkg/notifier/telegramnotifier/logrus_look.go @@ -34,6 +34,12 @@ func (t *LogHook) Fire(e *logrus.Entry) error { } var message = fmt.Sprintf("[%s] %s", e.Level.String(), e.Message) + if errData, ok := e.Data[logrus.ErrorKey]; ok { + if err, isErr := errData.(error); isErr { + message += " Error: " + err.Error() + } + } + t.notifier.Notify(message) return nil }