Add debugging to log file

This commit is contained in:
qowevisa 2024-03-15 17:44:54 +02:00
parent d9e17c8b62
commit 8006402f0f

View File

@ -10,6 +10,7 @@ import (
"syscall" "syscall"
"unicode" "unicode"
"git.qowevisa.me/Qowevisa/gotell/debug"
"git.qowevisa.me/Qowevisa/gotell/errors" "git.qowevisa.me/Qowevisa/gotell/errors"
"golang.org/x/term" "golang.org/x/term"
) )
@ -209,6 +210,7 @@ func (t *TUI) setRoutines() error {
var readEnterdMu sync.Mutex var readEnterdMu sync.Mutex
readInput := false readInput := false
readCommand := false readCommand := false
readDebug := false
readEnter := false readEnter := false
go func() { go func() {
for newState := range t.readInputState { for newState := range t.readInputState {
@ -241,6 +243,16 @@ func (t *TUI) setRoutines() error {
continue continue
} }
} }
if readDebug {
log.Printf("Reading debug")
switch r {
case 'm':
log.Printf("get m for debug")
debug.LogMemUsage()
}
readDebug = false
continue
}
if readCommand { if readCommand {
switch r { switch r {
case 'q': case 'q':
@ -276,7 +288,11 @@ func (t *TUI) setRoutines() error {
if unicode.IsControl(r) { if unicode.IsControl(r) {
switch r { switch r {
case CTRL_A: case CTRL_A:
log.Printf("CTRL_A received!\n")
readCommand = true readCommand = true
case CTRL_D:
log.Printf("CTRL_D received!\n")
readDebug = true
} }
} else { } else {
if readInput { if readInput {