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

35 lines
636 B

package config
import (
"flag"
"fmt"
"io/ioutil"
utils "youtube_collection_server/Utils"
"github.com/sirupsen/logrus"
"gopkg.in/yaml.v2"
)
var configFile string
var MyEnv EnvConfig
var Logger *logrus.Logger
func init() {
flag.StringVar(&configFile, "cf", "config.yml", "配置文件名")
}
func InitConfig() {
flag.Parse()
//读取配置文件
data, _ := ioutil.ReadFile(configFile)
err := yaml.Unmarshal(data, &MyEnv)
if err != nil {
fmt.Println("读取配置文件错误...")
return
}
//初始化日志
Logger = utils.InitLogger(MyEnv.Log.LogEnv, MyEnv.Log.LogPath)
Logger.Info("初始化Logger成功...")
}