FIX #10 Implement logging
This commit is contained in:
parent
1cdb274c4b
commit
443b3a0765
2 changed files with 12 additions and 0 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -17,3 +17,6 @@ breakfast
|
|||
|
||||
# Go workspace file
|
||||
go.work
|
||||
|
||||
# Logs
|
||||
logs/
|
||||
|
|
9
main.go
9
main.go
|
@ -189,6 +189,15 @@ func (m model) View() string {
|
|||
}
|
||||
|
||||
func main() {
|
||||
// Logging example from the Bubbletea "simple" example. For some
|
||||
// reason there's no file variable, and hence no file to `.Close()`.
|
||||
logfilePath := os.Getenv("BUBBLETEA_LOG")
|
||||
if logfilePath != "" {
|
||||
if _, err := tea.LogToFile(logfilePath, "DEBUG"); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
p := tea.NewProgram(initialModel())
|
||||
if err := p.Start(); err != nil {
|
||||
fmt.Printf("Alas, there's been an error: %v", err)
|
||||
|
|
Loading…
Reference in a new issue