text

package
v1.0.0-dev.24 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(options ...Option) logrus.Formatter

New returns a new logrus formatter for text.

Types

type Option

type Option func(formatter *logrus.TextFormatter)

Option represents a text formatter options.

func WithCallerPrettyfier

func WithCallerPrettyfier(value func(*runtime.Frame) (function string, file string)) Option

WithCallerPrettyfier sets formatter's caller prettyfier to value. Can be set by the user to modify the content of the function and file keys in the data when ReportCaller is activated. If any of the returned value is the empty string the corresponding key will be removed from fields.

func WithDisableColors

func WithDisableColors(value bool) Option

WithDisableColors sets formatter's disable colors to value.

func WithDisableLevelTruncation

func WithDisableLevelTruncation(value bool) Option

WithDisableLevelTruncation sets formatter's disable level truncation to value. Disables the truncation of the level text to 4 characters.

func WithDisableQuote

func WithDisableQuote(value bool) Option

WithDisableQuote sets formatter's disable quote to value.

func WithDisableSorting

func WithDisableSorting(value bool) Option

WithDisableSorting sets formatter's disable sorting to value. The fields are sorted by default for a consistent output. For applications that log extremely frequently and don't use the JSON formatter this may not be desired.

func WithDisableTimestamp

func WithDisableTimestamp(value bool) Option

WithDisableTimestamp sets formatter's disable timestamp to value. Disable timestamps is useful when output is redirected to logging system that already adds timestamps.

func WithEnvironmentOverrideColors

func WithEnvironmentOverrideColors(value bool) Option

WithEnviromentOverrideColors sets formatter's override colors to value. Override coloring based on CLICOLOR and CLICOLOR_FORCE. - https://bixense.com/clicolors/

func WithFieldMap

func WithFieldMap(value logrus.FieldMap) Option

WithFieldMap sets formatter's field map to value.

func WithForceColors

func WithForceColors(value bool) Option

WithForceColors sets formatter's force colors to value.

func WithForceQuote

func WithForceQuote(value bool) Option

WithForceQuote sets formatter's force quote to value.

func WithFullTimestamp

func WithFullTimestamp(value bool) Option

WithFullTimestamp sets formatter's full timestamp to value.

func WithPadLevelText

func WithPadLevelText(value bool) Option

WithPadLevelText sets formatter's pad level text to value. Adds padding the level text so that all the levels output at the same length PadLevelText is a superset of the DisableLevelTruncation option.

func WithQuoteEmptyFields

func WithQuoteEmptyFields(value bool) Option

WithQuoteEmptyFields sets formatter's quote empty fields to value. This will wrap empty fields in quotes if true.

func WithSortingFunc

func WithSortingFunc(value func([]string)) Option

WithSortingFunc sets formatter's sorting func to value. The keys sorting function, when uninitialized it uses sort.Strings.

func WithTimestampFormat

func WithTimestampFormat(value string) Option

WithTimestampFormat sets formatter's timestamp format to value. The format to use is the same than for time.Format or time.Parse from the standard library.

Jump to

Keyboard shortcuts

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