go_dreamfactory/modules/constellation/options.go
2022-10-31 09:32:16 +08:00

41 lines
747 B
Go

package constellation
import (
"errors"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/lego/utils/mapstructure"
"go_dreamfactory/modules"
)
type (
IOptions interface {
modules.IOptions
}
Options struct {
modules.Options
}
)
func (this *Options) GetDebug() bool {
return this.Debug
}
func (this *Options) GetLog() log.ILogger {
return this.Log
}
func (this *Options) LoadConfig(settings map[string]interface{}) (err error) {
if settings != nil {
if err = mapstructure.Decode(settings, &this.Options); err != nil {
return
}
if err = mapstructure.Decode(settings, this); err != nil {
return
}
}
if this.Log = log.NewTurnlog(true, log.Clone("", 4)); this.Log == nil {
err = errors.New("log is nil")
}
return
}