config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	OptionName = "name"
	OptionDesc = "description"
)
View Source
const (
	LogDefault = "default"
)

Variables

View Source
var (
	DefaultLogLevel = logger.LOG_LEVEL_INFO

	// LogLevel is the threshold for this ColorLogger.
	//
	// Logging messages which are less severe than level will be ignored.
	//
	// Logging messages with a severity equal or greater than level will be emitted.
	//
	// Levels are represented numerically, with 0 being the most "severe" and 3 being the least "severe".
	//
	// When LogLevel is set to LOG_LEVEL_NONE (3), no messages will be emitted.
	//
	// When LogLevel is set to LOG_LEVEL_ALL, all messages except for Trace messages will be emitted.
	//
	// In order for Trace messages to be emitted, LogLevel must be set to LOG_LEVEL_ALL, and Verbose must be set to true.
	LogLevel = DefaultLogLevel

	// LogColor is a boolean flag indicating whether colored output is enabled (true) or not (false).
	LogColor = true

	// Verbose must be set to true in order for Trace log messages to be emitted.
	Verbose bool

	// LogTypePrefix is a bool flag that, when true, instructs the logger to also prepend the type of
	// a given log message (e.g., "ERROR", "WARNING", "DEBUG", "TRACE", or "INFO") to the beginning of
	// the message when emitting it.
	LogTypePrefix = true
)
View Source
var (
	Flag          *flag.FlagSet = flag.NewFlagSet("", flag.ContinueOnError)
	ErrNonPointer               = errors.New("validate with non-pointer")
	ErrPrintUsage               = errors.New("print usage")
)

Functions

func GetDefaultLogger

func GetDefaultLogger() logger.Logger

func GetLogger

func GetLogger(prefix string) logger.Logger

func InitLogger

func InitLogger(log *logger.Logger, prefix interface{})

func Polyfill

func Polyfill(opts Options, fill Options) error

func ValidateOptions

func ValidateOptions(opts Options) (*flag.FlagSet, error)

ValidateOptions validates the options with command line arguments. Returns a FlagSet and error. If returns ErrPrintUsage, the usage should be printed.

func ValidateOptionsWithFlags

func ValidateOptionsWithFlags(opts Options, args ...string) (*flag.FlagSet, error)

ValidateOptionsWithFlags validates the options with specified arguments. Returns a FlagSet and error. If returns ErrPrintUsage, the usage should be printed.

Types

type LoggerOptions

type LoggerOptions struct {
	Options

	Debug   bool `name:"debug" description:"Display debug logs."`
	Verbose bool `name:"v" description:"Display verbose logs."`
}

func (*LoggerOptions) Validate

func (o *LoggerOptions) Validate() error

type Options

type Options interface {
	// Validate validates the options.
	Validate() error
	// contains filtered or unexported methods
}

Options is the interface for all config options. See the package-level substructs to define your options.

func NewOptions

func NewOptions() Options

type SeedOptions

type SeedOptions struct {
	Options

	Seed int64 `name:"seed" description:"Random seed to reproduce simulation."`
}

func (*SeedOptions) Validate

func (opts *SeedOptions) Validate() error

Jump to

Keyboard shortcuts

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