1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-11-26 09:00:57 +02:00

use fork of roll that doesn't care about errors

This commit is contained in:
Jesse Duffield 2019-06-29 20:52:49 +10:00
parent 235a47bb80
commit b8baef7b8f
7 changed files with 32 additions and 30 deletions

34
Gopkg.lock generated
View File

@ -171,14 +171,6 @@
pruneopts = "NUT"
revision = "ef8a98b0bbce4a65b5aa4c368430a80ddc533168"
[[projects]]
branch = "master"
digest = "1:d457d39e88f678ed14ac29517c3d74927a48dbc6a9f073fa241cf364a68cbe5c"
name = "github.com/heroku/rollrus"
packages = ["."]
pruneopts = "NUT"
revision = "fc0cef2ff331aebb24cd4e9ded7e20650f3d7006"
[[projects]]
branch = "master"
digest = "1:62fe3a7ea2050ecbd753a71889026f83d73329337ada66325cbafd5dea5f713d"
@ -211,6 +203,22 @@
pruneopts = "NUT"
revision = "02db52c7e406c7abec44c717a173c7715e4c1b62"
[[projects]]
branch = "master"
digest = "1:7429d1589cc1454e9e97ba48cb7c5025a085b32eae4d3163c517e3e5d6c7a7a0"
name = "github.com/jesseduffield/roll"
packages = ["."]
pruneopts = "NUT"
revision = "695be2e62b007ecef6644383f0ee9504c1f5cbb9"
[[projects]]
branch = "master"
digest = "1:ec8982ff49a9ebdd7d7dfe320258ad19a07baafb5eeba7f41b31ee2072d1bba9"
name = "github.com/jesseduffield/rollrus"
packages = ["."]
pruneopts = "NUT"
revision = "7086c0b1b1bd21ef1f502e914ff2505a68c7d638"
[[projects]]
branch = "master"
digest = "1:3ab130f65766f5b7cc944d557df31c6a007ec017151705ec1e1b8719f2689021"
@ -445,14 +453,6 @@
revision = "f35b8ab0b5a2cef36673838d662e249dd9c94686"
version = "v1.2.2"
[[projects]]
branch = "master"
digest = "1:e42372d3f4921ec35df07f9b23239631e9d28580f7c1edcca212bc6daddc68fe"
name = "github.com/stvp/roll"
packages = ["."]
pruneopts = "NUT"
revision = "3627a5cbeaeaa68023abd02bb8687925265f2f63"
[[projects]]
digest = "1:cd5ffc5bda4e0296ab3e4de90dbb415259c78e45e7fab13694b14cde8ab74541"
name = "github.com/tcnksm/go-gitconfig"
@ -630,10 +630,10 @@
"github.com/fatih/color",
"github.com/go-errors/errors",
"github.com/golang-collections/collections/stack",
"github.com/heroku/rollrus",
"github.com/jesseduffield/go-getter",
"github.com/jesseduffield/gocui",
"github.com/jesseduffield/pty",
"github.com/jesseduffield/rollrus",
"github.com/kardianos/osext",
"github.com/mgutz/str",
"github.com/nicksnyder/go-i18n/v2/i18n",

View File

@ -9,12 +9,12 @@ import (
"path/filepath"
"strings"
"github.com/heroku/rollrus"
"github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/config"
"github.com/jesseduffield/lazygit/pkg/gui"
"github.com/jesseduffield/lazygit/pkg/i18n"
"github.com/jesseduffield/lazygit/pkg/updates"
"github.com/jesseduffield/rollrus"
"github.com/shibukawa/configdir"
"github.com/sirupsen/logrus"
)

View File

@ -203,7 +203,8 @@ func (c *rollbarClient) send(item map[string]interface{}) (uuid string, err erro
resp, err := http.Post(Endpoint, "application/json", bytes.NewReader(jsonBody))
if err != nil {
return "", err
// If something goes wrong it really does not matter
return "", nil
}
defer func() {
io.Copy(ioutil.Discard, resp.Body)
@ -211,7 +212,8 @@ func (c *rollbarClient) send(item map[string]interface{}) (uuid string, err erro
}()
if resp.StatusCode != http.StatusOK {
return "", fmt.Errorf("Rollbar returned %s", resp.Status)
// If something goes wrong it really does not matter
return "", nil
}
// Extract UUID from JSON response

View File

@ -1,4 +1,4 @@
// Package rollrus combines github.com/stvp/roll with github.com/sirupsen/logrus
// Package rollrus combines github.com/jesseduffield/roll with github.com/sirupsen/logrus
// via logrus.Hook mechanism, so that whenever logrus' logger.Error/f(),
// logger.Fatal/f() or logger.Panic/f() are used the messages are
// intercepted and sent to rollbar.
@ -22,9 +22,9 @@ import (
"os"
"time"
"github.com/jesseduffield/roll"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/stvp/roll"
)
var defaultTriggerLevels = []logrus.Level{
@ -37,7 +37,7 @@ var defaultTriggerLevels = []logrus.Level{
type Hook struct {
roll.Client
triggers []logrus.Level
ignoredErrors map[error]struct{}
ignoredErrors []error
ignoreErrorFunc func(error) bool
ignoreFunc func(error, map[string]string) bool
@ -78,12 +78,10 @@ func WithMinLevel(level logrus.Level) OptionFunc {
}
// WithIgnoredErrors is an OptionFunc that whitelists certain errors to prevent
// them from firing.
// them from firing. See https://golang.org/ref/spec#Comparison_operators
func WithIgnoredErrors(errors ...error) OptionFunc {
return func(h *Hook) {
for _, e := range errors {
h.ignoredErrors[e] = struct{}{}
}
h.ignoredErrors = append(h.ignoredErrors, errors...)
}
}
@ -120,7 +118,7 @@ func NewHookForLevels(token string, env string, levels []logrus.Level) *Hook {
return &Hook{
Client: roll.New(token, env),
triggers: levels,
ignoredErrors: make(map[error]struct{}),
ignoredErrors: make([]error, 0),
ignoreErrorFunc: func(error) bool { return false },
ignoreFunc: func(error, map[string]string) bool { return false },
}
@ -179,8 +177,10 @@ func (r *Hook) Levels() []logrus.Level {
// returned by Levels().
func (r *Hook) Fire(entry *logrus.Entry) error {
trace, cause := extractError(entry)
if _, ok := r.ignoredErrors[cause]; ok {
return nil
for _, ie := range r.ignoredErrors {
if ie == cause {
return nil
}
}
if r.ignoreErrorFunc(cause) {