Skip to content

feat: support symphony @timestamp #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23.2'
go-version: '1.24.1'
id: go

- name: Check out code into the Go module directory
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23.2'
go-version: '1.24.1'

- name: Fetch vendor
run: make vendor
Expand Down
95 changes: 62 additions & 33 deletions .golangci.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,72 @@
{
"formatters": {
"enable": [
"gofmt",
"gofumpt",
"goimports"
],
"exclusions": {
"generated": "lax",
"paths": [
"third_party$",
"builtin$",
"examples$"
]
},
"settings": {
"goimports": {
"local-prefixes": [
"github.com/hedhyw/json-log-viewer/"
]
}
}
},
"linters": {
"enable-all": true,
"default": "all",
"disable": [
"lll",
"gochecknoglobals",
"bodyclose",
"wsl",
"funlen",
"gci",
"wrapcheck",
"varnamelen",
"testpackage",
"depguard",
"exhaustive",
"gomnd",
"thelper",
"paralleltest",
"tagliatelle",
"nonamedreturns",
"exhaustruct",
"nolintlint",
"wastedassign",
"rowserrcheck",
"depguard",
"ireturn",
"funlen",
"gochecknoglobals",
"gomoddirectives",
"execinquery",
"tagalign",
"ireturn",
"lll",
"mnd",
"nlreturn",
"exportloopref"
]
},
"linters-settings": {
"goimports": {
"local-prefixes": "github.com/hedhyw/json-log-viewer/"
},
"cyclop": {
"max-complexity": 15
"nolintlint",
"nonamedreturns",
"paralleltest",
"rowserrcheck",
"tagalign",
"tagliatelle",
"testpackage",
"thelper",
"varnamelen",
"wastedassign",
"wrapcheck",
"wsl"
],
"exclusions": {
"generated": "lax",
"paths": [
"third_party$",
"builtin$",
"examples$"
],
"presets": [
"comments",
"common-false-positives",
"legacy",
"std-error-handling"
]
},
"revive": {}
}
}
"settings": {
"cyclop": {
"max-complexity": 15
}
}
},
"version": "2"
}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GOLANG_CI_LINT_VER:=v1.61.0
GOLANG_CI_LINT_VER:=v2.0.2
GORELEASER_VERSION:=v2.3.2
OUT_BIN?=${PWD}/bin/jlv
COVER_PACKAGES=./...
Expand Down
3 changes: 2 additions & 1 deletion assets/example.log
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ plain text log
{"time":865900800,"level":"TRACE","message": "Money doesn't talk, it swears","author": "Bob Dylan"}
{"time":883612800.45,"level":"WARN","message": "If a man knows not to which port he sails, no wind is favorable","author": "Seneca"}
{"time":"915148800000.45","level":"VERBOSE","message": "Begin at once to live, and count each separate day as a separate life","author": "Seneca"}
{"time":946684800.45,"level":"VERBOSE","message": "Begin at once to live, and count each separate day as a separate life","author": "Seneca"}
{"time":946684800.45,"level":"VERBOSE","message": "Begin at once to live, and count each separate day as a separate life","author": "Seneca"}
{"@timestamp":"2025-03-06T11:55:53.723682+01:00","@version":1,"host":"bad21ee895cd","message":"Message ..","level":"INFO"}
3 changes: 2 additions & 1 deletion example.jlv.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"$.timestamp",
"$.time",
"$.t",
"$.ts"
"$.ts",
"$[\"@timestamp\"]"
],
"width": 30,
// Year: "2006" "06"
Expand Down
2 changes: 1 addition & 1 deletion internal/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,6 @@ func requireCmdMsg(tb testing.TB, expected tea.Msg, cmd tea.Cmd) {
}

