Skip to content

Commit

Permalink
Log received events on trace level
Browse files Browse the repository at this point in the history
If you run moar with -trace you'll get all handled events listed after
moar finishes running.

The point would be to be able to debug mishandled keys as reported
in #55.

Also, remove the screen refresh timings from the trace logs. We get lots
of them, and I don't think they provide value any more.
  • Loading branch information
walles committed May 13, 2021
1 parent edacfee commit 2b1e87b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
6 changes: 3 additions & 3 deletions m/pager.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,15 +741,15 @@ func (p *Pager) StartPaging(screen twin.Screen) {
event := <-screen.Events()
switch event := event.(type) {
case twin.EventKeyCode:
log.Trace("Handling key event...")
log.Tracef("Handling key event %d...", event.KeyCode())
p._OnKey(event.KeyCode())

case twin.EventRune:
log.Trace("Handling rune event...")
log.Tracef("Handling rune event '%c'/0x%04x...", event.Rune(), event.Rune())
p._OnRune(event.Rune())

case twin.EventMouse:
log.Trace("Handling mouse event...")
log.Tracef("Handling mouse event %d...", event.Buttons())
switch event.Buttons() {
case twin.MouseWheelUp:
// Clipping is done in _AddLines()
Expand Down
8 changes: 1 addition & 7 deletions twin/screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"os"
"regexp"
"strings"
"time"
"unicode"
"unicode/utf8"

Expand Down Expand Up @@ -479,12 +478,7 @@ func (screen *UnixScreen) Show() {
}

// Write out what we have
t0 := time.Now()
byteCount := screen.write(builder.String())
t1 := time.Now()
dt := t1.Sub(t0)
megaBytesPerSecond := float64(byteCount) / (1024.0 * 1024.0) / dt.Seconds()
log.Trace("Wrote ", byteCount, " bytes to screen in ", dt, " at ", int(megaBytesPerSecond), "MB/s")
screen.write(builder.String())
}

func NewCell(rune rune, style Style) Cell {
Expand Down

0 comments on commit 2b1e87b

Please sign in to comment.