logentryformatter

package
v1.54.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DescribeObject

func DescribeObject(obj interface{}) string

func FormatLogLine

func FormatLogLine(text string, unwrapperMap map[LogType]Unwrapper, formatterMap map[LogType]Formatter, only, exclude map[LogType]struct{}) (string, error)

func FormatValue

func FormatValue(val interface{}) string

func NiceMap

func NiceMap(params map[string]interface{}) string

Types

type ColorizerFunc

type ColorizerFunc func(interface{}) *color.Color

type Formatter

type Formatter interface {
	// Format takes JSON bytes that represents a single log entry and returns the human-readable version.
	Format(lineJSON []byte) (string, error)
	// RawTemplate returns the raw template string for this formatter.
	RawTemplate() string
	// TemplateObjectDescription returns the description of the object that is expected to be provided to the
	// template function for this formatter. Empty string indicates that there is no suitable description.
	TemplateObjectDescription() string
}

func New

func New(entryParser func([]byte, bool) (interface{}, error), tmplString string, params ...Param) (Formatter, error)

type LogEntry

type LogEntry struct {
	Type *LogType `json:"type"`
}

type LogType

type LogType string

type Param

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

func Colorizer

func Colorizer(c ColorizerFunc) Param

func NoSubstitution

func NoSubstitution() Param

NoSubstitution configures the formatter in a mode that specifies that no substitution should be performed.

func ObjDesc

func ObjDesc(objDesc string) Param

type Unwrapper

type Unwrapper interface {
	UnwrapLogLine(lineJSON []byte) ([]byte, error)
}

An Unwrapper unwraps a line of JSON, returning the underlying log entry's contents.

type UnwrapperFunc

type UnwrapperFunc func([]byte) ([]byte, error)

The UnwrapperFunc type is an adapter to allow the use of ordinary functions as Unwrappers. If f is a function with the appropriate signature, UnwrapperFunc(f) is an Unwrapper that calls f.

func (UnwrapperFunc) UnwrapLogLine

func (f UnwrapperFunc) UnwrapLogLine(lineJSON []byte) ([]byte, error)

UnwrapLogLine calls f(lineJSON).

Jump to

Keyboard shortcuts

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