Skip to content

Commit 0961467

Browse files
authored
feat: support symphony @timestamp (#128)
1 parent 907354b commit 0961467

File tree

14 files changed

+86
-54
lines changed

14 files changed

+86
-54
lines changed

.github/workflows/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Set up Go
1515
uses: actions/setup-go@v5
1616
with:
17-
go-version: '1.23.2'
17+
go-version: '1.24.1'
1818
id: go
1919

2020
- name: Check out code into the Go module directory

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Set up Go
1616
uses: actions/setup-go@v5
1717
with:
18-
go-version: '1.23.2'
18+
go-version: '1.24.1'
1919

2020
- name: Fetch vendor
2121
run: make vendor

.golangci.json

Lines changed: 62 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,72 @@
11
{
2+
"formatters": {
3+
"enable": [
4+
"gofmt",
5+
"gofumpt",
6+
"goimports"
7+
],
8+
"exclusions": {
9+
"generated": "lax",
10+
"paths": [
11+
"third_party$",
12+
"builtin$",
13+
"examples$"
14+
]
15+
},
16+
"settings": {
17+
"goimports": {
18+
"local-prefixes": [
19+
"github.com/hedhyw/json-log-viewer/"
20+
]
21+
}
22+
}
23+
},
224
"linters": {
3-
"enable-all": true,
25+
"default": "all",
426
"disable": [
5-
"lll",
6-
"gochecknoglobals",
727
"bodyclose",
8-
"wsl",
9-
"funlen",
10-
"gci",
11-
"wrapcheck",
12-
"varnamelen",
13-
"testpackage",
28+
"depguard",
1429
"exhaustive",
15-
"gomnd",
16-
"thelper",
17-
"paralleltest",
18-
"tagliatelle",
19-
"nonamedreturns",
2030
"exhaustruct",
21-
"nolintlint",
22-
"wastedassign",
23-
"rowserrcheck",
24-
"depguard",
25-
"ireturn",
31+
"funlen",
32+
"gochecknoglobals",
2633
"gomoddirectives",
27-
"execinquery",
28-
"tagalign",
34+
"ireturn",
35+
"lll",
2936
"mnd",
3037
"nlreturn",
31-
"exportloopref"
32-
]
33-
},
34-
"linters-settings": {
35-
"goimports": {
36-
"local-prefixes": "github.com/hedhyw/json-log-viewer/"
37-
},
38-
"cyclop": {
39-
"max-complexity": 15
38+
"nolintlint",
39+
"nonamedreturns",
40+
"paralleltest",
41+
"rowserrcheck",
42+
"tagalign",
43+
"tagliatelle",
44+
"testpackage",
45+
"thelper",
46+
"varnamelen",
47+
"wastedassign",
48+
"wrapcheck",
49+
"wsl"
50+
],
51+
"exclusions": {
52+
"generated": "lax",
53+
"paths": [
54+
"third_party$",
55+
"builtin$",
56+
"examples$"
57+
],
58+
"presets": [
59+
"comments",
60+
"common-false-positives",
61+
"legacy",
62+
"std-error-handling"
63+
]
4064
},
41-
"revive": {}
42-
}
43-
}
65+
"settings": {
66+
"cyclop": {
67+
"max-complexity": 15
68+
}
69+
}
70+
},
71+
"version": "2"
72+
}

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
GOLANG_CI_LINT_VER:=v1.61.0
1+
GOLANG_CI_LINT_VER:=v2.0.2
22
GORELEASER_VERSION:=v2.3.2
33
OUT_BIN?=${PWD}/bin/jlv
44
COVER_PACKAGES=./...

assets/example.log

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,5 @@ plain text log
5252
{"time":865900800,"level":"TRACE","message": "Money doesn't talk, it swears","author": "Bob Dylan"}
5353
{"time":883612800.45,"level":"WARN","message": "If a man knows not to which port he sails, no wind is favorable","author": "Seneca"}
5454
{"time":"915148800000.45","level":"VERBOSE","message": "Begin at once to live, and count each separate day as a separate life","author": "Seneca"}
55-
{"time":946684800.45,"level":"VERBOSE","message": "Begin at once to live, and count each separate day as a separate life","author": "Seneca"}
55+
{"time":946684800.45,"level":"VERBOSE","message": "Begin at once to live, and count each separate day as a separate life","author": "Seneca"}
56+
{"@timestamp":"2025-03-06T11:55:53.723682+01:00","@version":1,"host":"bad21ee895cd","message":"Message ..","level":"INFO"}

example.jlv.jsonc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"$.timestamp",
1919
"$.time",
2020
"$.t",
21-
"$.ts"
21+
"$.ts",
22+
"$[\"@timestamp\"]"
2223
],
2324
"width": 30,
2425
// Year: "2006" "06"

internal/app/app_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,6 @@ func requireCmdMsg(tb testing.TB, expected tea.Msg, cmd tea.Cmd) {
102102
}
103103

104104
func getTestError() error {
105-
// nolint: goerr113 // It is a test.
105+
// nolint: err113 // It is a test.
106106
return errors.New("error description")
107107
}

