You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nnet/config/config.go

36 lines
817 B
Go

2 years ago
package config
import (
"fmt"
"time"
)
const (
// DevMode means development mode.
DevMode = "dev"
// TestMode means test mode.
TestMode = "test"
// ProductionMode means production mode.
ProductionMode = "prod"
)
type (
EngineConf struct {
// TaskTimerPrecision // 全局任务的timer间隔
TaskTimerPrecision time.Duration `json:",default=1s"`
// Mode 运行模式
2 years ago
Mode string `json:",default=dev,options=[dev,test,prod]"`
// Name 引擎名称
Name string `json:",default=NL,env=ENGINE_NAME"`
}
)
// ShallLogDebug 是否应该打印 Debug 级别的日志,打印的首要条件是 nlog 的打印级别为 debug
func (c EngineConf) ShallLogDebug() bool {
return c.Mode == DevMode || c.Mode == TestMode
}
func (c EngineConf) LogPrefix() string {
return fmt.Sprintf("[NNet-%s]", c.Name)
}