[agent/codex:gpt-5.4-mini] Read ~/spec/code/core/go/cli/RFC.md fully. Find ONE feature ... #41
2 changed files with 35 additions and 0 deletions
|
|
@ -26,3 +26,8 @@ func LogWarn(msg string, keyvals ...any) { log.Warn(msg, keyvals...) }
|
|||
|
||||
// LogError logs an error message.
|
||||
func LogError(msg string, keyvals ...any) { log.Error(msg, keyvals...) }
|
||||
|
||||
// LogSecurity logs a security-sensitive message.
|
||||
//
|
||||
// cli.LogSecurity("login attempt", "user", "admin")
|
||||
func LogSecurity(msg string, keyvals ...any) { log.Security(msg, keyvals...) }
|
||||
|
|
|
|||
30
pkg/cli/log_test.go
Normal file
30
pkg/cli/log_test.go
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"forge.lthn.ai/core/go-log"
|
||||
)
|
||||
|
||||
func TestLogSecurity_Good(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
original := log.Default()
|
||||
t.Cleanup(func() {
|
||||
log.SetDefault(original)
|
||||
})
|
||||
|
||||
logger := log.New(log.Options{Level: log.LevelDebug, Output: &buf})
|
||||
log.SetDefault(logger)
|
||||
|
||||
LogSecurity("login attempt", "user", "admin")
|
||||
|
||||
out := buf.String()
|
||||
if !strings.Contains(out, "login attempt") {
|
||||
t.Fatalf("expected security log message, got %q", out)
|
||||
}
|
||||
if !strings.Contains(out, "user") {
|
||||
t.Fatalf("expected structured key/value output, got %q", out)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue