formatter

package
v1.1.12 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: MIT Imports: 6 Imported by: 70

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CLI

type CLI struct {
	NoUseColors bool
	// contains filtered or unexported fields
}

CLI is a formatter for outputting CLI logs

func NewCLI added in v1.1.1

func NewCLI(noUseColors bool) *CLI

NewCLI returns a new CLI based formatter

func (*CLI) Format

func (c *CLI) Format(event *LogEvent) ([]byte, error)

Format formats the log event data into bytes

type Formatter

type Formatter interface {
	// Format formats the log event data into bytes
	Format(event *LogEvent) ([]byte, error)
}

Formatter type format raw logging data into something useful

type JSON

type JSON struct{}

JSON is a formatter for outputting json logs

func (*JSON) Format

func (j *JSON) Format(event *LogEvent) ([]byte, error)

Format formats the log event data into bytes

type LogEvent

type LogEvent struct {
	Message  string
	Level    levels.Level
	Metadata map[string]string
}

LogEvent is the respresentation of a single event to be logged.

type Tee added in v1.1.5

type Tee struct {
	Wrapper Formatter

	Formatter Formatter
	// contains filtered or unexported fields
}

Tee formatter can be used to write the event to a writer while also use the existing formatter and output

func NewTee added in v1.1.5

func NewTee(wrapper Formatter, w io.Writer) (teeW *Tee)

NewTee returns a new TeeWriter with default JSON messages

func (*Tee) Format added in v1.1.5

func (tee *Tee) Format(event *LogEvent) (bts []byte, err error)

Format saves the event and forwards the event to the internal Wrapper

Jump to

Keyboard shortcuts

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