ecslog

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "v0.6.0"

Version is the semver version of this tool.

Variables

This section is empty.

Functions

func LevelNameOrderStr added in v0.5.0

func LevelNameOrderStr() string

LevelNameOrderStr returns a string with all the known level names in order in the format "trace < debug < ...".

func LogLevelLess

func LogLevelLess(level1, level2 string) bool

LogLevelLess returns true iff level1 is less than level2.

Because ECS doesn't mandate a set of log level names for the "log.level" field, nor any specific ordering of those log levels, this is a best effort based on names and ordering from common logging frameworks. If a level name is unknown, this returns false. Level names are considered case-insensitive.

Types

type Formatter

type Formatter interface {
	// contains filtered or unexported methods
}

Formatter is the interface for formatting a log record.

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

Renderer is the class used to drive ECS log rendering (aka pretty printing).

func NewRenderer

func NewRenderer(shouldColorize, colorScheme, formatName string, maxLineLen int, excludeFields, includeFields []string, ecsLenient, timestampShowDiff bool) (*Renderer, error)

NewRenderer returns a new ECS logging log renderer.

  • `shouldColorize` is one of "auto" (meaning colorize if the output stream is a TTY), "yes", or "no"
  • `colorScheme` is the name of one of the colors schemes in ansipainter.PainterFromName
  • `maxLineLen` a maximum number of bytes for a line that will be considered for log record processing. It must be a positive number between 1 and 1048576 (2^20), or -1 to use the default value (16384).
  • `ecsLenient` is a bool indicating if rendering should be lenient in validating if a JSON line is an ecs-logging record. Strictly (the default) to be an ecs-logging record it must have ecs.version, log.level, and @timestamp. If this option is true, it will only require *one* of those fields to exist.
  • `timestampShowDiff` is a bool indicating if the @timestamp diff from the preceding log record should be styled.

func (*Renderer) RenderFile

func (r *Renderer) RenderFile(in io.Reader, out io.Writer) error

RenderFile renders log records from the given open file stream to the given output stream (typically os.Stdout).

func (*Renderer) SetKQLFilter

func (r *Renderer) SetKQLFilter(kql string) error

SetKQLFilter sets the KQL statement used for log record filtering.

func (*Renderer) SetLevelFilter

func (r *Renderer) SetLevelFilter(level string)

SetLevelFilter sets the level at which `log.level` filtering is done.

func (*Renderer) SetStrictFilter added in v0.2.0

func (r *Renderer) SetStrictFilter(strict bool)

SetStrictFilter tells the renderer whether to strictly suppress input lines that are not valid ecs-logging records.

Jump to

Keyboard shortcuts

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