logevent

package
v0.0.0-...-c66a2f6 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: MIT Imports: 10 Imported by: 61

Documentation

Index

Constants

View Source
const MessageField = "message"
View Source
const TagsField = "tags"
View Source
const TimestampField = "@timestamp"

TagsField is the event tags field name

Variables

This section is empty.

Functions

func FormatWithCurrentTime

func FormatWithCurrentTime(text string) (result string)

FormatWithCurrentTime format string with current time, ex: %{+2006-01-02}

func FormatWithEnv

func FormatWithEnv(text string) (result string)

FormatWithEnv format string with environment value, ex: %{HOSTNAME}

func FormatWithEventTime

func FormatWithEventTime(text string, evevtTime time.Time) (result string)

FormatWithEventTime format string with event time, ex: %{+@2006-01-02}

func SetConfig

func SetConfig(c *Config)

SetConfig for LogEvent

Types

type Config

type Config struct {
	SortMapKeys bool     `yaml:"sort_map_keys"`
	RemoveField []string `yaml:"remove_field"`
	// contains filtered or unexported fields
}

type LogEvent

type LogEvent struct {
	Timestamp time.Time      `json:"timestamp"`
	Message   string         `json:"message"`
	Tags      []string       `json:"tags,omitempty"`
	Extra     map[string]any `json:"-"`
	Drop      bool
}

func (*LogEvent) AddTag

func (t *LogEvent) AddTag(tags ...string)

AddTag add tags into event.Tags

func (LogEvent) Format

func (t LogEvent) Format(format string) (out string)

Format return string with current time / LogEvent field / ENV, ex: %{hostname}

func (LogEvent) Get

func (t LogEvent) Get(field string) (v any)

func (LogEvent) GetString

func (t LogEvent) GetString(field string) string

func (LogEvent) GetValue

func (t LogEvent) GetValue(field string) (any, bool)

func (LogEvent) MarshalIndent

func (t LogEvent) MarshalIndent() (data []byte, err error)

func (LogEvent) MarshalJSON

func (t LogEvent) MarshalJSON() (data []byte, err error)

func (*LogEvent) ParseTags

func (t *LogEvent) ParseTags(tags any) bool

ParseTags parse tags into event.Tags

func (*LogEvent) Remove

func (t *LogEvent) Remove(field string) bool

func (*LogEvent) RemoveTag

func (t *LogEvent) RemoveTag(tags ...string)

RemoveTag removes tags from event.Tags

func (*LogEvent) SetValue

func (t *LogEvent) SetValue(field string, v any) bool

Jump to

Keyboard shortcuts

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