Browse Source

[🚀] RestyClientLogger

bvbej 1 year ago
parent
commit
5beafd5252
1 changed files with 21 additions and 0 deletions
  1. 21 0
      pkg/logger/logger.go

+ 21 - 0
pkg/logger/logger.go

@@ -252,3 +252,24 @@ func WrapMeta(err error, metas ...Meta) (fields []zap.Field) {
 
 	return
 }
+
+// RestyClientLogger use by resty.Client
+func RestyClientLogger(logger *zap.Logger) *RestyClientLog {
+	return &RestyClientLog{logger: logger}
+}
+
+type RestyClientLog struct {
+	logger *zap.Logger
+}
+
+func (r *RestyClientLog) Errorf(format string, v ...any) {
+	r.logger.Sugar().Errorf(format, v)
+}
+
+func (r *RestyClientLog) Warnf(format string, v ...any) {
+	r.logger.Sugar().Warnf(format, v)
+}
+
+func (r *RestyClientLog) Debugf(format string, v ...any) {
+	r.logger.Sugar().Debugf(format, v)
+}