调整封装的方法

This commit is contained in:
Yun
2025-12-28 15:14:05 +08:00
parent 8bca4cc013
commit 0931539e1c
6 changed files with 151 additions and 153 deletions
+13 -2
View File
@@ -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{})