internal/app/lazytable.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (m lazyTableModel) getCellRenderer() func(table.Model, string, table.CellPo
8080

8181
if position.Column == cellIDLogLevel {
8282
return removeClearSequence(
83-
m.Application.getLogLevelStyle(
83+
m.getLogLevelStyle(
8484
m.renderedRows,
8585
style,
8686
position.RowID,
@@ -94,7 +94,7 @@ func (m lazyTableModel) getCellRenderer() func(table.Model, string, table.CellPo
9494

9595
func (m lazyTableModel) handleKey(msg tea.KeyMsg, render bool) (lazyTableModel, bool) {
9696
// toggle the reverse display of items.
97-
if key.Matches(msg, m.Application.keys.Reverse) {
97+
if key.Matches(msg, m.keys.Reverse) {
9898
m.reverse = !m.reverse
9999
render = true
100100
}
@@ -128,21 +128,21 @@ func (m lazyTableModel) handleKey(msg tea.KeyMsg, render bool) (lazyTableModel,
128128
increaseOffset, decreaseOffset = decreaseOffset, increaseOffset
129129
}
130130

131-
if key.Matches(msg, m.Application.keys.Down) {
131+
if key.Matches(msg, m.keys.Down) {
132132
m.follow = false
133133
if m.table.Cursor()+1 == m.table.Height() {
134134
increaseOffset() // move the viewport
135135
}
136136
}
137137

138-
if key.Matches(msg, m.Application.keys.Up) {
138+
if key.Matches(msg, m.keys.Up) {
139139
m.follow = false
140140
if m.table.Cursor() == 0 {
141141
decreaseOffset() // move the viewport
142142
}
143143
}
144144

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

156-
if key.Matches(msg, m.Application.keys.GotoBottom) {
156+
if key.Matches(msg, m.keys.GotoBottom) {
157157
if m.reverse {
158158
m.follow = false
159159
m.offset = 0

internal/app/statefiltered.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (s StateFilteredModel) Init() tea.Cmd {
4343

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

@@ -128,7 +128,7 @@ func (s StateFilteredModel) getApplication() *Application {
128128
}
129129

130130
func (s StateFilteredModel) refresh() (_ stateModel, cmd tea.Cmd) {
131-
s.table, cmd = s.table.Update(s.Application.LastWindowSize())
131+
s.table, cmd = s.table.Update(s.LastWindowSize())
132132

133133
return s, cmd
134134
}

internal/app/stateloaded.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (s StateLoadedModel) viewHelp() string {
8282
Padding(0, 1).
8383
Render(s.Version)
8484

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

163-
s.table, cmdSecond = s.table.Update(s.Application.LastWindowSize())
164-
s.table, cmdFirst = s.table.Update(events.LogEntriesUpdateMsg(s.Application.Entries()))
163+
s.table, cmdSecond = s.table.Update(s.LastWindowSize())
164+
s.table, cmdFirst = s.table.Update(events.LogEntriesUpdateMsg(s.Entries()))
165165

166166
return s, tea.Batch(cmdFirst, cmdSecond)
167167
}

internal/pkg/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func GetDefaultConfig() *Config {
6868
Fields: []Field{{
6969
Title: "Time",
7070
Kind: FieldKindNumericTime,
71-
References: []string{"$.timestamp", "$.time", "$.t", "$.ts"},
71+
References: []string{"$.timestamp", "$.time", "$.t", "$.ts", "$[\"@timestamp\"]"},
7272
Width: 30,
7373
TimeFormat: &defaultTimeFormat,
7474
}, {

internal/pkg/config/config_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ func ExampleGetDefaultConfig() {
110110
// "$.timestamp",
111111
// "$.time",
112112
// "$.t",
113-
// "$.ts"
113+
// "$.ts",
114+
// "$[\"@timestamp\"]"
114115
// ],
115116
// "width": 30,
116117
// "time_format": "2006-01-02T15:04:05Z07:00"

internal/pkg/source/entry_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ func getTimestampFormattingConfig(fieldKind config.FieldKind, format string) *co
722722
cfg.Fields = []config.Field{{
723723
Title: "Time",
724724
Kind: fieldKind,
725-
References: []string{"$.timestamp", "$.time", "$.t", "$.ts"},
725+
References: []string{"$.timestamp", "$.time", "$.t", "$.ts", "$[\"@timestamp\"]"},
726726
Width: 30,
727727
TimeFormat: timeFormat,
728728
}}

internal/pkg/tests/tests.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const ErrTest semerr.Error = "test error"
2020
func RequireCreateFile(tb testing.TB, content []byte) string {
2121
tb.Helper()
2222

23-
f, err := os.CreateTemp("", "json_log_viewer_test")
23+
f, err := os.CreateTemp(tb.TempDir(), "json_log_viewer_test")
2424
require.NoError(tb, err)
2525

2626
defer func() { assert.NoError(tb, f.Close()) }()

0 commit comments

Comments
 (0)