fixed visibility of structs.

This commit is contained in:
Pradyumna Kaushik 2019-12-05 23:02:08 -05:00
parent f084eddd68
commit 5a53998942
9 changed files with 61 additions and 61 deletions

View file

@ -0,0 +1,36 @@
package logging
import (
"bytes"
"fmt"
"strings"
log "github.com/sirupsen/logrus"
)
type elektronFormatter struct {
TimestampFormat string
}
func (f elektronFormatter) Format(entry *log.Entry) ([]byte, error) {
var b *bytes.Buffer
if entry.Buffer != nil {
b = entry.Buffer
} else {
b = &bytes.Buffer{}
}
level := fmt.Sprintf("[%s]:", strings.ToUpper(entry.Level.String()))
message := strings.Join([]string{level, entry.Time.Format(f.TimestampFormat), entry.Message, " "}, " ")
var formattedFields []string
for key, value := range entry.Data {
formattedFields = append(formattedFields, strings.Join([]string{key, value.(string)}, "="))
}
b.WriteString(message)
b.WriteString(strings.Join(formattedFields, ", "))
b.WriteByte('\n')
return b.Bytes(), nil
}