Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LogLevel ¶
LogLevel returns zapcore.Level received from the given VarFrom.
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 AtomicLevel ¶ added in v0.2.0
type AtomicLevel zap.AtomicLevel
AtomicLevel is a wrapper over zap.AtomicLevel to implement the flag.Value interface.
func (AtomicLevel) Set ¶ added in v0.2.0
func (a AtomicLevel) Set(s string) error
func (AtomicLevel) String ¶ added in v0.2.0
func (a AtomicLevel) String() string
type Options ¶
type Options struct {
Level AtomicLevel
// 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. [Options.Level] will be ignored and logging level
// will be set to [zap.DebugLevel].
EnableVerbose bool
// Enable colorful output.
EnableColor bool
}
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 [Options.Level] field.
func (*Options) SetLogLevel ¶
SetLogLevel sets [Options.Level] to the value received from the given VarFrom.
func (*Options) VerboseFlag ¶
VerboseFlag defines a new "verbose" flag for the given flag.FlagSet. The flag will set the [Options.EnableVerbose] field.
type VarFrom ¶
VarFrom reads the value from a source.
func FromDotEnvFiles ¶
FromDotEnvFiles returns VarFrom that reads the variable with the given name from the optional file(s) with the given filename(s) (default: .env).
func FromString ¶ added in v0.2.0
FromString returns VarFrom that returns the given string.