Skip to content

Commit 20d3459

Browse files
authored
[log] Add debug logging to server/session.go (#2673)
Adds a dedicated `logSession` debug logger to `internal/server/session.go` using the project's `logger.New()` framework with namespace `"server:session"`. ## Changes **File modified:** `internal/server/session.go` Added `var logSession = logger.New("server:session")` and 4 debug logging calls: | Function | Log message | |---|---| | `NewSession` | `Creating new session: sessionID=%s, has_token=%v` | | `getSessionID` | `Extracted session ID from context: %s` | | `requireSession` | `Checking session: sessionID=%s` | | `getSessionKeys` | `Active sessions: count=%d` | ## Usage Enable debug output: ```bash DEBUG=server:session ./awmg --config config.toml DEBUG=server:* ./awmg --config config.toml ``` ## Checklist - [x] Exactly 1 file modified - [x] No test files modified - [x] Logger declaration added (`var logSession = logger.New("server:session")`) - [x] Logger naming follows `pkg:filename` convention - [x] Logger arguments have no side effects - [x] Messages are meaningful and helpful for debugging - [x] No duplicate logging with existing logs (complements stdlib `log.Printf` calls) > Generated by [Go Logger Enhancement](https://github.com/github/gh-aw-mcpg/actions/runs/23662556318) · [◷](https://github.com/search?q=repo%3Agithub%2Fgh-aw-mcpg+%22gh-aw-workflow-id%3A+go-logger%22&type=pullrequests) <!-- gh-aw-agentic-workflow: Go Logger Enhancement, engine: copilot, model: auto, id: 23662556318, workflow_id: go-logger, run: https://github.com/github/gh-aw-mcpg/actions/runs/23662556318 --> <!-- gh-aw-workflow-id: go-logger -->
2 parents ca54650 + 0b13faa commit 20d3459

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

internal/server/session.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ import (
1111
"github.com/github/gh-aw-mcpg/internal/logger"
1212
)
1313

14+
var logSession = logger.New("server:session")
15+
1416
// NewSession creates a new Session with the given session ID and optional token
1517
func NewSession(sessionID, token string) *Session {
18+
logSession.Printf("Creating new session: sessionID=%s, has_token=%v", sessionID, token != "")
1619
return &Session{
1720
Token: token,
1821
SessionID: sessionID,
@@ -24,6 +27,7 @@ func NewSession(sessionID, token string) *Session {
2427
// getSessionID extracts the MCP session ID from the context
2528
func (us *UnifiedServer) getSessionID(ctx context.Context) string {
2629
if sessionID, ok := ctx.Value(SessionIDContextKey).(string); ok && sessionID != "" {
30+
logSession.Printf("Extracted session ID from context: %s", sessionID)
2731
log.Printf("Extracted session ID from context: %s", sessionID)
2832
return sessionID
2933
}
@@ -62,6 +66,7 @@ func (us *UnifiedServer) ensureSessionDirectory(sessionID string) error {
6266
// Sessions are automatically created if one doesn't exist (for standard MCP client compatibility)
6367
func (us *UnifiedServer) requireSession(ctx context.Context) error {
6468
sessionID := us.getSessionID(ctx)
69+
logSession.Printf("Checking session: sessionID=%s", sessionID)
6570
log.Printf("Checking session for ID: %s", sessionID)
6671

6772
// Use double-checked locking to auto-create session if needed
@@ -103,5 +108,6 @@ func (us *UnifiedServer) getSessionKeys() []string {
103108
for k := range us.sessions {
104109
keys = append(keys, k)
105110
}
111+
logSession.Printf("Active sessions: count=%d", len(keys))
106112
return keys
107113
}

0 commit comments

Comments
 (0)