log

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LogVerbosityInfo is the verbosity level for info logging.
	LogVerbosityInfo = 0
	// LogVerbosityDebug is the verbosity level for debug logging.
	LogVerbosityDebug = 2
	// LogVerbosityTrace is the verbosity level for trace logging.
	LogVerbosityTrace = 9
)
View Source
const (
	// LogFormatText specifies a textual log format.
	LogFormatText = "text"
	// LogFormatJSON specifies a JSON log format.
	LogFormatJSON = "json"
)
View Source
const LoggerKey loggerCtxKeyType = "flintlockd.logger"

LoggerKey is the key to use for the logger in the context.

Variables

View Source
var ErrLogOutputRequired = errors.New("you must specify a log output")

ErrLogOutputRequired is used when no log output is specified.

Functions

func AddFlagsToCommand

func AddFlagsToCommand(cmd *cobra.Command, config *Config)

AddFlagsToCommand will add the logging flags to the supplied command and bind to the provided config.

func Configure

func Configure(logConfig *Config) error

Configure will configure the logger from the supplied config.

func GetLogger

func GetLogger(ctx context.Context) *logrus.Entry

GetLogger will get a logger from the supplied context for create a new logger.

func IsInvalidLogFormat

func IsInvalidLogFormat(err error) bool

IsInvalidLogFormat tests an error to see if its a invalid log format error.

func WithLogger

func WithLogger(ctx context.Context, logger *logrus.Entry) context.Context

WithLogger is used to attached a logger to a specific context.

Types

type Config

type Config struct {
	// Verbosity specifies the logging verbosity level.
	Verbosity int
	// Format specifies the logging output format.
	Format string
	// Output specifies the destination for logging. You can specify the special
	// values of 'stderr' or 'stdout' or a file path.
	Output string
}

Config represents the configuration settings for a logger.

Jump to

Keyboard shortcuts

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