From 5968aa49d2e414351e7fdb61bbdedd47b3329ec2 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Sun, 11 Jul 2021 17:08:51 -0700 Subject: [PATCH] Fix initial creation of logging directory --- logging/logging.go | 8 +++++--- main.go | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/logging/logging.go b/logging/logging.go index a49db0b8b..3cf0dad97 100644 --- a/logging/logging.go +++ b/logging/logging.go @@ -6,6 +6,7 @@ package logging import ( "math" "os" + "path/filepath" "sync" "time" @@ -29,9 +30,10 @@ var Logger *OCLogger // Setup configures our custom logging destinations. func Setup(enableDebugOptions bool, enableVerboseLogging bool) { // Create the logging directory if needed - if !utils.DoesFileExists(getLogFilePath()) { - if err := os.Mkdir(getLogFilePath(), 0700); err != nil { - logger.Errorln("unable to create directory", getLogFilePath(), err) + loggingDirectory := filepath.Dir(getLogFilePath()) + if !utils.DoesFileExists(loggingDirectory) { + if err := os.Mkdir(loggingDirectory, 0700); err != nil { + logger.Errorln("unable to create logs directory", loggingDirectory, err) } } diff --git a/main.go b/main.go index 1ef788a82..b9dcc5bcb 100644 --- a/main.go +++ b/main.go @@ -38,7 +38,6 @@ func main() { config.LogDirectory = *logDirectory } - configureLogging(*enableDebugOptions, *enableVerboseLogging) log.Infoln(config.GetReleaseString()) if *backupDirectory != "" { @@ -52,6 +51,8 @@ func main() { } } + configureLogging(*enableDebugOptions, *enableVerboseLogging) + // Allows a user to restore a specific database backup if *restoreDatabaseFile != "" { databaseFile := config.DatabaseFilePath