hedhyw / json-log-viewer

Interactive viewer for JSON logs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feat: support sorting by field

hedhyw opened this issue · comments

Add an ability to sort by field:

  • Descending
  • Ascending

Hi I want to work on it. Can you please explain what do you mean by Show the list of fields to sort by ?

Hi I want to work on it.

Hi! Thank you.

Can you please explain what do you mean by Show the list of fields to sort by ?

The idea was to show a list of fields from which we can select a field to sort by, but of course, it's not a requirement.
Feel free to describe how you see it at its best.

He @hedhyw assign it to me on this account, @arsalankone is my work account and I had mistakenly commented from that account.

I might need some help also in understanding the flow of code properly. Also like in sorting by fields, what criterion should be used for sorting mechanism. Sorting by value in case of timestamps and lexicographical sorting in message makes sense, but for level fields, what should be an appropriate parameter?

I might need some help also in understanding the flow of code properly.

  • Clicking hotkeys ("O"/"F6") on StateLoaded, StateFiltered should open a dialogue to select a field to sort by:
  • Possible sorting fields can be taken from the config:
    Fields []Field `json:"fields" validate:"min=1"`
  • The current sorting order can be stored in the persistent application state (available in all models, note: each local state clones it). StateLoaded and StateFiltered will sort considering sorting configuration from the persistent state:
    type Application struct {

Sorting by value in case of timestamps and lexicographical sorting in message makes sense, but for level fields, what should be an appropriate parameter?

  • Numbers/Timestamps -> by value.
  • Any other value -> lexicographical.

Can you take a look at it and see if I am following the right approach?
https://github.com/SpoonBuoy/json-log-viewer/tree/spoon

Can you take a look at it and see if I am following the right approach? https://github.com/SpoonBuoy/json-log-viewer/tree/spoon

looks right, but I'm not sure we need StateSorted, we can save the order in the application state, and use it in StateLoaded/StateFiltered

@SpoonBuoy do you still need this feature?