Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 7bddbdf

Browse files
committed
Merge pull request #19503 from jfrazelle/update-logrus
bump logrus
2 parents 2705fa5 + 95695aa commit 7bddbdf

File tree

14 files changed

+129
-73
lines changed

14 files changed

+129
-73
lines changed

hack/vendor.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ source 'hack/.vendor-helpers.sh'
77

88
# the following lines are in sorted order, FYI
99
clone git github.com/Azure/go-ansiterm 70b2c90b260171e829f1ebd7c17f600c11858dbe
10-
clone git github.com/Sirupsen/logrus v0.8.2 # logrus is a common dependency among multiple deps
10+
clone git github.com/Sirupsen/logrus v0.8.7 # logrus is a common dependency among multiple deps
1111
clone git github.com/docker/libtrust 9cbd2a1374f46905c68a4eb3694a130610adc62a
1212
clone git github.com/go-check/check 11d3bc7aa68e238947792f30573146a3231fc0f1
1313
clone git github.com/gorilla/context 14f550f51a
Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,47 @@
1+
# 0.8.7
2+
3+
* logrus/core: fix possible race (#216)
4+
* logrus/doc: small typo fixes and doc improvements
5+
6+
7+
# 0.8.6
8+
9+
* hooks/raven: allow passing an initialized client
10+
11+
# 0.8.5
12+
13+
* logrus/core: revert #208
14+
15+
# 0.8.4
16+
17+
* formatter/text: fix data race (#218)
18+
19+
# 0.8.3
20+
21+
* logrus/core: fix entry log level (#208)
22+
* logrus/core: improve performance of text formatter by 40%
23+
* logrus/core: expose `LevelHooks` type
24+
* logrus/core: add support for DragonflyBSD and NetBSD
25+
* formatter/text: print structs more verbosely
26+
127
# 0.8.2
228

3-
logrus: fix more Fatal family functions
29+
* logrus: fix more Fatal family functions
430

531
# 0.8.1
632

7-
logrus: fix not exiting on `Fatalf` and `Fatalln`
33+
* logrus: fix not exiting on `Fatalf` and `Fatalln`
834

935
# 0.8.0
1036

11-
logrus: defaults to stderr instead of stdout
12-
hooks/sentry: add special field for `*http.Request`
13-
formatter/text: ignore Windows for colors
37+
* logrus: defaults to stderr instead of stdout
38+
* hooks/sentry: add special field for `*http.Request`
39+
* formatter/text: ignore Windows for colors
1440

1541
# 0.7.3
1642

17-
formatter/\*: allow configuration of timestamp layout
43+
* formatter/\*: allow configuration of timestamp layout
1844

1945
# 0.7.2
2046

21-
formatter/text: Add configuration option for time format (#158)
47+
* formatter/text: Add configuration option for time format (#158)

vendor/src/github.com/Sirupsen/logrus/README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ Logrus comes with [built-in hooks](hooks/). Add those, or your custom hook, in
183183
import (
184184
log "github.com/Sirupsen/logrus"
185185
"github.com/Sirupsen/logrus/hooks/airbrake"
186-
"github.com/Sirupsen/logrus/hooks/syslog"
186+
logrus_syslog "github.com/Sirupsen/logrus/hooks/syslog"
187187
"log/syslog"
188188
)
189189

@@ -206,12 +206,19 @@ func init() {
206206
| [Papertrail](https://github.com/Sirupsen/logrus/blob/master/hooks/papertrail/papertrail.go) | Send errors to the Papertrail hosted logging service via UDP. |
207207
| [Syslog](https://github.com/Sirupsen/logrus/blob/master/hooks/syslog/syslog.go) | Send errors to remote syslog server. Uses standard library `log/syslog` behind the scenes. |
208208
| [BugSnag](https://github.com/Sirupsen/logrus/blob/master/hooks/bugsnag/bugsnag.go) | Send errors to the Bugsnag exception tracking service. |
209+
| [Sentry](https://github.com/Sirupsen/logrus/blob/master/hooks/sentry/sentry.go) | Send errors to the Sentry error logging and aggregation service. |
209210
| [Hiprus](https://github.com/nubo/hiprus) | Send errors to a channel in hipchat. |
210211
| [Logrusly](https://github.com/sebest/logrusly) | Send logs to [Loggly](https://www.loggly.com/) |
211212
| [Slackrus](https://github.com/johntdyer/slackrus) | Hook for Slack chat. |
212213
| [Journalhook](https://github.com/wercker/journalhook) | Hook for logging to `systemd-journald` |
213214
| [Graylog](https://github.com/gemnasium/logrus-hooks/tree/master/graylog) | Hook for logging to [Graylog](http://graylog2.org/) |
214215
| [Raygun](https://github.com/squirkle/logrus-raygun-hook) | Hook for logging to [Raygun.io](http://raygun.io/) |
216+
| [LFShook](https://github.com/rifflock/lfshook) | Hook for logging to the local filesystem |
217+
| [Honeybadger](https://github.com/agonzalezro/logrus_honeybadger) | Hook for sending exceptions to Honeybadger |
218+
| [Mail](https://github.com/zbindenren/logrus_mail) | Hook for sending exceptions via mail |
219+
| [Rollrus](https://github.com/heroku/rollrus) | Hook for sending errors to rollbar |
220+
| [Fluentd](https://github.com/evalphobia/logrus_fluent) | Hook for logging to fluentd |
221+
| [Mongodb](https://github.com/weekface/mgorus) | Hook for logging to mongodb |
215222

216223
#### Level logging
217224

@@ -267,7 +274,7 @@ init() {
267274
// do something here to set environment depending on an environment variable
268275
// or command-line flag
269276
if Environment == "production" {
270-
log.SetFormatter(logrus.JSONFormatter)
277+
log.SetFormatter(&log.JSONFormatter{})
271278
} else {
272279
// The TextFormatter is default, you don't actually have to do this.
273280
log.SetFormatter(&log.TextFormatter{})
@@ -310,7 +317,7 @@ type MyJSONFormatter struct {
310317
311318
log.SetFormatter(new(MyJSONFormatter))
312319
313-
func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) {
320+
func (f *MyJSONFormatter) Format(entry *Entry) ([]byte, error) {
314321
// Note this doesn't include Time, Level and Message which are available on
315322
// the Entry. Consult `godoc` on information about those fields or read the
316323
// source of the official loggers.
@@ -324,7 +331,7 @@ func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) {
324331
325332
#### Logger as an `io.Writer`
326333
327-
Logrus can be transormed into an `io.Writer`. That writer is the end of an `io.Pipe` and it is your responsibility to close it.
334+
Logrus can be transformed into an `io.Writer`. That writer is the end of an `io.Pipe` and it is your responsibility to close it.
328335
329336
```go
330337
w := logger.Writer()
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
Package logrus is a structured logger for Go, completely API compatible with the standard library logger.
3+
4+
5+
The simplest way to use Logrus is simply the package-level exported logger:
6+
7+
package main
8+
9+
import (
10+
log "github.com/Sirupsen/logrus"
11+
)
12+
13+
func main() {
14+
log.WithFields(log.Fields{
15+
"animal": "walrus",
16+
"number": 1,
17+
"size": 10,
18+
}).Info("A walrus appears")
19+
}
20+
21+
Output:
22+
time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10
23+
24+
For a full guide visit https://github.com/Sirupsen/logrus
25+
*/
26+
package logrus

vendor/src/github.com/Sirupsen/logrus/entry.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import (
88
"time"
99
)
1010

11+
// Defines the key when adding errors using WithError.
12+
var ErrorKey = "error"
13+
1114
// An entry is the final or intermediate Logrus logging entry. It contains all
1215
// the fields passed with WithField{,s}. It's finally logged when Debug, Info,
1316
// Warn, Error, Fatal or Panic is called on it. These objects can be reused and
@@ -53,6 +56,11 @@ func (entry *Entry) String() (string, error) {
5356
return reader.String(), err
5457
}
5558

59+
// Add an error as single field (using the key defined in ErrorKey) to the Entry.
60+
func (entry *Entry) WithError(err error) *Entry {
61+
return entry.WithField(ErrorKey, err)
62+
}
63+
5664
// Add a single field to the Entry.
5765
func (entry *Entry) WithField(key string, value interface{}) *Entry {
5866
return entry.WithFields(Fields{key: value})
@@ -70,12 +78,14 @@ func (entry *Entry) WithFields(fields Fields) *Entry {
7078
return &Entry{Logger: entry.Logger, Data: data}
7179
}
7280

73-
func (entry *Entry) log(level Level, msg string) {
81+
// This function is not declared with a pointer value because otherwise
82+
// race conditions will occur when using multiple goroutines
83+
func (entry Entry) log(level Level, msg string) {
7484
entry.Time = time.Now()
7585
entry.Level = level
7686
entry.Message = msg
7787

78-
if err := entry.Logger.Hooks.Fire(level, entry); err != nil {
88+
if err := entry.Logger.Hooks.Fire(level, &entry); err != nil {
7989
entry.Logger.mu.Lock()
8090
fmt.Fprintf(os.Stderr, "Failed to fire hook: %v\n", err)
8191
entry.Logger.mu.Unlock()
@@ -100,7 +110,7 @@ func (entry *Entry) log(level Level, msg string) {
100110
// panic() to use in Entry#Panic(), we avoid the allocation by checking
101111
// directly here.
102112
if level <= PanicLevel {
103-
panic(entry)
113+
panic(&entry)
104114
}
105115
}
106116

vendor/src/github.com/Sirupsen/logrus/exported.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ func AddHook(hook Hook) {
4848
std.Hooks.Add(hook)
4949
}
5050

51+
// WithError creates an entry from the standard logger and adds an error to it, using the value defined in ErrorKey as key.
52+
func WithError(err error) *Entry {
53+
return std.WithField(ErrorKey, err)
54+
}
55+
5156
// WithField creates an entry from the standard logger and adds a field to
5257
// it. If you want multiple fields, use `WithFields`.
5358
//

vendor/src/github.com/Sirupsen/logrus/hooks.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ type Hook interface {
1111
}
1212

1313
// Internal type for storing the hooks on a logger instance.
14-
type levelHooks map[Level][]Hook
14+
type LevelHooks map[Level][]Hook
1515

1616
// Add a hook to an instance of logger. This is called with
1717
// `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface.
18-
func (hooks levelHooks) Add(hook Hook) {
18+
func (hooks LevelHooks) Add(hook Hook) {
1919
for _, level := range hook.Levels() {
2020
hooks[level] = append(hooks[level], hook)
2121
}
2222
}
2323

2424
// Fire all the hooks for the passed level. Used by `entry.log` to fire
2525
// appropriate hooks for a log entry.
26-
func (hooks levelHooks) Fire(level Level, entry *Entry) error {
26+
func (hooks LevelHooks) Fire(level Level, entry *Entry) error {
2727
for _, hook := range hooks[level] {
2828
if err := hook.Fire(entry); err != nil {
2929
return err

vendor/src/github.com/Sirupsen/logrus/logger.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import (
88

99
type Logger struct {
1010
// The logs are `io.Copy`'d to this in a mutex. It's common to set this to a
11-
// file, or leave it default which is `os.Stdout`. You can also set this to
11+
// file, or leave it default which is `os.Stderr`. You can also set this to
1212
// something more adventorous, such as logging to Kafka.
1313
Out io.Writer
1414
// Hooks for the logger instance. These allow firing events based on logging
1515
// levels and log entries. For example, to send errors to an error tracking
1616
// service, log to StatsD or dump the core on fatal errors.
17-
Hooks levelHooks
17+
Hooks LevelHooks
1818
// All log entries pass through the formatter before logged to Out. The
1919
// included formatters are `TextFormatter` and `JSONFormatter` for which
2020
// TextFormatter is the default. In development (when a TTY is attached) it
@@ -37,7 +37,7 @@ type Logger struct {
3737
// var log = &Logger{
3838
// Out: os.Stderr,
3939
// Formatter: new(JSONFormatter),
40-
// Hooks: make(levelHooks),
40+
// Hooks: make(LevelHooks),
4141
// Level: logrus.DebugLevel,
4242
// }
4343
//
@@ -46,14 +46,14 @@ func New() *Logger {
4646
return &Logger{
4747
Out: os.Stderr,
4848
Formatter: new(TextFormatter),
49-
Hooks: make(levelHooks),
49+
Hooks: make(LevelHooks),
5050
Level: InfoLevel,
5151
}
5252
}
5353

5454
// Adds a field to the log entry, note that you it doesn't log until you call
5555
// Debug, Print, Info, Warn, Fatal or Panic. It only creates a log entry.
56-
// Ff you want multiple fields, use `WithFields`.
56+
// If you want multiple fields, use `WithFields`.
5757
func (logger *Logger) WithField(key string, value interface{}) *Entry {
5858
return NewEntry(logger).WithField(key, value)
5959
}

vendor/src/github.com/Sirupsen/logrus/logrus.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ const (
7474
)
7575

7676
// Won't compile if StdLogger can't be realized by a log.Logger
77-
var _ StdLogger = &log.Logger{}
77+
var (
78+
_ StdLogger = &log.Logger{}
79+
_ StdLogger = &Entry{}
80+
_ StdLogger = &Logger{}
81+
)
7882

7983
// StdLogger is what your logrus-enabled library should take, that way
8084
// it'll accept a stdlib logger and a logrus logger. There's no standard

vendor/src/github.com/Sirupsen/logrus/terminal_openbsd.go renamed to vendor/src/github.com/Sirupsen/logrus/terminal_bsd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// +build darwin freebsd openbsd netbsd dragonfly
2+
13
package logrus
24

35
import "syscall"

0 commit comments

Comments
 (0)