调整封装的方法
This commit is contained in:
+13
-2
@@ -10,12 +10,14 @@ type clientOptions struct {
|
||||
TimeOut time.Duration
|
||||
InsecureSkipVerify bool
|
||||
Logger OptionLogger
|
||||
LoggerLength int // 日志输出长度
|
||||
}
|
||||
|
||||
func defaultOptions() clientOptions {
|
||||
return clientOptions{
|
||||
TimeOut: time.Second * 120, // 默认超时120
|
||||
Logger: defaultLogger{},
|
||||
TimeOut: time.Second * 120, // 默认超时120
|
||||
Logger: defaultLogger{},
|
||||
LoggerLength: 100,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +50,15 @@ func SetOptionLog(log OptionLogger) Option {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置日志输出长度
|
||||
*/
|
||||
func WithLoggerLength(length int) Option {
|
||||
return func(options *clientOptions) {
|
||||
options.LoggerLength = length
|
||||
}
|
||||
}
|
||||
|
||||
type OptionLogger interface {
|
||||
Infof(ctx context.Context, format string, args ...interface{})
|
||||
Errorf(ctx context.Context, format string, args ...interface{})
|
||||
|
||||
Reference in New Issue
Block a user