1
1
mirror of https://github.com/walles/moar.git synced 2024-11-22 11:45:50 +03:00

Log start / end on trace level

This commit is contained in:
Johan Walles 2023-05-20 07:00:05 +02:00
parent 63839bd325
commit 2a5b82fe81
3 changed files with 9 additions and 2 deletions

View File

@ -415,6 +415,9 @@ func (p *Pager) onRune(char rune) {
// StartPaging brings up the pager on screen
func (p *Pager) StartPaging(screen twin.Screen) {
log.Trace("Pager starting")
defer log.Trace("Pager done")
unprintableStyle = p.UnprintableStyle
ConsumeLessTermcapEnvs()

View File

@ -56,6 +56,7 @@ func (reader *Reader) cleanupFilter(fromFilter *exec.Cmd) {
if fromFilter == nil {
reader.done.Store(true)
log.Trace("Reader done, no filter")
return
}
@ -96,6 +97,7 @@ func (reader *Reader) cleanupFilter(fromFilter *exec.Cmd) {
// FIXME: Report any filter printouts to stderr to the user
reader.done.Store(true)
log.Trace("Reader done, filter done")
}
// Count lines in the original file and preallocate space for them. Good
@ -382,7 +384,7 @@ func countLines(filename string) (uint64, error) {
t1 := time.Now().UnixNano()
dtNanos := t1 - t0
if count == 0 {
log.Debug("Counted ", count, " lines in ", dtNanos/1_000_000, "ms")
log.Debug("Counted ", count, " lines in 0ms")
} else {
log.Debug("Counted ", count, " lines in ", dtNanos/1_000_000, "ms at ", dtNanos/int64(count), "ns/line")
}
@ -423,6 +425,7 @@ func NewReaderFromFilename(filename string, style chroma.Style, formatter chroma
go func() {
defer func() {
returnMe.highlightingDone.Store(true)
log.Trace("Highlighting done")
}()
highlighted, err := highlight(filename, false, style, formatter)
@ -567,6 +570,7 @@ func (reader *Reader) setText(text string) {
reader.Unlock()
reader.done.Store(true)
log.Trace("Reader done, contents explicitly set")
select {
case reader.moreLinesAdded <- true:

View File

@ -302,7 +302,7 @@ func main() {
}
log.SetFormatter(&log.TextFormatter{
TimestampFormat: time.RFC3339Nano,
TimestampFormat: time.StampMicro,
})
if len(flagSet.Args()) > 1 {