Skip to content

Commit

Permalink
Order logs from newest to oldest
Browse files Browse the repository at this point in the history
  • Loading branch information
igolaizola committed Jun 27, 2024
1 parent f0187d0 commit cc753cd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions webcli.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log"
"net"
"net/http"
"sort"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -352,6 +353,10 @@ func New(commands []*Command, opts ...Option) (*Server, error) {
Canceled: p.canceled,
})
}
// Order from newest to oldest
sort.Slice(logs, func(i, j int) bool {
return logs[i].Start.After(logs[j].Start)
})
v := view.ListLog(o.app, logs)
if err := v.Render(r.Context(), w); err != nil {
log.Println("webcli: couldn't render view:", err)
Expand Down

0 comments on commit cc753cd

Please sign in to comment.