forked from mirror/logrus
Merge pull request #91 from rasky/disable-timestamp
Allow disabling timestamp in non-tty output.
This commit is contained in:
commit
7096056d3c
|
@ -34,6 +34,9 @@ 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
|
||||||
|
// Set to true to disable timestamp logging (useful when the output
|
||||||
|
// is redirected to a logging system already adding a timestamp)
|
||||||
|
DisableTimestamp bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
|
func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
|
||||||
|
@ -53,7 +56,9 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
|
||||||
if isColored {
|
if isColored {
|
||||||
printColored(b, entry, keys)
|
printColored(b, entry, keys)
|
||||||
} else {
|
} else {
|
||||||
f.appendKeyValue(b, "time", entry.Time.Format(time.RFC3339))
|
if !f.DisableTimestamp {
|
||||||
|
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