Skip to content

fix #21#22

Merged
xzyaoi merged 4 commits intomainfrom
fix/#21
Feb 12, 2026
Merged

fix #21#22
xzyaoi merged 4 commits intomainfrom
fix/#21

Conversation

@xzyaoi
Copy link
Contributor

@xzyaoi xzyaoi commented Feb 12, 2026

No description provided.

Copilot AI review requested due to automatic review settings February 12, 2026 09:59
@xzyaoi
Copy link
Contributor Author

xzyaoi commented Feb 12, 2026

@copilot review this PR.

Copy link
Contributor

Copilot AI commented Feb 12, 2026

@xzyaoi I've opened a new pull request, #23, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR appears to address issue #21 by improving runtime configuration of logging and slightly adjusting operational behavior/log verbosity in the P2P/protocol layer.

Changes:

  • Add common.InitLogger() to allow logger re-initialization after Viper config/env is loaded, with more flexible loglevel parsing.
  • Adjust protocol startup/error handling and reduce periodic connection summary logging from Info to Debug.
  • Update dependencies (notably testify) and add an initial README.md.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/internal/protocol/host.go Replaces panics with logging + os.Exit(1) during P2P host initialization.
src/internal/protocol/clock.go Lowers connection summary log level from Info to Debug.
src/internal/common/logger.go Introduces InitLogger() and enhances log level configuration parsing.
src/entry/cmd/root.go Enables Viper env support and re-initializes logger after config setup.
src/go.mod Bumps testify and adds indirect deps.
src/go.sum Updates dependency checksums accordingly.
README.md Adds initial project description.
Comments suppressed due to low confidence (1)

src/internal/common/logger.go:43

  • zapLogger.Sync() is no longer called anywhere (the only call site is commented out). Without syncing on shutdown, buffered logs can be lost. Consider returning the built *zap.Logger (or exposing a SyncLogger()), and calling Sync() from main()/shutdown handling rather than in init().
	zapLogger, err := config.Build()
	// defer func() { _ = zapLogger.Sync() }()
	if err != nil {
		panic(err)
	}
	Logger = zapLogger.Sugar()
}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 56 to 61
host, err := newHost(ctx, seedInt, ds)
MyID = host.ID().String()
P2PNode = &host
if err != nil {
panic(err)
common.Logger.Error("Error while creating P2P node: ", err)
os.Exit(1)
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

host, err := newHost(...) is used (via host.ID().String()) before checking err. If newHost returns a nil host on error, this will panic before the error is logged/handled. Move the err check immediately after newHost and only set MyID/P2PNode when err == nil.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

xzyaoi and others added 2 commits February 12, 2026 11:04
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Xiaozhe Yao <xiaozhe.yaoi@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Xiaozhe Yao <xiaozhe.yaoi@gmail.com>
Copy link
Contributor

Copilot AI commented Feb 12, 2026

@xzyaoi I've opened a new pull request, #24, to work on those changes. Once the pull request is ready, I'll request review from you.

…24)

* Initial plan

* Fix error handling in GetP2PNode - check err before using host

Co-authored-by: xzyaoi <10499297+xzyaoi@users.noreply.github.com>

* Complete fix for error handling review feedback

Co-authored-by: xzyaoi <10499297+xzyaoi@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: xzyaoi <10499297+xzyaoi@users.noreply.github.com>
@xzyaoi xzyaoi merged commit 7d3f9bd into main Feb 12, 2026
2 checks passed
@xzyaoi xzyaoi deleted the fix/#21 branch February 12, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants