logs-fix-5
This commit is contained in:
parent
d6fec9121c
commit
934f433dd2
|
@ -1,18 +1,15 @@
|
||||||
package logs
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
|
||||||
|
|
||||||
// LogTextFormatter is a custom log formatter for text output
|
// LogTextFormatter is a custom log formatter for text output
|
||||||
type LogTextFormatter struct {
|
type LogTextFormatter struct {
|
||||||
logrus.Formatter
|
logrus.Formatter
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format helps fomratting time to UTC
|
// Format helps formatting time to UTC
|
||||||
func (u LogTextFormatter) Format(e *logrus.Entry) ([]byte, error) {
|
func (u LogTextFormatter) Format(e *logrus.Entry) ([]byte, error) {
|
||||||
return []byte(fmt.Sprintf("[%s] %s", strings.ToUpper(e.Level.String()), e.Message)), nil
|
timestamp := e.Time.Format("2006-01-02 15:04:05.000")
|
||||||
|
level := strings.ToUpper(e.Level.String())
|
||||||
|
message := e.Message
|
||||||
|
file := path.Base(e.Caller.File)
|
||||||
|
line := e.Caller.Line
|
||||||
|
|
||||||
|
return []byte(fmt.Sprintf("%s [%s] %s:%d %s\n", timestamp, level, file, line, message)), nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user