Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: standardize logging #1302

Merged
merged 51 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
72f96cc
Initial slog switch
zivkovicmilos Oct 26, 2023
9328f52
Change log level
zivkovicmilos Oct 26, 2023
3abfc67
Merge branch 'feat/standardized-logging' into feat/log
zivkovicmilos Oct 26, 2023
a4449bd
Drop the logger backend in tm2
zivkovicmilos Oct 26, 2023
c08de43
Use custom zap config
zivkovicmilos Oct 26, 2023
035bbef
Use log level from config
zivkovicmilos Oct 26, 2023
e6dd5ac
Merge branch 'master' into feat/log
zivkovicmilos Oct 26, 2023
dec3fed
Update workflows
zivkovicmilos Oct 26, 2023
9aa5d7d
Remove test case because of Go 1.21
zivkovicmilos Oct 26, 2023
209041f
Resolve faulty log lines
zivkovicmilos Oct 26, 2023
568ff80
Revert go version change
zivkovicmilos Jan 15, 2024
be13b5d
Merge master
zivkovicmilos Jan 15, 2024
b32ea84
Tidy go mods
zivkovicmilos Jan 15, 2024
32603c2
Switch to /exp/log because of go 1.20
zivkovicmilos Jan 15, 2024
71787aa
Update gnodev logger usage:
zivkovicmilos Jan 15, 2024
28bebde
Please the go mod gods
zivkovicmilos Jan 15, 2024
5db0ddb
Add logger err case
zivkovicmilos Jan 15, 2024
13fefe7
Merge branch 'master' into feat/log
zivkovicmilos Jan 15, 2024
33f1934
fix: use zap logger specific initialization
gfanton Jan 15, 2024
75c7285
Resolve API changes
zivkovicmilos Jan 16, 2024
f23782f
Tidy loop go mod
zivkovicmilos Jan 16, 2024
655557b
Lowercase log format
zivkovicmilos Jan 16, 2024
c8b6d54
Move github.com/kr/pretty into indirect deps
zivkovicmilos Jan 22, 2024
db969ac
Move golang.org/x/exp into direct deps
zivkovicmilos Jan 22, 2024
a39674b
Remove duplicate defer
zivkovicmilos Jan 22, 2024
1c29d7c
Add import cleanup directive
zivkovicmilos Jan 22, 2024
a8e0dce
Move block to indirect imports; add mod linter
zivkovicmilos Jan 22, 2024
fe5f770
Remove leftover message from go.mods
zivkovicmilos Jan 22, 2024
4130b15
Add goimports CI
zivkovicmilos Jan 22, 2024
34e4087
Update gno.land/pkg/sdk/vm/keeper.go
zivkovicmilos Jan 22, 2024
d66b6f7
Update gno.land/pkg/sdk/vm/keeper.go
zivkovicmilos Jan 22, 2024
c3cd030
Merge branch 'master' into feat/log
zivkovicmilos Jan 22, 2024
795fe67
Make the linting gods happy
zivkovicmilos Jan 22, 2024
6779dc6
Merge branch 'master' into feat/log
zivkovicmilos Jan 23, 2024
01e4fd5
Add testing logger
zivkovicmilos Jan 23, 2024
6471c93
Tidy go mods
zivkovicmilos Jan 23, 2024
86ad349
Output the log to a dir
zivkovicmilos Jan 23, 2024
9e45196
Update workflows
zivkovicmilos Jan 23, 2024
301409a
fix: workflow debug env variable
gfanton Jan 23, 2024
821c01d
fix: fixup gnoland logs
gfanton Jan 23, 2024
09d3ec0
fix(ci): glob every log file into the artifact archive
gfanton Jan 23, 2024
de264d4
wip: test ci full logging
gfanton Jan 23, 2024
6b9230c
fix(log): replace slash by _ in log name to avoid sub-directory
gfanton Jan 23, 2024
27e2383
Enable debug artifacts
zivkovicmilos Jan 23, 2024
bac025e
Merge branch 'master' into feat/log
zivkovicmilos Jan 24, 2024
7eb92d2
Merge goimports format with 'fmt'
zivkovicmilos Jan 24, 2024
7720593
Update fmt CI
zivkovicmilos Jan 24, 2024
a8fe8d3
Update tidy workflow
zivkovicmilos Jan 24, 2024
9ab96d0
Simplify tidy workflows
zivkovicmilos Jan 24, 2024
89c7b62
Add basic base config verification
zivkovicmilos Jan 24, 2024
18727d8
Merge branch 'master' into feat/log
zivkovicmilos Jan 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ linters:
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13
- gofumpt # Stricter gofmt
- unused # Checks Go code for unused constants, variables, functions and types
- gomodguard # Enforces an allow and block list for direct Go module dependencies

