utils: ensure loggin path is used correctly

This commit is contained in:
Jakob Schrettenbrunner 2017-09-16 14:00:11 +02:00
parent e92e3e4e66
commit 8ebc74b3a3
2 changed files with 4 additions and 3 deletions

View File

@ -30,7 +30,7 @@
},
"remote": "https://pterodactyl.app",
"log": {
"path": "logs/",
"path": "/srv/daemon-data/logs/",
"level": "info",
"deleteAfterDays": 100
},

View File

@ -2,6 +2,7 @@ package tools
import (
"os"
"path/filepath"
"time"
"github.com/Pterodactyl/wings/constants"
@ -26,12 +27,12 @@ func InitLogging() {
// ConfigureLogging applies the configuration to the logging library.
func ConfigureLogging() error {
path := viper.GetString(config.LogPath)
path := filepath.Clean(viper.GetString(config.LogPath))
if err := os.MkdirAll(path, constants.DefaultFilePerms); err != nil {
return err
}
writer := rotatelogs.New(
path+"wings.%Y%m%d-%H%M.log",
path+"/wings.%Y%m%d-%H%M.log",
rotatelogs.WithLinkName(path),
rotatelogs.WithMaxAge(time.Duration(viper.GetInt(config.LogDeleteAfterDays))*time.Hour*24),
rotatelogs.WithRotationTime(time.Duration(604800)*time.Second),