format

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package format implements a custom format logs

Index

Constants

View Source
const (
	BareFormatName     = "bare"
	PrettyFormatName   = "pretty"
	JSONFormatName     = "json"
	KeyValueFormatName = "key-value"
)

Variables

This section is empty.

Functions

func NewBareFormat

func NewBareFormat() Placeholders

func NewJSONFormat

func NewJSONFormat() Placeholders

func NewKeyValueFormat

func NewKeyValueFormat() Placeholders

func NewPrettyFormat

func NewPrettyFormat() Placeholders

func ParseFormat

func ParseFormat(str string) (Placeholders, error)

Types

type Formatter

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

func NewFormatter

func NewFormatter(phs placeholders.Placeholders) *Formatter

NewFormatter returns a new Formatter instance with default values.

func (*Formatter) DisableColors

func (formatter *Formatter) DisableColors()

DisableColors disables log color.

func (*Formatter) DisableRelativePaths

func (formatter *Formatter) DisableRelativePaths()

DisableRelativePaths disables the conversion of absolute paths to relative ones.

func (*Formatter) Format

func (formatter *Formatter) Format(entry *log.Entry) ([]byte, error)

Format implements logrus.Format.

func (*Formatter) SetBaseDir

func (formatter *Formatter) SetBaseDir(baseDir string) error

func (*Formatter) SetFormat

func (formatter *Formatter) SetFormat(phs placeholders.Placeholders)

SetFormat sets log format.

Directories

Path Synopsis
Package options represents a set of placeholders options.
Package options represents a set of placeholders options.
Package placeholders represents a set of placeholders for formatting various log values.
Package placeholders represents a set of placeholders for formatting various log values.

Jump to

Keyboard shortcuts

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