Use *slog.Logger instead of slog.Logger in option (#74)
* Use *slog.Logger instead of slog.Logger in option * Update common_client.go Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
This commit is contained in:
+6
-2
@@ -146,9 +146,13 @@ func (c *commonClient) setUserAgent() {
|
|||||||
type HTTPOption func(*httpClientOption)
|
type HTTPOption func(*httpClientOption)
|
||||||
|
|
||||||
// WithLogger sets a custom logger for the Client.
|
// WithLogger sets a custom logger for the Client.
|
||||||
func WithLogger(logger slog.Logger) HTTPOption {
|
// If nil is passed, a discard logger will be used.
|
||||||
|
func WithLogger(logger *slog.Logger) HTTPOption {
|
||||||
return func(c *httpClientOption) {
|
return func(c *httpClientOption) {
|
||||||
c.logger = &logger
|
if logger == nil {
|
||||||
|
logger = slog.New(slog.DiscardHandler)
|
||||||
|
}
|
||||||
|
c.logger = logger
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user