Documentation ¶
Index ¶
- Variables
- func AShortError(key string, err error) zap.Field
- func AbbreviatedArray(key string, elements any, marshalFunc func(any) []string) zap.Field
- func AbbreviatedStringers[T fmt.Stringer](key string, stringers []T) zap.Field
- func CL(c context.Context) *zap.Logger
- func ContextWithField(c context.Context, fields ...zap.Field) context.Context
- func File(file *backuppb.File) zap.Field
- func Files(fs []*backuppb.File) zap.Field
- func Key(fieldKey string, key []byte) zap.Field
- func Keys(keys [][]byte) zap.Field
- func Leader(peer *metapb.Peer) zap.Field
- func LoggerFromContext(c context.Context) *zap.Logger
- func MarshalLogObjectForFiles(files []*backuppb.File, encoder zapcore.ObjectEncoder) error
- func Peer(peer *metapb.Peer) zap.Field
- func Redact(field zap.Field) zap.Field
- func RedactAny(fieldKey string, key any) zap.Field
- func Region(region *metapb.Region) zap.Field
- func RegionBy(key string, region *metapb.Region) zap.Field
- func ResetGlobalLogger(l *zap.Logger)
- func RewriteRule(rewriteRule *import_sstpb.RewriteRule) zap.Field
- func RewriteRuleObject(rewriteRule *import_sstpb.RewriteRule) zapcore.ObjectMarshaler
- func SSTMeta(sstMeta *import_sstpb.SSTMeta) zap.Field
- func SSTMetas(sstMetas []*import_sstpb.SSTMeta) zap.Field
- func ShortError(err error) zap.Field
- func StreamBackupTaskInfo(t *backuppb.StreamBackupTaskInfo) zap.Field
- func StringifyMany[T fmt.Stringer](items []T) zapcore.ArrayMarshaler
- func WarnTerm(message string, fields ...zap.Field)
- type AbbreviatedArrayMarshaler
- type HexBytes
- type RateTracer
- type StringifyKeys
- type StringifyRange
Constants ¶
This section is empty.
Variables ¶
var MetricTableCreatedCounter = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "BR",
Name: "table_created",
Help: "The count of tables have been created.",
})
MetricTableCreatedCounter counts how many tables created. TODO: when br decided to introduce Prometheus, move this to its metric package.
Functions ¶
func AShortError ¶
AShortError make the zap field with key to display error without verbose representation (e.g. the stack trace).
func AbbreviatedArray ¶
AbbreviatedArray constructs a field that abbreviates an array of elements.
func AbbreviatedStringers ¶
func ContextWithField ¶
ContextWithField wrap a context with a logger with some fields.
func LoggerFromContext ¶
LoggerFromContext returns the contextual logger via the context. If there isn't a logger in the context, returns the global logger.
func MarshalLogObjectForFiles ¶
func MarshalLogObjectForFiles(files []*backuppb.File, encoder zapcore.ObjectEncoder) error
MarshalLogObjectForFiles is an internal util function to zap something having `Files` field.
func ResetGlobalLogger ¶
ResetGlobalLogger resets the global logger. Contexts have already made by `ContextWithField` would keep untouched, subsequent wrapping over those contexts would keep using the old global logger, only brand new contexts (i.e. context without logger) would be wrapped with the new global logger. This method is mainly for testing.
func RewriteRule ¶
func RewriteRule(rewriteRule *import_sstpb.RewriteRule) zap.Field
RewriteRule make the zap fields for a rewrite rule.
func RewriteRuleObject ¶
func RewriteRuleObject(rewriteRule *import_sstpb.RewriteRule) zapcore.ObjectMarshaler
RewriteRuleObject make zap object marshaler for a rewrite rule.
func SSTMeta ¶
func SSTMeta(sstMeta *import_sstpb.SSTMeta) zap.Field
SSTMeta make the zap fields for a SST meta.
func SSTMetas ¶
func SSTMetas(sstMetas []*import_sstpb.SSTMeta) zap.Field
SSTMetas make the zap fields for SST metas.
func ShortError ¶
ShortError make the zap field to display error without verbose representation (e.g. the stack trace).
func StreamBackupTaskInfo ¶
func StreamBackupTaskInfo(t *backuppb.StreamBackupTaskInfo) zap.Field
StreamBackupTaskInfo makes the zap fields for a stream backup task info.
func StringifyMany ¶
func StringifyMany[T fmt.Stringer](items []T) zapcore.ArrayMarshaler
StringifyMany returns an array marshaler for a slice of stringers.
Types ¶
type AbbreviatedArrayMarshaler ¶
type AbbreviatedArrayMarshaler []string
AbbreviatedArrayMarshaler abbreviates an array of elements.
func (AbbreviatedArrayMarshaler) MarshalLogArray ¶
func (abb AbbreviatedArrayMarshaler) MarshalLogArray(encoder zapcore.ArrayEncoder) error
MarshalLogArray implements zapcore.ArrayMarshaler.
type HexBytes ¶
type HexBytes []byte
HexBytes is a wrapper which make a byte sequence printed by the hex format.
func (HexBytes) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
type RateTracer ¶
type RateTracer struct { prometheus.Counter // contains filtered or unexported fields }
RateTracer is a trivial rate tracer based on a prometheus counter. It traces the average speed from it was created.
func TraceRateOver ¶
func TraceRateOver(counter prometheus.Counter) RateTracer
TraceRateOver make a trivial rater based on a counter. the current value of this counter would be omitted.
func (*RateTracer) Rate ¶
func (r *RateTracer) Rate() float64
Rate returns the average rate from when it was created.
type StringifyKeys ¶
StringifyKeys wraps the key range into a stringer.
func (StringifyKeys) String ¶
func (kr StringifyKeys) String() string
type StringifyRange ¶
StringifyRange is the wrapper for displaying a key range.
func StringifyRangeOf ¶
func StringifyRangeOf(start, end []byte) StringifyRange
func (StringifyRange) String ¶
func (rng StringifyRange) String() string