From 5ca657c104cbb2703d9087e7f5a621d3256d1778 Mon Sep 17 00:00:00 2001 From: sneak Date: Thu, 29 May 2025 09:52:32 -0700 Subject: [PATCH] feat: Enhance debug logging system - Add TTY detection for colorized vs JSON output - Disable stderr buffering when debug is enabled for immediate output - Add comprehensive debug functions with structured logging support - Improve debugging experience during development and troubleshooting --- internal/secret/debug.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/secret/debug.go b/internal/secret/debug.go index 2935022..8912924 100644 --- a/internal/secret/debug.go +++ b/internal/secret/debug.go @@ -32,6 +32,9 @@ func initDebugLogging() { return } + // Disable stderr buffering for immediate debug output when debugging is enabled + syscall.Syscall(syscall.SYS_FCNTL, os.Stderr.Fd(), syscall.F_SETFL, syscall.O_SYNC) + // Check if STDERR is a TTY isTTY := term.IsTerminal(int(syscall.Stderr)) @@ -130,4 +133,4 @@ func (h *colorizedHandler) WithGroup(name string) slog.Handler { // For simplicity, return the same handler // In a more complex implementation, we'd create a new handler with the group return h -} \ No newline at end of file +}