Documentation
¶
Overview ¶
Package cmdlog provides functions for creating development and production loggers, as well as flags for command-line tools.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDevelopmentLogger ¶
NewDevelopmentLogger creates a new zap.Logger for logging development and deployment tools with optional Options.
func NewProductionLogger ¶
NewProductionLogger creates a new zap.Logger for logging production with optional Options.
Types ¶
type Options ¶
type Options struct {
// These Extra options will be passed into [zap.Config.Build] when a logger
// creation function is called right before the new [zap.Logger] is returned.
Extra []zap.Option
// Enable verbose output. The logging level will be set to [zap.DebugLevel].
EnableVerbose bool
// Enable colorful output.
EnableColor bool
// contains filtered or unexported fields
}
Options is options to create a new zap.Logger.
func NewOptions ¶
func NewOptions(level zap.AtomicLevel, opts ...zap.Option) Options
NewOptions creates a new Options with the given logging level and optional zap.Option's.
func (*Options) ColorFlag ¶
ColorFlag defines a new "color" flag for the given flag.FlagSet. The flag will set the [Options.EnableColor] field.
func (*Options) LogLevelFlag ¶
LogLevelFlag defines a new "loglevel" flag for the given flag.FlagSet. The flag will set the logging level.
func (*Options) SetLogLevel ¶
SetLogLevel sets the logging level to the given value.
func (*Options) VerboseFlag ¶
VerboseFlag defines a new "verbose" and "v" flags for the given flag.FlagSet. The flags will set the [Options.EnableVerbose] field.