Skip to content

Refactor logging#30

Merged
bitgamma merged 5 commits intokeycard-tech:developfrom
willianpaixao:bugfix-logging
Sep 9, 2025
Merged

Refactor logging#30
bitgamma merged 5 commits intokeycard-tech:developfrom
willianpaixao:bugfix-logging

Conversation

@willianpaixao
Copy link
Contributor

Refactors logging implementation from deprecated Ethereum logging package to Go's standard log/slog, improving maintainability and eliminating deprecated dependencies.

  • Migrated from github.com/ethereum/go-ethereum/log to standard log/slog package
  • Replaced string-based log levels with typed slog.Level constants
  • Updated all stdlog.Fatal() calls to structured log.Error() calls
  • Fixed deprecated time.Now().Sub() to time.Since() in installer

Copilot AI review requested due to automatic review settings September 8, 2025 09:37
Copy link

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 refactors the logging implementation from the deprecated Ethereum logging package to Go's standard log/slog, improving maintainability and eliminating deprecated dependencies.

  • Migrated from github.com/ethereum/go-ethereum/log to standard log/slog package for type safety
  • Replaced all stdlog.Fatal() calls with structured log.Error() calls to avoid abrupt termination
  • Fixed deprecated time.Now().Sub() to time.Since() for better performance

Reviewed Changes

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

File Description
main.go Refactored logging initialization to use slog.Level constants and replaced fatal calls with structured error logging
installer.go Updated time calculation to use time.Since() and improved formatting precision
go.mod Updated dependencies to newer versions supporting the logging changes

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


if err := app.Run(context.Background(), os.Args); err != nil {
stdlog.Fatal(err)
log.Error("application error", "error", err)
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

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

The application continues execution after logging an error, but this should terminate the program since it replaced stdlog.Fatal(). Add os.Exit(1) after the log statement to maintain the original behavior.

Suggested change
log.Error("application error", "error", err)
log.Error("application error", "error", err)
os.Exit(1)

Copilot uses AI. Check for mistakes.
text, err := r.ReadString('\n')
if err != nil {
stdlog.Fatal(err)
log.Error("error reading input", "error", err)
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

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

The function continues execution after logging an error, but this should terminate the program since it replaced stdlog.Fatal(). Add os.Exit(1) after the log statement to maintain the original behavior.

Suggested change
log.Error("error reading input", "error", err)
log.Error("error reading input", "error", err)
os.Exit(1)

Copilot uses AI. Check for mistakes.
data, err := hex.DecodeString(s)
if err != nil {
stdlog.Fatal(err)
log.Error("error decoding hex", "error", err)
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

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

The function continues execution after logging an error, but this should terminate the program since it replaced stdlog.Fatal(). Add os.Exit(1) after the log statement to maintain the original behavior.

Copilot uses AI. Check for mistakes.
i, err := strconv.ParseInt(s, 10, 8)
if err != nil {
stdlog.Fatal(err)
log.Error("error parsing integer", "error", err)
Copy link

Copilot AI Sep 8, 2025

Choose a reason for hiding this comment

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

The function continues execution after logging an error, but this should terminate the program since it replaced stdlog.Fatal(). Add os.Exit(1) after the log statement to maintain the original behavior.

Suggested change
log.Error("error parsing integer", "error", err)
log.Error("error parsing integer", "error", err)
os.Exit(1)

Copilot uses AI. Check for mistakes.
@bitgamma bitgamma merged commit 821b884 into keycard-tech:develop Sep 9, 2025
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