linters-settings:
gofmt:
Expand All @@ -59,6 +60,17 @@ linters-settings:
- opinionated
- performance
- style
gomodguard:
blocked:
modules:
- log/slog:
recommendations:
- golang.org/x/exp
reason: "the minimum go version for the monorepo is 1.20"
versions:
- go.uber.org/zap/exp:
version: "> 0.1.0"
reason: "this version of zap/exp is a requirement until we upgrade to go 1.21 (https://github.com/uber-go/zap/blob/master/exp/CHANGELOG.md)"

issues:
whole-files: true
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/db-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ jobs:
wget http://ftp.us.debian.org/debian/pool/main/l/leveldb/libleveldb-dev_1.22-3_amd64.deb
sudo dpkg -i *.deb

- name: Set environment variables for debug mode
if: env.ACTIONS_STEP_DEBUG == 'true'
run: |
export LOG_PATH_DIR=${{ runner.temp }}/logs
mkdir -p $LOG_PATH_DIR

echo "LOG_LEVEL=debug" >> $GITHUB_ENV
echo "LOG_PATH_DIR=$LOG_PATH_DIR" >> $GITHUB_ENV

# test ./pkgs/db
- name: test ./tm2/pkg/db
run: go test -tags ${{ matrix.tags }} ./tm2/pkg/db/...
16 changes: 6 additions & 10 deletions .github/workflows/dependabot-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,14 @@ jobs:
go-version: 1.21.x

- name: Tidy all Go mods
env:
VERIFY_MOD_SUMS: false
run: |
set -e
# Find all go.mod files
gomods=$(find . -type f -name go.mod)

# Tidy each go.mod file
for modfile in $gomods; do
dir=$(dirname "$modfile")
# Ensure Make is installed
make --version

# Run go mod tidy in the directory
(cd "$dir" && go mod tidy -v) || exit 1
done
# Run the tidy target
make tidy

- name: Commit changes, if any
uses: stefanzweifel/git-auto-commit-action@v5
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.goversion }}
- name: Set environment variables for debug mode
if: env.ACTIONS_STEP_DEBUG == 'true'
run: |
export LOG_PATH_DIR=${{ runner.temp }}/logs
mkdir -p $LOG_PATH_DIR

echo "LOG_LEVEL=debug" >> $GITHUB_ENV
echo "LOG_PATH_DIR=$LOG_PATH_DIR" >> $GITHUB_ENV
- run: go install -v ./gnovm/cmd/gno
- run: go run ./gnovm/cmd/gno test --verbose ./examples/...
lint:
Expand Down
25 changes: 16 additions & 9 deletions .github/workflows/gnoland.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,32 +60,39 @@ jobs:
- _test.gnoland
- _test.gnokey
- _test.pkgs
- _test.gnoweb
- _test.gnoweb
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.goversion }}
- name: Set environment variables for debug mode
if: ${{ runner.debug == 1 }}
run: |
export LOG_PATH_DIR=${{ runner.temp }}/logs-go${{ matrix.goversion }}-${{ matrix.args }}
mkdir -p $LOG_PATH_DIR

echo "LOG_LEVEL=debug" >> $GITHUB_ENV
echo "LOG_PATH_DIR=$LOG_PATH_DIR" >> $GITHUB_ENV
- name: test
working-directory: gno.land
run: |
export GOPATH=$HOME/go
export GOTEST_FLAGS="-v -p 1 -timeout=30m -coverprofile=coverage.out -covermode=atomic"
export LOG_DIR="${{ runner.temp }}/logs/test-${{ matrix.goversion }}-gnoland"
make ${{ matrix.args }}
- name: Upload Test Log
if: always()
uses: actions/upload-artifact@v3
with:
name: logs-test-gnoland-go${{ matrix.goversion }}
path: ${{ runner.temp }}/logs/**/*.log
- uses: actions/upload-artifact@v3
if: ${{ runner.os == 'Linux' && matrix.goversion == '1.21.x' }}
with:
name: ${{runner.os}}-coverage-gnoland-${{ matrix.args}}-${{matrix.goversion}}
path: ./gno.land/coverage.out
- name: Upload Debug Logs
uses: actions/upload-artifact@v3
if: ${{ always() && runner.debug == 1 }}
with:
name: logs-test-go${{ matrix.goversion }}-${{ matrix.args }}
path: ${{ env.LOG_PATH_DIR }}/**/*

upload-coverage:
needs: test
Expand All @@ -99,7 +106,7 @@ jobs:
uses: codecov/codecov-action@v3
with:
directory: ${{ runner.temp }}/coverage
token: ${{ secrets.CODECOV_TOKEN }}
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: ${{ github.repository == 'gnolang/gno' }}

docker-integration:
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/gnovm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.goversion }}
- name: Set environment variables for debug mode
if: ${{ runner.debug == 1 }}
run: |
export LOG_PATH_DIR=${{ runner.temp }}/logs-go${{ matrix.goversion }}-${{ matrix.args }}
mkdir -p $LOG_PATH_DIR

echo "LOG_LEVEL=debug" >> $GITHUB_ENV
echo "LOG_PATH_DIR=$LOG_PATH_DIR" >> $GITHUB_ENV
- name: test
working-directory: gnovm
env:
Expand All @@ -92,6 +100,12 @@ jobs:
with:
name: ${{runner.os}}-coverage-gnovm-${{ matrix.args}}-${{matrix.goversion}}
path: ${{ env.COVERAGE_DIR }}
- name: Upload Debug Logs
uses: actions/upload-artifact@v3
if: ${{ always() && runner.debug == 1 }}
with:
name: logs-test-go${{ matrix.goversion }}-${{ matrix.args }}
path: ${{ env.LOG_PATH_DIR }}/**/*

upload-coverage:
needs: test
Expand Down Expand Up @@ -129,6 +143,6 @@ jobs:
uses: codecov/codecov-action@v3
with:
files: ${{ env.COVERAGE_PROFILE }}
token: ${{ secrets.CODECOV_TOKEN }}
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: ${{ github.repository == 'gnolang/gno' }}

33 changes: 13 additions & 20 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ jobs:

# inspired by:
# https://github.com/Jerome1337/gofmt-action/blob/d5eabd189843f1d568286a54578159978b7c0fb1/entrypoint.sh
- name: Check gofumpt
- name: Check gofumpt / goimports
run: |
output="$(GOFMT_FLAGS=-l make -s fmt)"
output="$(GOFMT_FLAGS=-l GOIMPORTS_FLAGS=-l make -s fmt)"
if [ ! -z "$output" ]; then
echo "The following files are not properly formatted; run 'make fmt' to format them."
echo "The following files are not properly formatted; run 'make fmt imports' to format them."
echo "$output"
exit 1
else
Expand All @@ -70,22 +70,15 @@ jobs:
with:
go-version: 1.21.x

- name: Install make
run: sudo apt-get install -y make

- name: Check go.mods
env:
VERIFY_MOD_SUMS: true
run: |
set -xe
# Find all go.mod files
gomods=$(find . -type f -name go.mod)

# Calculate sums for all go.mod files
sums=$(sha256sum $gomods)

# Iterate over each go.mod file
for modfile in $gomods; do
dir=$(dirname "$modfile")

# Run go mod tidy in the directory
(cd "$dir" && go mod tidy -v) || exit 1
done

# Verify the sums
echo "$sums" | sha256sum -c
# Ensure Make is installed
make --version

