formatter

package
v1.1.77 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 6 Imported by: 155 modules, 100 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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