flag

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2022 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultFormatter = "text"

DefaultFormatter is a name of a default formatter. This formatter *must* be registered in the FormattersMap map.

View Source
var FormattersMap = map[string]func() logrus.Formatter{
	"text": func() logrus.Formatter {
		return &formatter.XFilterFormatter{Formatter: &logrus.TextFormatter{}}
	},
	"json": func() logrus.Formatter {
		return &formatter.JSONFormatter{}
	},
}

FormattersMap is a map of supported logrus formatters. It is safe to add custom formatters to this map.

Functions

func NewLoggerFlagSet

func NewLoggerFlagSet(logger *LoggerFlag) *pflag.FlagSet

Types

type FormatTypeValue

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

FormatTypeValue implements pflag.Value. It represents a flag that allow to choose a different logrus formatter.

func (*FormatTypeValue) Formatter

func (f *FormatTypeValue) Formatter() logrus.Formatter

Formatter returns the logrus.Formatter for selected type.

func (*FormatTypeValue) Set

func (f *FormatTypeValue) Set(v string) error

Set implements the pflag.Value interface.

func (*FormatTypeValue) String

func (f *FormatTypeValue) String() string

String implements the pflag.Value interface.

func (*FormatTypeValue) Type

func (f *FormatTypeValue) Type() string

Type implements the pflag.Value interface.

type LoggerFlag

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

func (*LoggerFlag) Formatter

func (f *LoggerFlag) Formatter() logrus.Formatter

Formatter returns the logrus.Formatter for selected type.

func (*LoggerFlag) Logger

func (logger *LoggerFlag) Logger() log.Logger

func (*LoggerFlag) Verbosity

func (f *LoggerFlag) Verbosity() logrus.Level

Jump to

Keyboard shortcuts

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