logging

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2021 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Emitters = make(map[string]Emitter)

Emitters is the registry of Emitter implementers

Functions

func Emit

func Emit(emitter Emitter, logMessage string)

Emit is launched as a goroutine for individual log lines to be sent concurrently. When it receives a line, it tries to decode it from JSON. If that succeeds, meaning it's already a structured object, we pass it along unmodified. If not, we wrap it in a basic ECS structure.

func Register

func Register(emitterType string, emitter Emitter)

Register will make note of new types of Emitters

Types

type Emitter

type Emitter interface {
	Setup()
	HandleLogMessage(jsonSerializeable interface{}) error
	Cleanup() error
}

An Emitter defines how to ship a log message to a log service.

type Message

type Message struct {
	ECSVersion string            `json:"ecs.version"`
	Timestamp  time.Time         `json:"@timestamp"`
	Labels     map[string]string `json:"labels"`
	Tags       []string          `json:"tags"`
	Message    string            `json:"message"`
}

A Message is a structured log message - only used if the log message we consume from the subprocess is not already structured

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