Merge branch 'master' of https://github.com/Sirupsen/logrus
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
# 0.8
|
||||||
|
|
||||||
|
logrus: defaults to stderr instead of stdout
|
||||||
|
|
||||||
# 0.7.3
|
# 0.7.3
|
||||||
|
|
||||||
formatter/\*: allow configuration of timestamp layout
|
formatter/\*: allow configuration of timestamp layout
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ ocean","size":10,"time":"2014-03-10 19:57:38.562264131 -0400 EDT"}
|
|||||||
"time":"2014-03-10 19:57:38.562543128 -0400 EDT"}
|
"time":"2014-03-10 19:57:38.562543128 -0400 EDT"}
|
||||||
```
|
```
|
||||||
|
|
||||||
With the default `log.Formatter = new(logrus.TextFormatter)` when a TTY is not
|
With the default `log.Formatter = new(&log.TextFormatter{})` when a TTY is not
|
||||||
attached, the output is compatible with the
|
attached, the output is compatible with the
|
||||||
[logfmt](http://godoc.org/github.com/kr/logfmt) format:
|
[logfmt](http://godoc.org/github.com/kr/logfmt) format:
|
||||||
|
|
||||||
@@ -269,7 +269,7 @@ init() {
|
|||||||
log.SetFormatter(logrus.JSONFormatter)
|
log.SetFormatter(logrus.JSONFormatter)
|
||||||
} else {
|
} else {
|
||||||
// The TextFormatter is default, you don't actually have to do this.
|
// The TextFormatter is default, you don't actually have to do this.
|
||||||
log.SetFormatter(logrus.TextFormatter)
|
log.SetFormatter(&log.TextFormatter{})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ type Logger struct {
|
|||||||
// It's recommended to make this a global instance called `log`.
|
// It's recommended to make this a global instance called `log`.
|
||||||
func New() *Logger {
|
func New() *Logger {
|
||||||
return &Logger{
|
return &Logger{
|
||||||
Out: os.Stdout,
|
Out: os.Stderr,
|
||||||
Formatter: new(TextFormatter),
|
Formatter: new(TextFormatter),
|
||||||
Hooks: make(levelHooks),
|
Hooks: make(levelHooks),
|
||||||
Level: InfoLevel,
|
Level: InfoLevel,
|
||||||
|
|||||||
+1
-1
@@ -191,7 +191,7 @@ func TestUserSuppliedLevelFieldHasPrefix(t *testing.T) {
|
|||||||
log.WithField("level", 1).Info("test")
|
log.WithField("level", 1).Info("test")
|
||||||
}, func(fields Fields) {
|
}, func(fields Fields) {
|
||||||
assert.Equal(t, fields["level"], "info")
|
assert.Equal(t, fields["level"], "info")
|
||||||
assert.Equal(t, fields["fields.level"], 1)
|
assert.Equal(t, fields["fields.level"], 1.0) // JSON has floats only
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -3,6 +3,7 @@ package logrus
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -69,7 +70,8 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
|
|||||||
|
|
||||||
prefixFieldClashes(entry.Data)
|
prefixFieldClashes(entry.Data)
|
||||||
|
|
||||||
isColored := (f.ForceColors || isTerminal) && !f.DisableColors
|
isColorTerminal := isTerminal && (runtime.GOOS != "windows")
|
||||||
|
isColored := (f.ForceColors || isColorTerminal) && !f.DisableColors
|
||||||
|
|
||||||
if f.TimestampFormat == "" {
|
if f.TimestampFormat == "" {
|
||||||
f.TimestampFormat = DefaultTimestampFormat
|
f.TimestampFormat = DefaultTimestampFormat
|
||||||
|
|||||||
Reference in New Issue
Block a user