Skip to content

Commit 1a347b2

Browse files
authored
allow to customize the default logger (dapr#496)
Signed-off-by: Gustavo Chain <me@qustavo.cc>
1 parent ac26e62 commit 1a347b2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

client/client.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@ var (
6161
defaultClient Client
6262
)
6363

64+
// SetLogger sets the global logger for the Dapr client.
65+
// The default logger has a destination of os.Stdout, SetLogger allows you to
66+
// optionally specify a custom logger (with a custom destination).
67+
// To disable client logging entirely, use a nil argument e.g.: client.SetLogger(nil)
68+
func SetLogger(l *log.Logger) {
69+
if l == nil {
70+
l = log.New(io.Discard, "", 0)
71+
}
72+
73+
logger = l
74+
}
75+
6476
// Client is the interface for Dapr client implementation.
6577
//
6678
//nolint:interfacebloat

0 commit comments

Comments
 (0)