utils: ensure loggin path is used correctly
This commit is contained in:
parent
e92e3e4e66
commit
8ebc74b3a3
|
@ -30,7 +30,7 @@
|
||||||
},
|
},
|
||||||
"remote": "https://pterodactyl.app",
|
"remote": "https://pterodactyl.app",
|
||||||
"log": {
|
"log": {
|
||||||
"path": "logs/",
|
"path": "/srv/daemon-data/logs/",
|
||||||
"level": "info",
|
"level": "info",
|
||||||
"deleteAfterDays": 100
|
"deleteAfterDays": 100
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,6 +2,7 @@ package tools
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Pterodactyl/wings/constants"
|
"github.com/Pterodactyl/wings/constants"
|
||||||
|
@ -26,12 +27,12 @@ func InitLogging() {
|
||||||
// ConfigureLogging applies the configuration to the logging library.
|
// ConfigureLogging applies the configuration to the logging library.
|
||||||
func ConfigureLogging() error {
|
func ConfigureLogging() error {
|
||||||
|
|
||||||
path := viper.GetString(config.LogPath)
|
path := filepath.Clean(viper.GetString(config.LogPath))
|
||||||
if err := os.MkdirAll(path, constants.DefaultFilePerms); err != nil {
|
if err := os.MkdirAll(path, constants.DefaultFilePerms); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
writer := rotatelogs.New(
|
writer := rotatelogs.New(
|
||||||
path+"wings.%Y%m%d-%H%M.log",
|
path+"/wings.%Y%m%d-%H%M.log",
|
||||||
rotatelogs.WithLinkName(path),
|
rotatelogs.WithLinkName(path),
|
||||||
rotatelogs.WithMaxAge(time.Duration(viper.GetInt(config.LogDeleteAfterDays))*time.Hour*24),
|
rotatelogs.WithMaxAge(time.Duration(viper.GetInt(config.LogDeleteAfterDays))*time.Hour*24),
|
||||||
rotatelogs.WithRotationTime(time.Duration(604800)*time.Second),
|
rotatelogs.WithRotationTime(time.Duration(604800)*time.Second),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user