func getTestError() error {
// nolint: goerr113 // It is a test.
// nolint: err113 // It is a test.
return errors.New("error description")
}
12 changes: 6 additions & 6 deletions internal/app/lazytable.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (m lazyTableModel) getCellRenderer() func(table.Model, string, table.CellPo

if position.Column == cellIDLogLevel {
return removeClearSequence(
m.Application.getLogLevelStyle(
m.getLogLevelStyle(
m.renderedRows,
style,
position.RowID,
Expand All @@ -94,7 +94,7 @@ func (m lazyTableModel) getCellRenderer() func(table.Model, string, table.CellPo

func (m lazyTableModel) handleKey(msg tea.KeyMsg, render bool) (lazyTableModel, bool) {
// toggle the reverse display of items.
if key.Matches(msg, m.Application.keys.Reverse) {
if key.Matches(msg, m.keys.Reverse) {
m.reverse = !m.reverse
render = true
}
Expand Down Expand Up @@ -128,21 +128,21 @@ func (m lazyTableModel) handleKey(msg tea.KeyMsg, render bool) (lazyTableModel,
increaseOffset, decreaseOffset = decreaseOffset, increaseOffset
}

if key.Matches(msg, m.Application.keys.Down) {
if key.Matches(msg, m.keys.Down) {
m.follow = false
if m.table.Cursor()+1 == m.table.Height() {
increaseOffset() // move the viewport
}
}

if key.Matches(msg, m.Application.keys.Up) {
if key.Matches(msg, m.keys.Up) {
m.follow = false
if m.table.Cursor() == 0 {
decreaseOffset() // move the viewport
}
}

if key.Matches(msg, m.Application.keys.GotoTop) {
if key.Matches(msg, m.keys.GotoTop) {
if m.reverse {
// when follow is enabled, rendering will handle setting the offset to the correct value
m.follow = true
Expand All @@ -153,7 +153,7 @@ func (m lazyTableModel) handleKey(msg tea.KeyMsg, render bool) (lazyTableModel,
render = true
}

if key.Matches(msg, m.Application.keys.GotoBottom) {
if key.Matches(msg, m.keys.GotoBottom) {
if m.reverse {
m.follow = false
m.offset = 0
Expand Down
4 changes: 2 additions & 2 deletions internal/app/statefiltered.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (s StateFilteredModel) Init() tea.Cmd {

// View renders component. It implements tea.Model.
func (s StateFilteredModel) View() string {
footer := s.Application.FooterStyle.Render(
footer := s.FooterStyle.Render(
fmt.Sprintf("filtered %d by: %s", s.logEntries.Len(), s.filterText),
)

Expand Down Expand Up @@ -128,7 +128,7 @@ func (s StateFilteredModel) getApplication() *Application {
}

func (s StateFilteredModel) refresh() (_ stateModel, cmd tea.Cmd) {
s.table, cmd = s.table.Update(s.Application.LastWindowSize())
s.table, cmd = s.table.Update(s.LastWindowSize())

return s, cmd
}
Expand Down
6 changes: 3 additions & 3 deletions internal/app/stateloaded.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (s StateLoadedModel) viewHelp() string {
Padding(0, 1).
Render(s.Version)

width := s.Application.LastWindowSize().Width
width := s.LastWindowSize().Width
fillerText := lipgloss.NewStyle().
Background(lipgloss.Color("#353533")).
Width(width - lipgloss.Width(toggleText) - lipgloss.Width(versionText)).
Expand Down Expand Up @@ -160,8 +160,8 @@ func (s StateLoadedModel) getApplication() *Application {
func (s StateLoadedModel) refresh() (_ stateModel, cmd tea.Cmd) {
var cmdFirst, cmdSecond tea.Cmd

s.table, cmdSecond = s.table.Update(s.Application.LastWindowSize())
s.table, cmdFirst = s.table.Update(events.LogEntriesUpdateMsg(s.Application.Entries()))
s.table, cmdSecond = s.table.Update(s.LastWindowSize())
s.table, cmdFirst = s.table.Update(events.LogEntriesUpdateMsg(s.Entries()))

return s, tea.Batch(cmdFirst, cmdSecond)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func GetDefaultConfig() *Config {
Fields: []Field{{
Title: "Time",
Kind: FieldKindNumericTime,
References: []string{"$.timestamp", "$.time", "$.t", "$.ts"},
References: []string{"$.timestamp", "$.time", "$.t", "$.ts", "$[\"@timestamp\"]"},
Width: 30,
TimeFormat: &defaultTimeFormat,
}, {
Expand Down
3 changes: 2 additions & 1 deletion internal/pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ func ExampleGetDefaultConfig() {
// "$.timestamp",
// "$.time",
// "$.t",
// "$.ts"
// "$.ts",
// "$[\"@timestamp\"]"
// ],
// "width": 30,
// "time_format": "2006-01-02T15:04:05Z07:00"
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/source/entry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ func getTimestampFormattingConfig(fieldKind config.FieldKind, format string) *co
cfg.Fields = []config.Field{{
Title: "Time",
Kind: fieldKind,
References: []string{"$.timestamp", "$.time", "$.t", "$.ts"},
References: []string{"$.timestamp", "$.time", "$.t", "$.ts", "$[\"@timestamp\"]"},
Width: 30,
TimeFormat: timeFormat,
}}
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/tests/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const ErrTest semerr.Error = "test error"
func RequireCreateFile(tb testing.TB, content []byte) string {
tb.Helper()

f, err := os.CreateTemp("", "json_log_viewer_test")
f, err := os.CreateTemp(tb.TempDir(), "json_log_viewer_test")
require.NoError(tb, err)

defer func() { assert.NoError(tb, f.Close()) }()
Expand Down
Loading