36 lines
503 B
Go
36 lines
503 B
Go
|
package log
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"gopkg.in/yaml.v2"
|
||
|
"io/ioutil"
|
||
|
"os"
|
||
|
)
|
||
|
|
||
|
func init() {
|
||
|
|
||
|
bytes, err := getConfig()
|
||
|
var info *DuInfo
|
||
|
|
||
|
if err = yaml.Unmarshal(bytes, &info); err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
|
||
|
InitLogger(info.Config)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
func getConfig() ([]byte, error) {
|
||
|
configFilePath := "../conf/log.yaml"
|
||
|
_, err := os.Stat(configFilePath)
|
||
|
if os.IsNotExist(err) {
|
||
|
fmt.Println("-----------不存在")
|
||
|
} else {
|
||
|
|
||
|
fmt.Println("------------存在")
|
||
|
|
||
|
}
|
||
|
|
||
|
return ioutil.ReadFile(configFilePath)
|
||
|
}
|