0.2.63 update

This commit is contained in:
ponzischeme89
2026-08-14 11:47:32 +12:00
parent 9a8ecbdceb
commit 06b6490ac9
41 changed files with 921 additions and 179 deletions
+24
View File
@@ -63,6 +63,29 @@ func TestConsoleQuotesOnlyAmbiguousValues(t *testing.T) {
}
}
func TestLoggingRedactsSensitiveAttributesAndURLs(t *testing.T) {
var output bytes.Buffer
logger, buffer := NewBuffered(&output, LevelTrace, 10, FormatConsole)
logger.Log(nil, LevelTrace, "diagnostic request",
"authorization", "Bearer private-token",
"url", "https://emby.example/stream?api_key=private-key&quality=720p",
)
line := output.String()
if strings.Contains(line, "private-token") || strings.Contains(line, "private-key") {
t.Fatalf("console leaked a secret: %s", line)
}
if !strings.Contains(line, "TRACE") {
t.Fatalf("console did not render TRACE: %s", line)
}
page := buffer.Events(0, 1)
if len(page.Events) != 1 || page.Events[0].Level != "TRACE" ||
page.Events[0].Attributes["authorization"] != "[redacted]" ||
strings.Contains(page.Events[0].Attributes["url"], "private-key") {
t.Fatalf("buffer leaked or mislabelled diagnostic event: %+v", page.Events)
}
}
func TestParseFormat(t *testing.T) {
tests := map[string]Format{
"": FormatConsole,
@@ -144,6 +167,7 @@ func TestPersistentBufferRestoresTheRetainedTail(t *testing.T) {
func TestParseLevel(t *testing.T) {
tests := map[string]slog.Level{
"": slog.LevelInfo,
"trace": LevelTrace,
"debug": slog.LevelDebug,
"WARNING": slog.LevelWarn,
"error": slog.LevelError,