mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
fix missing error message on wrong config.
This commit is contained in:
parent
8381020415
commit
bd04ca88e8
11
cmd/root.go
11
cmd/root.go
@ -68,8 +68,11 @@ func init() {
|
|||||||
|
|
||||||
// read config values
|
// read config values
|
||||||
err := viper.ReadInConfig()
|
err := viper.ReadInConfig()
|
||||||
if err != nil && config != "" {
|
if err != nil {
|
||||||
panic("unable to read config file: " + err.Error())
|
_, notFound := err.(viper.ConfigFileNotFoundError)
|
||||||
|
if !notFound {
|
||||||
|
log.Fatal().Err(err).Msg("unable to read config file")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get full config file path
|
// get full config file path
|
||||||
@ -93,13 +96,13 @@ func init() {
|
|||||||
if _, err := os.Stat(latest); err == nil {
|
if _, err := os.Stat(latest); err == nil {
|
||||||
err = os.Rename(latest, filepath.Join(rootConfig.LogDir, "neko."+time.Now().Format("2006-01-02T15-04-05Z07-00")+".log"))
|
err = os.Rename(latest, filepath.Join(rootConfig.LogDir, "neko."+time.Now().Format("2006-01-02T15-04-05Z07-00")+".log"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("failed to rotate log file: " + err.Error())
|
log.Fatal().Err(err).Msg("failed to rotate log file")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logf, err := os.OpenFile(latest, os.O_RDWR|os.O_CREATE, 0666)
|
logf, err := os.OpenFile(latest, os.O_RDWR|os.O_CREATE, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("failed to open log file: " + err.Error())
|
log.Fatal().Err(err).Msg("failed to open log file")
|
||||||
}
|
}
|
||||||
|
|
||||||
logWriter = diode.NewWriter(logf, 1000, 10*time.Millisecond, func(missed int) {
|
logWriter = diode.NewWriter(logf, 1000, 10*time.Millisecond, func(missed int) {
|
||||||
|
Loading…
Reference in New Issue
Block a user