Skip to content
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
33 changes: 33 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: go
on:
push:
branches:
- master
pull_request:

permissions:
contents: read

env:
GOPRIVATE: github.com/NextronSystems/
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
- name: Test
run: go test -v ./...
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
- name: Lint
uses: golangci/golangci-lint-action@v8
with:
version: v2.1.6
73 changes: 73 additions & 0 deletions reference_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,82 @@ package jsonlog
import (
"testing"

"github.com/NextronSystems/jsonlog/jsonpointer"
"github.com/stretchr/testify/assert"
)

type testObject struct {
ObjectHeader

Substruct struct {
SubField1 string `json:"subfield1" textlog:"subfield1"`
} `json:"substruct" textlog:"substruct,expand"`

// nolint:unused // not used, just used to check that unexported fields are not included in the event
unexported string

AnonymousSubstruct

Nested NestedSubstruct `json:"nested" textlog:"nested,expand"`

Unexpanded UnexpandedSubstruct `json:"unexpanded" textlog:"unexpanded"`

Subfield5 string `json:"subfield5" textlog:"subfield5"`

Valuer TestEventValuer `json:"valuer" textlog:"valuer"`

SubObject *SubObject `json:"subobject" textlog:"subobject,expand"`
}

type AnonymousSubstruct struct {
SubField2 string `json:"subfield2" textlog:"subfield2"`
}

type NestedSubstruct struct {
Substruct struct {
SubField3 string `json:"subfield3" textlog:"subfield3"`
} `json:"substruct" textlog:",expand"`
}

type UnexpandedSubstruct struct {
SubField4 string `json:"subfield4" textlog:"subfield4"`
}

func (u UnexpandedSubstruct) String() string {
return u.SubField4
}

type TestEventValuer struct {
Subfield6 string `json:"subfield6"`
Subfield7 string `json:"subfield7"`
Ignore string
}

func (t *TestEventValuer) RelativeTextPointer(pointee any) (string, bool) {
if pointee == &t.Subfield6 {
return "subfield6", true
}
if pointee == &t.Subfield7 {
return "subfield7", true
}
return "", false
}

func (t *TestEventValuer) RelativeJsonPointer(pointee any) jsonpointer.Pointer {
if pointee == &t.Subfield6 {
return jsonpointer.New("subfield6")
}
if pointee == &t.Subfield7 {
return jsonpointer.New("subfield7")
}
return nil
}

type SubObject struct {
ObjectHeader
Subfield8 string `json:"subfield8" textlog:"subfield8"`
}

func TestReference_ToJsonPointer(t *testing.T) {
var test testObject
test.Substruct.SubField1 = "subfield1"
Expand Down
6 changes: 4 additions & 2 deletions thorlog/jsonschema/go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module gitlab.nextron/nextron-research/jsonlog/thorlog/jsonschema
module github.com/NextronSystems/jsonlog/thorlog/jsonschema

go 1.23.1

require (
github.com/NextronSystems/jsonlog v0.0.0-20240927093204-3ba6fa967aa2
github.com/NextronSystems/jsonlog v0.0.0-20250522074152-0a205b123911
github.com/invopop/jsonschema v0.12.0
github.com/wk8/go-ordered-map/v2 v2.1.8
)
Expand All @@ -17,3 +17,5 @@ require (
golang.org/x/mod v0.15.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/NextronSystems/jsonlog => ../../
4 changes: 2 additions & 2 deletions thorlog/jsonschema/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/NextronSystems/jsonlog v0.0.0-20240927093204-3ba6fa967aa2 h1:Zf5UV/1V+wA0F9rrpLZRL0Fvxi+9WuD9a0KsKnrAnmE=
github.com/NextronSystems/jsonlog v0.0.0-20240927093204-3ba6fa967aa2/go.mod h1:Hk47VW018TX8o/0sxK+EJt16iRE7gB91zGZGiaAjcww=
github.com/NextronSystems/jsonlog v0.0.0-20250522074152-0a205b123911 h1:jmmvwkhul9DtWWOBhyeyXV9LA4cQzqJ0UyniD3e/HZQ=
github.com/NextronSystems/jsonlog v0.0.0-20250522074152-0a205b123911/go.mod h1:Hk47VW018TX8o/0sxK+EJt16iRE7gB91zGZGiaAjcww=
github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk=
github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg=
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
Expand Down
4 changes: 2 additions & 2 deletions thorlog/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/NextronSystems/jsonlog/thorlog/common"
thorlogv1 "github.com/NextronSystems/jsonlog/thorlog/v1"
thorlogv2 "github.com/NextronSystems/jsonlog/thorlog/v2"
"github.com/NextronSystems/jsonlog/thorlog/v3"
thorlogv3 "github.com/NextronSystems/jsonlog/thorlog/v3"
)

func ParseEvent(data []byte) (common.Event, error) {
Expand All @@ -32,7 +32,7 @@ func ParseEvent(data []byte) (common.Event, error) {
}
return &event, nil
case common.JsonV3:
var logObject thorlog.EmbeddedObject
var logObject thorlogv3.EmbeddedObject
if err := json.Unmarshal(data, &logObject); err != nil {
return nil, err
}
Expand Down