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{}
|
|
|
|
|
|
|
|
// LogFormat defines a method of formatting log entries
|
|
|
|
type LogFormat interface {
|
2021-11-27 15:26:58 +01:00
|
|
|
// AppendLevel appends given log level to the log buffer
|
2021-11-13 12:29:08 +01:00
|
|
|
AppendLevel(buf *bytes.Buffer, lvl LEVEL)
|
|
|
|
|
2021-11-27 15:26:58 +01:00
|
|
|
// AppendTimestamp appends given time format string to the log buffer
|
|
|
|
AppendTimestamp(buf *bytes.Buffer, fmtNow string)
|
2021-11-13 12:29:08 +01:00
|
|
|
|
2021-11-27 15:26:58 +01:00
|
|
|
// AppendField appends given key-value pair to the log buffer
|
|
|
|
AppendField(buf *bytes.Buffer, key string, value interface{})
|
2021-11-13 12:29:08 +01:00
|
|
|
|
2021-11-27 15:26:58 +01:00
|
|
|
// AppendFields appends given key-values pairs to the log buffer
|
|
|
|
AppendFields(buf *bytes.Buffer, fields map[string]interface{})
|
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
|
|
|
|
2021-11-27 15:26:58 +01:00
|
|
|
// AppendValues appends given interfaces formatted as values to the log buffer
|
|
|
|
AppendValues(buf *bytes.Buffer, slice []interface{})
|
2021-11-13 12:29:08 +01:00
|
|
|
|
2021-11-27 15:26:58 +01:00
|
|
|
// AppendArgs appends given interfaces raw to the log buffer
|
|
|
|
AppendArgs(buf *bytes.Buffer, args []interface{})
|
2021-11-13 12:29:08 +01:00
|
|
|
|
2021-11-27 15:26:58 +01:00
|
|
|
// AppendByteField appends given byte value as key-value pair to the log buffer
|
|
|
|
AppendByteField(buf *bytes.Buffer, key string, value byte)
|
2021-11-13 12:29:08 +01:00
|
|
|
|
2021-11-27 15:26:58 +01:00
|
|
|
// AppendBytesField appends given byte slice value as key-value pair to the log buffer
|
|
|
|
AppendBytesField(buf *bytes.Buffer, key string, value []byte)
|
2021-11-13 12:29:08 +01:00
|
|
|
|
2021-11-27 15:26:58 +01:00
|
|
|
// AppendStringField appends given string value as key-value pair to the log buffer
|
|
|
|
AppendStringField(buf *bytes.Buffer, key string, value string)
|
2021-11-13 12:29:08 +01:00
|
|
|
|
2021-11-27 15:26:58 +01:00
|
|
|
// AppendStringsField appends given string slice value as key-value pair to the log buffer
|
|
|
|
AppendStringsField(buf *bytes.Buffer, key string, value []string)
|
2021-11-13 12:29:08 +01:00
|
|
|
|
2021-11-27 15:26:58 +01:00
|
|
|
// AppendBoolField appends given bool value as key-value pair to the log buffer
|
|
|
|
AppendBoolField(buf *bytes.Buffer, key string, value bool)
|
2021-11-13 12:29:08 +01:00
|
|
|
|
2021-11-27 15:26:58 +01:00
|
|
|
// AppendBoolsField appends given bool slice value as key-value pair to the log buffer
|
|
|
|
AppendBoolsField(buf *bytes.Buffer, key string, value []bool)
|
2021-11-13 12:29:08 +01:00
|
|
|
|
2021-11-27 15:26:58 +01:00
|
|
|
// AppendIntField appends given int value as key-value pair to the log buffer
|
|
|
|
AppendIntField(buf *bytes.Buffer, key string, value int)
|
2021-11-13 12:29:08 +01:00
|
|
|
|
2021-11-27 15:26:58 +01:00
|
|
|
// AppendIntsField appends given int slice value as key-value pair to the log buffer
|
|
|
|
AppendIntsField(buf *bytes.Buffer, key string, value []int)
|
2021-11-13 12:29:08 +01:00
|
|
|
|
2021-11-27 15:26:58 +01:00
|
|
|
// AppendUintField appends given uint value as key-value pair to the log buffer
|
|
|
|
AppendUintField(buf *bytes.Buffer, key string, value uint)
|
2021-11-13 12:29:08 +01:00
|
|
|
|
2021-11-27 15:26:58 +01:00
|
|
|
// AppendUintsField appends given uint slice value as key-value pair to the log buffer
|
|
|
|
AppendUintsField(buf *bytes.Buffer, key string, value []uint)
|
2021-11-13 12:29:08 +01:00
|
|
|
|
2021-11-27 15:26:58 +01:00
|
|
|
// AppendFloatField appends given float value as key-value pair to the log buffer
|
|
|
|
AppendFloatField(buf *bytes.Buffer, key string, value float64)
|
2021-11-13 12:29:08 +01:00
|
|
|
|
2021-11-27 15:26:58 +01:00
|
|
|
// AppendFloatsField appends given float slice value as key-value pair to the log buffer
|
|
|
|
AppendFloatsField(buf *bytes.Buffer, key string, value []float64)
|
2021-11-13 12:29:08 +01:00
|
|
|
|
2021-11-27 15:26:58 +01:00
|
|
|
// AppendTimeField appends given time value as key-value pair to the log buffer
|
|
|
|
AppendTimeField(buf *bytes.Buffer, key string, value time.Time)
|
2021-11-13 12:29:08 +01:00
|
|
|
|
2021-11-27 15:26:58 +01:00
|
|
|
// AppendTimesField appends given time slice value as key-value pair to the log buffer
|
|
|
|
AppendTimesField(buf *bytes.Buffer, key string, value []time.Time)
|
2021-11-13 12:29:08 +01:00
|
|
|
|
2021-11-27 15:26:58 +01:00
|
|
|
// AppendDurationField appends given duration value as key-value pair to the log buffer
|
|
|
|
AppendDurationField(buf *bytes.Buffer, key string, value time.Duration)
|
2021-11-13 12:29:08 +01:00
|
|
|
|
2021-11-27 15:26:58 +01:00
|
|
|
// AppendDurationsField appends given duration slice value as key-value pair to the log buffer
|
|
|
|
AppendDurationsField(buf *bytes.Buffer, key string, 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
|
|
|
}
|