Documentation
¶
Index ¶
- Variables
- type CmdLineConfigLoader
- type Config
- type ConfigLoader
- type Duration
- type EmptyLogger
- func (l EmptyLogger) Debug(args ...interface{})
- func (l EmptyLogger) Debugf(format string, args ...interface{})
- func (l EmptyLogger) Error(args ...interface{})
- func (l EmptyLogger) Errorf(format string, args ...interface{})
- func (l EmptyLogger) Fatal(args ...interface{})
- func (l EmptyLogger) Fatalf(format string, args ...interface{})
- func (l EmptyLogger) Info(args ...interface{})
- func (l EmptyLogger) Infof(format string, args ...interface{})
- func (l EmptyLogger) Warn(args ...interface{})
- func (l EmptyLogger) Warnf(format string, args ...interface{})
- type LogLevel
- type Logger
- type Manager
- type MapObject
- type StdLogger
- func (l *StdLogger) Debug(args ...interface{})
- func (l *StdLogger) Debugf(format string, args ...interface{})
- func (l *StdLogger) Error(args ...interface{})
- func (l *StdLogger) Errorf(format string, args ...interface{})
- func (l *StdLogger) Fatal(args ...interface{})
- func (l *StdLogger) Fatalf(format string, args ...interface{})
- func (l *StdLogger) Info(args ...interface{})
- func (l *StdLogger) Infof(format string, args ...interface{})
- func (l *StdLogger) LogLevel() LogLevel
- func (l *StdLogger) SetLogLevel(level LogLevel)
- func (l *StdLogger) Warn(args ...interface{})
- func (l *StdLogger) Warnf(format string, args ...interface{})
- type StdinConfigLoader
- type StringList
- type StringParsable
Constants ¶
This section is empty.
Variables ¶
var ( // Log used in the client. Initially its set to an empty logger and must be // set with a specific logging implementation in order to log messages Log = Logger(EmptyLogger{}) //LogLevels represents the different supported levels for logging messages LogLevels = struct { Debug LogLevel Info LogLevel Warn LogLevel Error LogLevel Fatal LogLevel Off LogLevel }{ LogLevel(0), LogLevel(1), LogLevel(2), LogLevel(3), LogLevel(4), LogLevel(5), } )
Functions ¶
This section is empty.
Types ¶
type CmdLineConfigLoader ¶
type CmdLineConfigLoader struct { }
CmdLineConfigLoader is config loader that makes the given config fields available as a command line flags for overwriting.
func (*CmdLineConfigLoader) Load ¶
func (cmd *CmdLineConfigLoader) Load(config Config) error
Load will load the config field values as command line flags
type Config ¶
type Config interface { // Validates assigned config values Validate() error // DumpJSON will return JSON marshalled string of config DumpJSON() (string, error) // DumpYAML will return YAML marshalled string of config DumpYAML() (string, error) }
Config defines a interface that needs to be implemented by all config struct's to be used with ConfigManager
type ConfigLoader ¶
type ConfigLoader interface { // Load takes in a implementation of Config and populates field values Load(config Config) error }
ConfigLoader defines a interface that needs to be implemented by a config loader to be able to plug into config manager
type Duration ¶
Duration is wrapper on time.Duration to support via new config structure for auto wiring
func (*Duration) ParseString ¶
type EmptyLogger ¶
type EmptyLogger struct{}
EmptyLogger does not log any log messages
func (EmptyLogger) Debug ¶
func (l EmptyLogger) Debug(args ...interface{})
Debug will log out the args at the debug level if debug level or lower is set
func (EmptyLogger) Debugf ¶
func (l EmptyLogger) Debugf(format string, args ...interface{})
Debugf will log out the args using the format string at the debug level if debug level or lower is set
func (EmptyLogger) Error ¶
func (l EmptyLogger) Error(args ...interface{})
Error will log out the args at the error level if error level or lower is set
func (EmptyLogger) Errorf ¶
func (l EmptyLogger) Errorf(format string, args ...interface{})
Errorf will log out the args using the format string at the error level if error level or lower is set
func (EmptyLogger) Fatal ¶
func (l EmptyLogger) Fatal(args ...interface{})
Fatal will log out the args at the fatal level if fatal level or lower is set
func (EmptyLogger) Fatalf ¶
func (l EmptyLogger) Fatalf(format string, args ...interface{})
Fatalf will log out the args using the format string at the fatal level if fatal level or lower is set
func (EmptyLogger) Info ¶
func (l EmptyLogger) Info(args ...interface{})
Info will log out the args at the info level if info level or lower is set
func (EmptyLogger) Infof ¶
func (l EmptyLogger) Infof(format string, args ...interface{})
Infof will log out the args using the format string at the info level if info level or lower is set
func (EmptyLogger) Warn ¶
func (l EmptyLogger) Warn(args ...interface{})
Warn will log out the args at the warn level if warn level or lower is set
func (EmptyLogger) Warnf ¶
func (l EmptyLogger) Warnf(format string, args ...interface{})
Warnf will log out the args using the format string at the warn level if warn level or lower is set
type Logger ¶
type Logger interface { Debug(args ...interface{}) Debugf(format string, args ...interface{}) Info(args ...interface{}) Infof(format string, args ...interface{}) Warn(args ...interface{}) Warnf(format string, args ...interface{}) Error(args ...interface{}) Errorf(format string, args ...interface{}) Fatal(args ...interface{}) Fatalf(format string, args ...interface{}) }
Logger is an interface the provides basic logging functionality that can be implemented to wrap an existing logging framework
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager auto wires the given config pointer with given set of config loaders to NewConfigManager API
func NewConfigManager ¶
func NewConfigManager(appName, description string, configLoaders ...ConfigLoader) *Manager
NewConfigManager returns new instance of ConfigManager
func NewConfigManagerWithRootCmd ¶
func NewConfigManagerWithRootCmd(rootCmd *cobra.Command, configLoaders ...ConfigLoader) *Manager
NewConfigManagerWithRootCmd returns a configManager using the provided rootCmd
func (*Manager) CreateCommandLineFlags ¶
CreateCommandLineFlags will create command line flags for given config via Cobra and Viper to support command line overriding of config values
type MapObject ¶
type MapObject struct {
Mapping map[string]interface{}
}
MapObject implements StringParsable and read int a JSON object into map[string]interface{}
func (*MapObject) ParseString ¶
ParseString exists to satisfy the StringParsable interface
type StdLogger ¶
type StdLogger struct {
// contains filtered or unexported fields
}
StdLogger will write log messages to either stdout or stderr with an appropriate prefix depending on the level of the log message
func NewStdLogger ¶
NewStdLogger creates a new StdLogger using the provided level and flags
func (*StdLogger) Debug ¶
func (l *StdLogger) Debug(args ...interface{})
Debug will log out the args at the debug level if debug level or lower is set
func (*StdLogger) Debugf ¶
Debugf will log out the args using the format string at the debug level if debug level or lower is set
func (*StdLogger) Error ¶
func (l *StdLogger) Error(args ...interface{})
Error will log out the args at the error level if error level or lower is set
func (*StdLogger) Errorf ¶
Errorf will log out the args using the format string at the error level if error level or lower is set
func (*StdLogger) Fatal ¶
func (l *StdLogger) Fatal(args ...interface{})
Fatal will log out the args at the fatal level if fatal level or lower is set
func (*StdLogger) Fatalf ¶
Fatalf will log out the args using the format string at the fatal level if fatal level or lower is set
func (*StdLogger) Info ¶
func (l *StdLogger) Info(args ...interface{})
Info will log out the args at the info level if info level or lower is set
func (*StdLogger) Infof ¶
Infof will log out the args using the format string at the info level if info level or lower is set
func (*StdLogger) SetLogLevel ¶
SetLogLevel will set the LogLevel for the logger to the specified LogLevel
type StdinConfigLoader ¶
type StdinConfigLoader struct{}
StdinConfigLoader provides autowiring of config values piped in from stdin
func (*StdinConfigLoader) Load ¶
func (s *StdinConfigLoader) Load(config interface{}) error
Load trigger recursive load of config values from yaml piped to stdin
type StringList ¶
type StringList []string
StringList is of type []string
func (*StringList) Set ¶
func (sl *StringList) Set(s string) error
Set sets the value of the StringList given the argument from cmdline
func (*StringList) String ¶
func (sl *StringList) String() string
String returns the string value of a StringList
type StringParsable ¶
StringParsable interface can be implemented by any struct that needs to be loaded as string as is and not go through its fields recursively