# Run the tidy target
make tidy
9 changes: 9 additions & 0 deletions .github/workflows/misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ jobs:
with:
go-version: ${{ matrix.goversion }}

- name: Set environment variables for debug mode
if: env.ACTIONS_STEP_DEBUG == 'true'
run: |
export LOG_PATH_DIR=${{ runner.temp }}/logs
mkdir -p $LOG_PATH_DIR

echo "LOG_LEVEL=debug" >> $GITHUB_ENV
echo "LOG_PATH_DIR=$LOG_PATH_DIR" >> $GITHUB_ENV

- name: Test
working-directory: misc
run: |
Expand Down
17 changes: 16 additions & 1 deletion .github/workflows/tm2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
working-directory: tm2
run: GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go install ${{ matrix.program }}


test:
strategy:
fail-fast: false
Expand All @@ -61,6 +62,14 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.goversion }}
- name: Set environment variables for debug mode
if: ${{ runner.debug == 1 }}
run: |
export LOG_PATH_DIR=${{ runner.temp }}/logs-go${{ matrix.goversion }}-${{ matrix.args }}
mkdir -p $LOG_PATH_DIR

echo "LOG_LEVEL=debug" >> $GITHUB_ENV
echo "LOG_PATH_DIR=$LOG_PATH_DIR" >> $GITHUB_ENV
- name: test
working-directory: tm2
run: |
Expand All @@ -73,6 +82,12 @@ jobs:
with:
name: ${{runner.os}}-coverage-tm2-${{ matrix.args}}-${{matrix.goversion}}
path: ./tm2/coverage.out
- name: Upload Debug Logs
uses: actions/upload-artifact@v3
if: ${{ always() && runner.debug == 1 }}
with:
name: logs-test-go${{ matrix.goversion }}-${{ matrix.args }}
path: ${{ env.LOG_PATH_DIR }}/**/*

upload-coverage:
needs: test
Expand All @@ -86,6 +101,6 @@ jobs:
uses: codecov/codecov-action@v3
with:
directory: ${{ runner.temp }}/coverage
token: ${{ secrets.CODECOV_TOKEN }}
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: ${{ github.repository == 'gnolang/gno' }}

10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ test.docker:

.PHONY: fmt
fmt:
$(MAKE) --no-print-directory -C tm2 fmt
$(MAKE) --no-print-directory -C gnovm fmt
$(MAKE) --no-print-directory -C gno.land fmt
$(MAKE) --no-print-directory -C tm2 fmt imports
$(MAKE) --no-print-directory -C gnovm fmt imports
$(MAKE) --no-print-directory -C gno.land fmt imports
$(MAKE) --no-print-directory -C examples fmt

.PHONY: lint
lint:
$(rundep) github.com/golangci/golangci-lint/cmd/golangci-lint run --config .github/golangci.yml

.PHONY: tidy
tidy:
$(MAKE) --no-print-directory -C misc tidy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please double-check? I vaguely recall creating something similar, possibly only in the CI. Just ensure that there isn't already an existing solution for the same purpose.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It turns out we had not 1, but 2 tidy flows 🙂

Fixed:
9ab96d0 and a8fe8d3

5 changes: 5 additions & 0 deletions contribs/gnodev/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ replace github.com/gnolang/gno => ../..
require (
github.com/fsnotify/fsnotify v1.7.0
github.com/gnolang/gno v0.0.0-00010101000000-000000000000
go.uber.org/zap v1.24.0
golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3
golang.org/x/term v0.16.0
)

Expand Down Expand Up @@ -38,6 +40,7 @@ require (
github.com/jaekwon/testify v1.6.1 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/klauspost/compress v1.12.3 // indirect
github.com/kr/pretty v0.2.1 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/linxGnu/grocksdb v1.8.11 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
Expand All @@ -50,7 +53,9 @@ require (
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
go.etcd.io/bbolt v1.3.8 // indirect
go.opencensus.io v0.22.5 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.10.0 // indirect
go.uber.org/zap/exp v0.1.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.20.0 // indirect
Expand Down
15 changes: 13 additions & 2 deletions contribs/gnodev/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading