Documentation
¶
Index ¶
- Constants
- Variables
- func GetDefaultLogger() logger.Logger
- func GetLogger(prefix string) logger.Logger
- func InitLogger(log *logger.Logger, prefix interface{})
- func Polyfill(opts Options, fill Options) error
- func ValidateOptions(opts Options) (*flag.FlagSet, error)
- func ValidateOptionsWithFlags(opts Options, args ...string) (*flag.FlagSet, error)
- type LoggerOptions
- type Options
- type SeedOptions
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 InitLogger ¶
func ValidateOptions ¶
ValidateOptions validates the options with command line 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
Click to show internal directories.
Click to hide internal directories.