Add Bytes() method to Entry, and use it to avoid double type cast

This commit is contained in:
tbunyk
2019-03-18 16:07:31 +02:00
parent 470f2e08fc
commit c88f8de1fe
2 changed files with 8 additions and 3 deletions
+6 -1
View File
@@ -85,10 +85,15 @@ func NewEntry(logger *Logger) *Entry {
}
}
// Returns the bytes representation of this entry from the formatter.
func (entry *Entry) Bytes() ([]byte, error) {
return entry.Logger.Formatter.Format(entry)
}
// Returns the string representation from the reader and ultimately the
// formatter.
func (entry *Entry) String() (string, error) {
serialized, err := entry.Logger.Formatter.Format(entry)
serialized, err := entry.Bytes()
if err != nil {
return "", err
}