Skip to content

Commit b62fe92

Browse files
committed
chore(log): add note related to logging and simple void logger
1 parent 4dc03fc commit b62fe92

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

internal/log.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import (
77
"os"
88
)
99

10+
// TODO (ned): Revisit logging
11+
// Add more standardized approach with log levels and configurability
12+
1013
type Logging interface {
1114
Printf(ctx context.Context, format string, v ...interface{})
1215
}
@@ -24,3 +27,13 @@ func (l *logger) Printf(ctx context.Context, format string, v ...interface{}) {
2427
var Logger Logging = &logger{
2528
log: log.New(os.Stderr, "redis: ", log.LstdFlags|log.Lshortfile),
2629
}
30+
31+
// VoidLogger is a logger that does nothing.
32+
// Used to disable logging and thus speed up the library.
33+
type VoidLogger struct{}
34+
35+
func (v *VoidLogger) Printf(_ context.Context, _ string, _ ...interface{}) {
36+
// do nothing
37+
}
38+
39+
var _ Logging = (*VoidLogger)(nil)

redis.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type Scanner = hscan.Scanner
2424
const Nil = proto.Nil
2525

2626
// SetLogger set custom log
27+
// Use with VoidLogger to disable logging.
2728
func SetLogger(logger internal.Logging) {
2829
internal.Logger = logger
2930
}

0 commit comments

Comments
 (0)