diff --git a/thorlog/common/event.go b/thorlog/common/event.go index d01930a..8f2bbad 100644 --- a/thorlog/common/event.go +++ b/thorlog/common/event.go @@ -15,10 +15,17 @@ const ( Debug LogLevel = "Debug" ) +// LogEventMetadata contains the metadata of a log event. +// It is used to store common fields that are available in all log events. +// +// In a textlog formatted event, some of these fields are part of the header and do +// not occur "normally" as a KEY: VALUE pair in the event body. +// These fields are marked with the `textlog:"-"` tag to prevent them from being +// included in the event body. type LogEventMetadata struct { Time time.Time `json:"time" textlog:"-"` Lvl LogLevel `json:"level" textlog:"-"` - Mod string `json:"module" textlog:"-"` + Mod string `json:"module" textlog:"module"` ScanID string `json:"scan_id" textlog:"scanid,omitempty"` GenID string `json:"event_id" textlog:"uid,omitempty"` Source string `json:"hostname" textlog:"-"` diff --git a/thorlog/v1/event.go b/thorlog/v1/event.go index 6a685a1..8126db6 100644 --- a/thorlog/v1/event.go +++ b/thorlog/v1/event.go @@ -80,7 +80,7 @@ func (e Event) MarshalJSON() ([]byte, error) { type Metadata struct { Time time.Time `json:"time" textlog:"-"` Lvl common.LogLevel `json:"level" textlog:"-"` - Mod string `json:"module" textlog:"-"` + Mod string `json:"module" textlog:"module"` ScanID string `json:"scanid" textlog:"scanid,omitempty"` GenID string `json:"uid" textlog:"uid,omitempty"` Source string `json:"hostname" textlog:"-"` diff --git a/thorlog/v2/event.go b/thorlog/v2/event.go index fd6d014..a890ff6 100644 --- a/thorlog/v2/event.go +++ b/thorlog/v2/event.go @@ -105,7 +105,7 @@ func (e Event) MarshalJSON() ([]byte, error) { type Metadata struct { Time time.Time `json:"time" textlog:"-"` Lvl common.LogLevel `json:"level" textlog:"-"` - Mod string `json:"module" textlog:"-"` + Mod string `json:"module" textlog:"module"` ScanID string `json:"scanid" textlog:"scanid,omitempty"` GenID string `json:"uid" textlog:"uid,omitempty"` Source string `json:"hostname" textlog:"-"` diff --git a/thorlog/v3/event.go b/thorlog/v3/event.go index c47c4a0..e1adc83 100644 --- a/thorlog/v3/event.go +++ b/thorlog/v3/event.go @@ -16,7 +16,7 @@ import ( type Finding struct { jsonlog.ObjectHeader Meta LogEventMetadata `json:"meta" textlog:",expand"` - Text string `json:"message" textlog:"-"` + Text string `json:"message" textlog:"message"` Subject ReportableObject `json:"subject" textlog:",expand"` Score int64 `json:"score" textlog:"score"` Reasons []Reason `json:"reasons" textlog:",expand"` @@ -166,7 +166,7 @@ func NewFinding(subject ReportableObject, message string) *Finding { type Message struct { jsonlog.ObjectHeader Meta LogEventMetadata `json:"meta" textlog:",expand"` - Text string `json:"message" textlog:"-"` + Text string `json:"message" textlog:"message"` Fields MessageFields `json:"fields" textlog:",expand" jsonschema:"nullable"` LogVersion common.Version `json:"log_version"` }