Skip to content

Commit 29bb353

Browse files
committed
fixup! move everything to tui.logging
1 parent 13b6e45 commit 29bb353

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tui/logging.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2025 DataRobot, Inc. and its affiliates.
2+
// All rights reserved.
3+
// DataRobot, Inc. Confidential.
4+
// This is unpublished proprietary source code of DataRobot, Inc.
5+
// and its affiliates.
6+
// The copyright notice above does not evidence any actual or intended
7+
// publication of such source code.
8+
9+
package tui
10+
11+
import (
12+
"fmt"
13+
"os"
14+
15+
tea "github.com/charmbracelet/bubbletea"
16+
)
17+
18+
// DebugLogFile is the filename for TUI debug logs
19+
const DebugLogFile = "dr-tui-debug.log"
20+
21+
// SetupDebugLogging configures debug logging for the TUI if debug mode is enabled.
22+
// It should be called at the start of TUI programs when debug logging is needed.
23+
// Returns a cleanup function that should be deferred to close the log file.
24+
func SetupDebugLogging() (cleanup func(), err error) {
25+
f, err := tea.LogToFile(DebugLogFile, "debug")
26+
if err != nil {
27+
fmt.Println("fatal:", err)
28+
os.Exit(1)
29+
}
30+
31+
return func() { f.Close() }, nil
32+
}

0 commit comments

Comments
 (0)