common.go 681 字节
package common

import (
	"oppmg/common/config"
	"oppmg/common/log"
	"oppmg/common/redis"

	"github.com/astaxie/beego"
)

func ResetCommonConfig() {
	mconfig := config.RestMyConfig()
	var setlog log.SetLoggerConfig
	if mconfig.LogOutput == "console" {
		setlog = &log.LoggerConsole{
			Level: log.LogLevelDebug, Color: false,
		}
	} else if mconfig.LogOutput == "file" {
		setlog = &log.LoggerFile{
			Level:    log.LogLevel(mconfig.LogLevel),
			FileName: mconfig.LogFilename,
		}
	}

	var logCallfunc bool
	if beego.BConfig.RunMode != "prod" {
		logCallfunc = true
	}
	log.ResetLog(setlog, logCallfunc)
	redis.SetRedis(mconfig.RedisAddPort, mconfig.RedisAuth, mconfig.RedisDB)
}