fix: use log.Printf instead of log.Println for formatted error logs - #6
Merged
moghit-eou merged 1 commit intoAug 14, 2026
Merged
Conversation
moghit-eou
requested changes
Aug 14, 2026
| @@ -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 { | |||
Owner
There was a problem hiding this comment.
Please use the errorf instead
AHS0003
force-pushed
the
fix/log-printf-format-verbs-v2
branch
from
August 14, 2026 18:10
24dd710 to
fab01fe
Compare
moghit-eou
approved these changes
Aug 14, 2026
moghit-eou
requested changes
Aug 14, 2026
| conn, err := Listener.Accept() | ||
| if err != nil { | ||
| log.Println("Error accepting connection: %v\n", err) | ||
| log.Print(fmt.Errorf("error accepting connection: %w", err)) |
Owner
There was a problem hiding this comment.
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
force-pushed
the
fix/log-printf-format-verbs-v2
branch
from
August 14, 2026 18:22
fab01fe to
c6169b7
Compare
moghit-eou
approved these changes
Aug 14, 2026
Owner
|
Approved . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
(port already in use) and confirmed the log now shows the
properly formatted error message instead of a literal %v