From 5cdb6c341733194e27df1171711e5f251c7c7954 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Sun, 23 May 2021 14:24:20 -0700 Subject: [PATCH] Create+use logs dir within data dir for logging --- config/config.go | 2 +- logging/logging.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index dadc5db47..3a50c04cc 100644 --- a/config/config.go +++ b/config/config.go @@ -10,7 +10,7 @@ import ( var DatabaseFilePath = "data/owncast.db" // LogDirectory is the path to various log files -var LogDirectory = "." +var LogDirectory = "./data/logs" // EnableDebugFeatures will print additional data to help in debugging. var EnableDebugFeatures = false diff --git a/logging/logging.go b/logging/logging.go index ea2ba14ec..246b4060b 100644 --- a/logging/logging.go +++ b/logging/logging.go @@ -10,6 +10,7 @@ import ( "time" rotatelogs "github.com/lestrrat-go/file-rotatelogs" + "github.com/owncast/owncast/utils" "github.com/rifflock/lfshook" "github.com/sirupsen/logrus" logger "github.com/sirupsen/logrus" @@ -28,6 +29,11 @@ var _level logrus.Level // Setup configures our custom logging destinations. func Setup(enableDebugOptions bool, enableVerboseLogging bool) { + // Create the logging directory if needed + if !utils.DoesFileExists(getLogFilePath()) { + os.Mkdir(getLogFilePath(), 0700) + } + // Write logs to a file path := getLogFilePath() writer, _ := rotatelogs.New(