Skip to content

[log] Add debug logger to internal/server/guard_init.go#2528

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
add-debug-logger-guard-init-a4d2f953462a314f
Draft

[log] Add debug logger to internal/server/guard_init.go#2528
github-actions[bot] wants to merge 1 commit intomainfrom
add-debug-logger-guard-init-a4d2f953462a314f

Conversation

@github-actions
Copy link
Contributor

Adds a logger.New("server:guard_init") debug logger to internal/server/guard_init.go, providing structured, namespace-controlled debug tracing for the guard initialization subsystem.

Changes

New logger declaration:

var logGuardInit = logger.New("server:guard_init")

New debug log calls (7 total):

Function What's logged
hasServerGuardPolicies Server count checked; found/not-found result
findServerWASMGuardFile WASM discovery skipped (env unset); directory being searched; found/not-found outcome
resolveGuardPolicy Entry + which policy source branch is taken (global override, server-level, config, or legacy)
ensureGuardInitialized Guard session cache hit (previously had no debug log for the early-return path)

Why this file

guard_init.go has complex, multi-branch logic for resolving which guard and policy to use per server. It already has extensive log.Printf operational logs, but no debug logger — making it impossible to trace the policy-resolution path at development time without modifying the code. The new debug logs fill that gap without touching the operational output.

Usage

# Enable debug output for guard init
DEBUG=server:guard_init ./awmg --config config.toml

# Or enable all server debug logs
DEBUG=server:* ./awmg --config config.toml

Checklist

  • Exactly 1 file modified
  • No test files modified
  • Logger follows pkg:filename naming convention (server:guard_init)
  • Logger arguments have no side effects
  • Existing log.Printf operational calls are preserved unchanged
  • No duplicate logging with existing messages

Generated by Go Logger Enhancement ·

Add logger.New("server:guard_init") debug logger to provide
structured debug tracing for guard initialization logic.

New debug log calls cover:
- hasServerGuardPolicies: log server count and result
- findServerWASMGuardFile: log WASM guard discovery path and outcome
- resolveGuardPolicy: log which policy source is selected per branch
- ensureGuardInitialized: log guard session cache hits

These complement the existing operational log.Printf calls with
namespace-controlled debug output, visible via DEBUG=server:guard_init.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions bot added automation enhancement New feature or request labels Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants