mirror of https://github.com/sirupsen/logrus.git
Allow disabling timestamp in non-tty output.
This is useful if the output is already being piped to a logger daemon that will prefix the timestamp by itself (eg: on heroku).
This commit is contained in:
parent
1f2ba2c631
commit
3e9d38f80d
|
@ -34,6 +34,7 @@ type TextFormatter struct {
|
||||||
// Set to true to bypass checking for a TTY before outputting colors.
|
// Set to true to bypass checking for a TTY before outputting colors.
|
||||||
ForceColors bool
|
ForceColors bool
|
||||||
DisableColors bool
|
DisableColors bool
|
||||||
|
DisableTimestamp bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
|
func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
|
||||||
|
@ -53,7 +54,9 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
|
||||||
if isColored {
|
if isColored {
|
||||||
printColored(b, entry, keys)
|
printColored(b, entry, keys)
|
||||||
} else {
|
} else {
|
||||||
|
if !f.DisableTimestamp {
|
||||||
f.appendKeyValue(b, "time", entry.Time.Format(time.RFC3339))
|
f.appendKeyValue(b, "time", entry.Time.Format(time.RFC3339))
|
||||||
|
}
|
||||||
f.appendKeyValue(b, "level", entry.Level.String())
|
f.appendKeyValue(b, "level", entry.Level.String())
|
||||||
f.appendKeyValue(b, "msg", entry.Message)
|
f.appendKeyValue(b, "msg", entry.Message)
|
||||||
for _, key := range keys {
|
for _, key := range keys {
|
||||||
|
|
Loading…
Reference in New Issue