From 3f51fb39cb3d2a5796d33a2164151a70da5191ae Mon Sep 17 00:00:00 2001 From: Yun Date: Sun, 1 Mar 2026 19:03:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=97=A5=E5=BF=97=E6=89=93?= =?UTF-8?q?=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- curlx.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/curlx.go b/curlx.go index 58319eb..0633ed0 100644 --- a/curlx.go +++ b/curlx.go @@ -179,7 +179,14 @@ func (c *Curlx) exec(ctx context.Context, ps ...Param) Response { for _, param := range ps { param(&p) } - c.opts.Logger.Infof(ctx, "curlx.sendExec params:%+v", p) + + // 截取Body前指定长度输出,避免日志过大 + bodyLog := []rune(string(p.Body)) + if len(bodyLog) > c.opts.LoggerLength { + bodyLog = bodyLog[:c.opts.LoggerLength] + } + + c.opts.Logger.Infof(ctx, "curlx.sendExec params url:%s method:%s contentType:%s body:%s headers:%+v cookies:%+v", p.Url, p.Method, p.ContentType, string(bodyLog), p.Headers, p.Cookies) err := p.parseMethod() if err != nil {