event

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package event provides a generalized construct for representing input from a source.Source.

Index

Constants

View Source
const (
	// Bucket1 is histogram Bucket 1.
	Bucket1 = iota
	// Bucket2 is histogram Bucket 2.
	Bucket2
	// Bucket3 is histogram Bucket 3.
	Bucket3
	// Bucket4 is histogram Bucket 4.
	Bucket4
	// Bucket5 is histogram Bucket 5.
	Bucket5
	// Bucket6 is histogram Bucket 6.
	Bucket6
	// Bucket7 is histogram Bucket 7.
	Bucket7
	// Bucket8 is histogram Bucket 8.
	Bucket8

	// BucketUpperBound the highest Bucket.
	BucketUpperBound = iota - 1
)
View Source
const HumanTimeFormat = "human"

HumanTimeFormat procides human-friendly times via humanize.Time.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action string

Action an action name.

type Application

type Application string

Application the name of an application.

type Bucket

type Bucket uint8

Bucket is the

type CodeLocation

type CodeLocation string

CodeLocation is where the log event happened.

func (CodeLocation) Mark

func (cl CodeLocation) Mark(category string)

Mark manages a per-code-location meter. These meters can be used to generate metrics, as well as rate limit specific locations.

type Context

type Context string

Context a context name.

func (Context) String

func (contextName Context) String() string

String ...

type Entity

type Entity string

Entity an entity name.

func (Entity) Abbreviate

func (c Entity) Abbreviate(maxWidth int) Entity

Abbreviate shortens the name of an entity by trimming characters from the least-significant parts of the caller forward. A string is shortened until it meets the maxWidth, or no further abbreviation can be made. Example: 'com.example.of.couture.SomeClass' would be 'c.e.o.couture.SomeClass' with a value of 23. Any value between 0 and 18 would generate: 'c.e.o.c.SomeClass'.

type Error

type Error Message

Error a stack trace.

type Event

type Event struct {
	// Timestamp the timestamp. This field is required, and should default to time.Now() if not present.
	Timestamp Timestamp `json:"timestamp" regroup:"timestamp"`
	// Level the level. This field is required, and should default to Info if not present.
	Level level.Level `json:"level" regroup:"level"`
	// Message the message. This field is required.
	Message Message `json:"message" regroup:"message"`
	// Application is the name of the application that generated this event. This field is optional.
	Application Application `json:"application" regroup:"application"`
	// Action the action name. This field is optional.
	Action Action `json:"action" regroup:"action"`
	// Line the line number. This field is optional.
	Line Line `json:"line" regroup:"line"`
	// Context the context name. This field is optional.
	Context Context `json:"context" regroup:"context"`
	// Entity the entity name. This field is optional.
	Entity Entity `json:"entity" regroup:"entity"`
	// Error the error. This field is optional.
	Error Error `json:"error" regroup:"error"`
}

Event is a generalized log event.

func (Event) CodeLocation

func (event Event) CodeLocation() CodeLocation

CodeLocation returns the location where the event happened.

type Line

type Line uint64

Line a line number.

const (
	// NoLineNumber indicates no line number is present.
	NoLineNumber Line = 0
)

func (*Line) UnmarshalJSON

func (l *Line) UnmarshalJSON(bytes []byte) error

UnmarshalJSON ...

type Message

type Message string

Message a message.

func (Message) Matches

func (msg Message) Matches(filters *[]model.Filter) model.FilterKind

Matches determines if an event Matches the filters criteria.

func (Message) String

func (msg Message) String() string

String ...

type SinkEvent

type SinkEvent struct {
	Event
	SourceURL SourceURL
	Filters   model.Filters
	Mapping   *mapping.Mapping
}

SinkEvent wraps an Event with additional application metadata.

func (SinkEvent) LevelMeterBucket

func (event SinkEvent) LevelMeterBucket() Bucket

LevelMeterBucket returns the

type SourceURL

type SourceURL url.URL

SourceURL represents a source-spcific URL to events.

func (*SourceURL) HashInt

func (u *SourceURL) HashInt() int

HashInt of the string version of this URL. The hash is used to provide consistent behavior for a URL across invocations (e.g., the color of the messages).

func (*SourceURL) HashString

func (u *SourceURL) HashString() string

HashString is a hex version of the HashInt.

func (*SourceURL) Normalize

func (u *SourceURL) Normalize()

Normalize fixes situations where scheme://some/path/list is given rather than scheme:///some/path/list. In the first case this results in a hostname of some and a path of /path/list. This action rewrites it into the proper second form.

func (*SourceURL) QueryFlag

func (u *SourceURL) QueryFlag(key string) bool

QueryFlag looks up a QueryKey parameter value. If the key exists with an empty value, it is the equivalent of having set the value to true.

func (*SourceURL) QueryInt64

func (u *SourceURL) QueryInt64(key string) (*int64, error)

QueryInt64 returns the value of the QueryKey parameter a pointer to an int64. If the parameter is not set, or is set to empty, a nil pointer with no error is returned.

func (*SourceURL) QueryKey

func (u *SourceURL) QueryKey(key string) (string, bool)

QueryKey looks up a QueryKey parameter value.

func (*SourceURL) ShortForm

func (u *SourceURL) ShortForm() string

ShortForm returns a

func (*SourceURL) String

func (u *SourceURL) String() string

String ...

type Timestamp

type Timestamp time.Time

Timestamp When the even occurred.

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(bytes []byte) error

UnmarshalJSON ...

Directories

Path Synopsis
Package level provides an event-source agnostic log level system.
Package level provides an event-source agnostic log level system.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL