Skip to content

Set TLS Handshake logs to debug#50

Merged
mcpherrinm merged 3 commits intomainfrom
mattm-log-noise
Mar 24, 2026
Merged

Set TLS Handshake logs to debug#50
mcpherrinm merged 3 commits intomainfrom
mattm-log-noise

Conversation

@mcpherrinm
Copy link
Copy Markdown
Contributor

@mcpherrinm mcpherrinm commented Mar 23, 2026

This adds a logDebug, which if set true, prints debug-level logs. Set it true in integration test config for testing, but I expect any internet-facing instance would set this false (the default).

The logs from the http.Server are quite noisy from random internet scans, so set them to debug.

Since we still want to see errors from our own getCertificate, add a logging wrapper for it at the warn level. There still might be a bit of noise for SNI with unknown hostnames, but empirically those are much less frequent, and are mostly empty if they happen. Include the SNI in the slog line, rather than the error, for more structured output.

The funcorder linter wants me to put get() after the exported functions, but I don't want to move it as it follows directly from GetCertificate. So throw an ignore in.

fixes #37

This adds a logDebug, which if set true, prints debug-level logs.

The logs from the http.Server are quite noisy from random internet scans, so
set them to debug.

Since we still want to see errors from our own getCertificate, add a logging
wrapper for it at the warn level.
Drop it from the error message, and instead include it in the log line

This theoretically makes the error worse if you were trying to use the get()
function somewhere else, but we want this error for logging, and we add the
SNI, so we've got what we need.
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

This PR introduces a configurable debug log level and reclassifies noisy TLS handshake-related server logs to debug, while adding structured warning logs around certificate lookup failures.

Changes:

  • Add LogDebug to configuration and wire it to a runtime-adjustable slog level in main.go.
  • Route http.Server error logging through slog at debug level to reduce noise at default info level.
  • Add a GetCertificate wrapper that logs certificate lookup failures at warn level with structured SNI context.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
server/server.go Routes http.Server.ErrorLog through slog at debug level.
main.go Adds a slog.LevelVar and sets debug level based on cfg.LogDebug.
integration/test-certs-site-config.json Enables logDebug for integration testing.
config/config.go Adds LogDebug to the Config struct.
certs/certs.go Wraps GetCertificate to emit warn logs with sni and simplifies returned error strings.

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

Comment thread server/server.go
Comment thread certs/certs.go Outdated
Comment thread config/config.go
@mcpherrinm mcpherrinm merged commit be94d2b into main Mar 24, 2026
2 checks passed
@mcpherrinm mcpherrinm deleted the mattm-log-noise branch March 24, 2026 23:02
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.

Log Noise

4 participants