Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions audit/logging_auditor.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package audit

import "log/slog"

// LoggingAuditor implements Auditor by logging to slog
type LoggingAuditor struct {
logger *slog.Logger
}

// NewLoggingAuditor creates a new LoggingAuditor
func NewLoggingAuditor(logger *slog.Logger) *LoggingAuditor {
return &LoggingAuditor{
logger: logger,
}
}

// AuditRequest logs the request using structured logging
func (a *LoggingAuditor) AuditRequest(req *Request) {
if req.Allowed {
a.logger.Info("ALLOW",
"method", req.Method,
"url", req.URL,
"rule", req.Rule)
} else {
a.logger.Warn("DENY",
"method", req.Method,
"url", req.URL)
}
}
Loading
Loading