From a0322b7d2134fb8d42e4e7f438c8234c58c9e168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Wed, 7 Aug 2024 23:55:42 +0800 Subject: [PATCH] fix(ci): debug log printing --- .github/workflows/ci.yml | 5 ++++- gold/p2p/tcp/tcp.go | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 76923d7..648437d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,12 +18,15 @@ jobs: - name: Get dependencies run: go mod tidy + + - name: Enable Debug Log + run: sed -i '' 's/false/true/g' config/global.go - name: Build run: go build -v ./... - name: Test - run: sudo go test -ldflags "-X github.com/fumiama/WireGold/config.ShowDebugLog=true" $(go list ./...) # ip test needs sudo + run: sudo go test $(go list ./...) # ip test needs sudo lint: name: Lint diff --git a/gold/p2p/tcp/tcp.go b/gold/p2p/tcp/tcp.go index d197168..2c7c552 100644 --- a/gold/p2p/tcp/tcp.go +++ b/gold/p2p/tcp/tcp.go @@ -448,7 +448,9 @@ func (conn *Conn) WriteToPeer(b []byte, ep p2p.EndPoint) (n int, err error) { return 0, errors.New("data size " + strconv.Itoa(len(b)) + " is too large") } if (!conn.suberr || len(conn.subs) > 0) && !conn.cplk.TryLock() { - logrus.Infoln("[tcp] try sub write") + if config.ShowDebugLog { + logrus.Debug("[tcp] try sub write to", tcpep) + } n, err = conn.writeToPeer(b, tcpep, true) // try sub write if err == nil { return