gotosocial/vendor/codeberg.org/gruf/go-logger/format.go

88 lines
3.1 KiB
Go
Raw Normal View History

2021-11-13 12:29:08 +01:00
package logger
import (
"time"
"codeberg.org/gruf/go-bytes"
)
// Check our types impl LogFormat
var _ LogFormat = &TextFormat{}
// Formattable defines a type capable of writing a string formatted form
// of itself to a supplied byte buffer, and returning the resulting byte
// buffer. Implementing this will greatly speed up formatting of custom
// types passed to LogFormat (assuming they implement checking for this).
type Formattable interface {
AppendFormat([]byte) []byte
}
2021-11-13 12:29:08 +01:00
// LogFormat defines a method of formatting log entries
type LogFormat interface {
// AppendKey appends given key to the log buffer
AppendKey(buf *bytes.Buffer, key string)
// AppendLevel appends given log level as key-value pair to the log buffer
2021-11-13 12:29:08 +01:00
AppendLevel(buf *bytes.Buffer, lvl LEVEL)
// AppendTimestamp appends given timestamp string as key-value pair to the log buffer
2021-11-27 15:26:58 +01:00
AppendTimestamp(buf *bytes.Buffer, fmtNow string)
2021-11-13 12:29:08 +01:00
2021-11-27 15:26:58 +01:00
// AppendValue appends given interface formatted as value to the log buffer
AppendValue(buf *bytes.Buffer, value interface{})
2021-11-13 12:29:08 +01:00
// AppendByte appends given byte value to the log buffer
AppendByte(buf *bytes.Buffer, value byte)
2021-11-13 12:29:08 +01:00
// AppendBytes appends given byte slice value to the log buffer
AppendBytes(buf *bytes.Buffer, value []byte)
2021-11-13 12:29:08 +01:00
// AppendString appends given string value to the log buffer
AppendString(buf *bytes.Buffer, value string)
2021-11-13 12:29:08 +01:00
// AppendStrings appends given string slice value to the log buffer
AppendStrings(buf *bytes.Buffer, value []string)
2021-11-13 12:29:08 +01:00
// AppendBool appends given bool value to the log buffer
AppendBool(buf *bytes.Buffer, value bool)
2021-11-13 12:29:08 +01:00
// AppendBools appends given bool slice value to the log buffer
AppendBools(buf *bytes.Buffer, value []bool)
2021-11-13 12:29:08 +01:00
// AppendInt appends given int value to the log buffer
AppendInt(buf *bytes.Buffer, value int)
2021-11-13 12:29:08 +01:00
// AppendInts appends given int slice value to the log buffer
AppendInts(buf *bytes.Buffer, value []int)
2021-11-13 12:29:08 +01:00
// AppendUint appends given uint value to the log buffer
AppendUint(buf *bytes.Buffer, value uint)
2021-11-13 12:29:08 +01:00
// AppendUints appends given uint slice value to the log buffer
AppendUints(buf *bytes.Buffer, value []uint)
2021-11-13 12:29:08 +01:00
// AppendFloat appends given float value to the log buffer
AppendFloat(buf *bytes.Buffer, value float64)
2021-11-13 12:29:08 +01:00
// AppendFloats appends given float slice value to the log buffer
AppendFloats(buf *bytes.Buffer, value []float64)
2021-11-13 12:29:08 +01:00
// AppendTime appends given time value to the log buffer
AppendTime(buf *bytes.Buffer, value time.Time)
2021-11-13 12:29:08 +01:00
// AppendTimes appends given time slice value to the log buffer
AppendTimes(buf *bytes.Buffer, value []time.Time)
2021-11-13 12:29:08 +01:00
// AppendDuration appends given duration value to the log buffer
AppendDuration(buf *bytes.Buffer, value time.Duration)
2021-11-13 12:29:08 +01:00
// AppendDurations appends given duration slice value to the log buffer
AppendDurations(buf *bytes.Buffer, value []time.Duration)
2021-11-13 12:29:08 +01:00
2021-11-27 15:26:58 +01:00
// AppendMsg appends given msg as key-value pair to the log buffer using fmt.Sprint(...) formatting
AppendMsg(buf *bytes.Buffer, a ...interface{})
2021-11-13 12:29:08 +01:00
2021-11-27 15:26:58 +01:00
// AppendMsgf appends given msg format string as key-value pair to the log buffer using fmt.Sprintf(...) formatting
AppendMsgf(buf *bytes.Buffer, s string, a ...interface{})
2021-11-13 12:29:08 +01:00
}