Skip to content

fix: use log.Printf instead of log.Println for formatted error logs - #6

Merged
moghit-eou merged 1 commit into
moghit-eou:mainfrom
AHS0003:fix/log-printf-format-verbs-v2
Aug 14, 2026
Merged

fix: use log.Printf instead of log.Println for formatted error logs#6
moghit-eou merged 1 commit into
moghit-eou:mainfrom
AHS0003:fix/log-printf-format-verbs-v2

Conversation

@AHS0003

@AHS0003 AHS0003 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Problem

log.Println does not interpret format verbs like %v, so the two
error logs in server.go printed the literal string "%v" instead of
the actual error message making them useless for debugging.

Fix

Replaced log.Println with log.Printf in both call sites (server
startup failure and connection accept failure).

Testing

  • go build ./internal/... passes
  • Verified in a running container: triggered a real bind error
    (port already in use) and confirmed the log now shows the
    properly formatted error message instead of a literal %v

@@ -22,7 +22,7 @@ func NewServer(handler *control.Handler) *Server {
func (s *Server) Start(port string) {
Listener, err := net.Listen("tcp", ":"+port)
if err != nil {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Please use the errorf instead

@AHS0003
AHS0003 force-pushed the fix/log-printf-format-verbs-v2 branch from 24dd710 to fab01fe Compare August 14, 2026 18:10
Comment thread internal/network/server.go Outdated
conn, err := Listener.Accept()
if err != nil {
log.Println("Error accepting connection: %v\n", err)
log.Print(fmt.Errorf("error accepting connection: %w", err))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks , but just use log.Print("something happened...") alone

log.Println does not interpret format verbs like %v, so the previous
calls printed the literal string %v instead of the actual error
message. Switched to log.Print with the error message concatenated
directly, per review feedback.
@AHS0003
AHS0003 force-pushed the fix/log-printf-format-verbs-v2 branch from fab01fe to c6169b7 Compare August 14, 2026 18:22
@moghit-eou

Copy link
Copy Markdown
Owner

Approved .
Thanks

@moghit-eou
moghit-eou merged commit f633c74 into moghit-eou:main Aug 14, 2026
3 checks passed
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