[GH-ISSUE #38] Add debug logging to API endpoints #8

Open
opened 2026-02-28 01:17:59 +03:00 by kerem · 0 comments
Owner

Originally created by @therealpaulgg on GitHub (Feb 27, 2026).
Original GitHub issue: https://github.com/therealpaulgg/ssh-sync-server/issues/38

Summary

Add structured debug logging throughout the API endpoint handlers to aid in tracing request flow and diagnosing issues in development/staging environments. The logging should use the existing zerolog logger (github.com/rs/zerolog/log) already present in the project.

Motivation

Currently, error paths log via log.Err(err).Msg(...) but request lifecycle events (incoming requests, parsed parameters, key validation steps, DB operations, etc.) are not logged at the debug level. This makes it harder to trace what's happening without attaching a debugger.

Example

pkg/web/router/routes/setup.goinitialSetup handler — is a good reference for where debug logs would be useful:

func initialSetup(i *do.Injector) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		// e.g. log.Debug().Str("username", username).Msg("initialSetup: parsed form values")
		// e.g. log.Debug().Msg("initialSetup: public key validated")
		// e.g. log.Debug().Msg("initialSetup: user created, creating machine")
		...
	}
}

Scope

  • All handlers under pkg/web/router/routes/
  • Key lifecycle events: request received, parameters parsed/validated, DB operations initiated/completed, response written
  • Use log.Debug() (not log.Info()) so logs are silent in production by default
  • Follow the existing log.Err(err).Msg(...) style for consistency
Originally created by @therealpaulgg on GitHub (Feb 27, 2026). Original GitHub issue: https://github.com/therealpaulgg/ssh-sync-server/issues/38 ## Summary Add structured debug logging throughout the API endpoint handlers to aid in tracing request flow and diagnosing issues in development/staging environments. The logging should use the existing `zerolog` logger (`github.com/rs/zerolog/log`) already present in the project. ## Motivation Currently, error paths log via `log.Err(err).Msg(...)` but request lifecycle events (incoming requests, parsed parameters, key validation steps, DB operations, etc.) are not logged at the debug level. This makes it harder to trace what's happening without attaching a debugger. ## Example `pkg/web/router/routes/setup.go` — `initialSetup` handler — is a good reference for where debug logs would be useful: ```go func initialSetup(i *do.Injector) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { // e.g. log.Debug().Str("username", username).Msg("initialSetup: parsed form values") // e.g. log.Debug().Msg("initialSetup: public key validated") // e.g. log.Debug().Msg("initialSetup: user created, creating machine") ... } } ``` ## Scope - All handlers under `pkg/web/router/routes/` - Key lifecycle events: request received, parameters parsed/validated, DB operations initiated/completed, response written - Use `log.Debug()` (not `log.Info()`) so logs are silent in production by default - Follow the existing `log.Err(err).Msg(...)` style for consistency
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ssh-sync-server#8
No description provided.