diff options
| author | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2026-06-01 09:26:50 -0700 |
|---|---|---|
| committer | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2026-06-01 09:26:50 -0700 |
| commit | c42c103ddb66028a085fb452102f73f8b27dcdcb (patch) | |
| tree | b7fe404a3a46916e082c80dce089d2258c4bc307 /hotline/server.go | |
| parent | 123d1a305bc68474034f5989362148508bdbf7f5 (diff) | |
Improve startup logging and logging consistency
Startup log:
- Add interface, port, and fileTransferPort fields to the "Hotline
server started" line so operators can see what the server bound to.
- Resolve an empty -interface flag to 0.0.0.0 for display.
Levels:
- Demote the two Redis startup messages (ban management, cleared online
users) from Info to Debug.
Consistency:
- Standardize the error field key to "err" (was "Err" in a few account
handlers) and lowercase "Account" -> "account".
- Standardize the remote-address key to "remoteAddr" (was "RemoteAddr").
- Replace fmt.Sprintf in the tracker-registration message and string
concatenation in the config-dir-init and ban-disconnect messages with
structured fields; use the standard "err" key.
- Give the two bare rLogger.Error(err.Error()) file-transfer calls a
descriptive message and an "err" field.
logger.go:
- Only attach the rotating lumberjack file writer when --log-file is set.
An empty Filename made lumberjack write to a temp file by default.
Diffstat (limited to 'hotline/server.go')
| -rw-r--r-- | hotline/server.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/hotline/server.go b/hotline/server.go index 7bc6a4a..6ac68d8 100644 --- a/hotline/server.go +++ b/hotline/server.go @@ -309,16 +309,16 @@ func (s *Server) Serve(ctx context.Context, ln net.Listener) error { // Check if the rate limit is exceeded and close the connection if so. if !rl.Allow() { - s.Logger.Info("Rate limit exceeded", "RemoteAddr", conn.RemoteAddr()) + s.Logger.Info("Rate limit exceeded", "remoteAddr", conn.RemoteAddr()) _ = conn.Close() return } if err := s.handleNewConnection(connCtx, conn, conn.RemoteAddr().String()); err != nil { if err == io.EOF { - s.Logger.Info("Client disconnected", "RemoteAddr", conn.RemoteAddr()) + s.Logger.Info("Client disconnected", "remoteAddr", conn.RemoteAddr()) } else { - s.Logger.Error("Error serving request", "RemoteAddr", conn.RemoteAddr(), "err", err) + s.Logger.Error("Error serving request", "remoteAddr", conn.RemoteAddr(), "err", err) } } }() @@ -380,7 +380,7 @@ func (s *Server) registerWithAllTrackers() { tr.Password = parseTrackerPassword(t) if err := s.TrackerRegistrar.Register(t, tr); err != nil { - s.Logger.Error(fmt.Sprintf("Unable to register with tracker %v", t), "error", err) + s.Logger.Error("Unable to register with tracker", "tracker", t, "err", err) } } } |