41 lines
735 B
Go
41 lines
735 B
Go
package modules
|
|
|
|
import (
|
|
"errors"
|
|
"go_dreamfactory/lego/core"
|
|
"go_dreamfactory/lego/sys/log"
|
|
"go_dreamfactory/lego/utils/mapstructure"
|
|
)
|
|
|
|
type (
|
|
IOptions interface {
|
|
core.IModuleOptions
|
|
GetDebug() bool
|
|
GetLog() log.ILogger
|
|
}
|
|
Options struct {
|
|
Debug bool //日志是否开启
|
|
Log log.ILogger
|
|
}
|
|
)
|
|
|
|
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) {
|
|
this.Debug = false
|
|
if settings != nil {
|
|
err = mapstructure.Decode(settings, this)
|
|
}
|
|
|
|
if this.Log = log.NewTurnlog(this.Debug, log.Clone("", 4)); this.Log == nil {
|
|
err = errors.New("log is nil")
|
|
}
|
|
return
|
|
}
|