Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct { // UUID is a unique identifier for this event UUID string `json:"uuid"` // Timestamp is the time on the event Timestamp time.Time `json:"@timestamp"` // Severity is the severity of the event Severity slog.Severity `json:"severity"` // Service is the name of the service from which the event came Service string `json:"service"` // Message is a best-effort attempt at parsing the message // from the raw line. This is handled by logstash. Message string `json:"message"` // Metadata is extra parameters put into slog lines. // This will usually be a map[string]string. Metadata interface{} `json:"metadata"` // Raw is the original log line Raw []byte `json:"-"` }
Event represents a single log event
func NewEventFromBytes ¶
NewEventFromBytes returns a structured event from a log line. It is best-effort and therefore does not return an error. This is why this approach is used over a custom JSON unmarshal function.
func (*Event) Format ¶
func (e *Event) Format() *FormattedEvent
Format returns a formatted event that can be passed to an HTML template
type FormattedEvent ¶
type FormattedEvent struct { // UUID is a unique identifier for this event UUID string // Timestamp is the time on the event Timestamp string // Severity is the severity of the event Severity string // Service is the name of the service from which the event came Service string // Message is converted to template.HTML as-is Message template.HTML // Metadata is converted to template.HTML in its raw form Metadata template.HTML // MetadataPretty is parsed as JSON and indented if successful, // otherwise it will be equal to Metadata. MetadataPretty template.HTML // Raw is the original log line Raw template.HTML }
FormattedEvent is a version of Event that is ready to pass to an HTML template
Click to show internal directories.
Click to hide internal directories.