cmdlog

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 8 Imported by: 1

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

func NewDevelopmentLogger(options ...Options) (*zap.Logger, error)

NewDevelopmentLogger creates a new zap.Logger for logging development and deployment tools with optional Options.

func NewProductionLogger

func NewProductionLogger(options ...Options) (*zap.Logger, error)

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

func (opts *Options) ColorFlag(set *flag.FlagSet)

ColorFlag defines a new "color" flag for the given flag.FlagSet. The flag will set the [Options.EnableColor] field.

func (*Options) LogLevelFlag

func (opts *Options) LogLevelFlag(set *flag.FlagSet)

LogLevelFlag defines a new "loglevel" flag for the given flag.FlagSet. The flag will set the logging level.

func (*Options) SetLogLevel

func (opts *Options) SetLogLevel(value string) error

SetLogLevel sets the logging level to the given value.

func (*Options) VerboseFlag

func (opts *Options) VerboseFlag(set *flag.FlagSet)

VerboseFlag defines a new "verbose" and "v" flags for the given flag.FlagSet. The flags will set the [Options.EnableVerbose] field.

Jump to

Keyboard shortcuts

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