Skip to content

feat: structured logging#22

Merged
lachlanharrisdev merged 2 commits intomainfrom
structured-logging
Apr 7, 2026
Merged

feat: structured logging#22
lachlanharrisdev merged 2 commits intomainfrom
structured-logging

Conversation

@lachlanharrisdev
Copy link
Copy Markdown
Owner

@lachlanharrisdev lachlanharrisdev commented Apr 7, 2026

Solves #12

@lachlanharrisdev lachlanharrisdev requested a review from Copilot April 7, 2026 22:03
@lachlanharrisdev lachlanharrisdev self-assigned this Apr 7, 2026
@lachlanharrisdev lachlanharrisdev added enhancement New feature or request dependencies Pull requests that update a dependency file labels Apr 7, 2026
@lachlanharrisdev lachlanharrisdev linked an issue Apr 7, 2026 that may be closed by this pull request
Copy link
Copy Markdown

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

Introduces structured logging across GoNetSim using log/slog, with configurable log format/level and per-service logger injection to improve observability and log consistency.

Changes:

  • Add internal/observability.NewLogger (tint text output or JSON) and wire it into CLI commands.
  • Inject per-service *slog.Logger via a new optional service.LoggerAware interface and update HTTP/DNS services to use it.
  • Add logging configuration defaults and TOML config keys ([logging] format/level), plus small TTY-aware banner formatting.

Reviewed changes

Copilot reviewed 17 out of 18 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
main.go TTY-aware banner formatting and new color/TTY deps.
cmd/root.go Create/configure default slog logger from config; structured startup/error logging.
cmd/dns.go Configure slog logger for standalone DNS command.
cmd/http.go Configure slog logger for standalone HTTP command.
cmd/https.go Configure slog logger for standalone HTTPS command.
internal/observability/logging.go New logger factory supporting text (tint) and JSON output.
internal/config/config.go Add logging config to schema, defaults, and validation.
internal/config/default_config.toml Add default [logging] section.
internal/service/service.go Add LoggerAware interface for logger injection.
internal/service/manager.go Switch manager to slog, add prefix handler, inject loggers into services.
internal/httpserver/config.go Store injected logger on HTTP server service.
internal/httpserver/server.go Pass logger into handler/server and use slog for listening logs.
internal/httpserver/fakemode.go Structured request logging with captured status code.
internal/httpserver/http_test.go Update server constructor calls for new logger parameter.
internal/dnsserver/config.go Store injected logger on DNS server service.
internal/dnsserver/server.go Add logger-aware server creation and structured query/listen logging.
go.mod Add tint/colorable/isatty deps; bump x/sys.
go.sum Add checksums for new deps / updated x/sys.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lachlanharrisdev lachlanharrisdev merged commit 416effa into main Apr 7, 2026
5 checks passed
@lachlanharrisdev lachlanharrisdev deleted the structured-logging branch April 7, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Structured Logging

2 participants