Skip to content

Commit

Permalink
Print working directory and absolute path of configuration file for b…
Browse files Browse the repository at this point in the history
…etter debugging
  • Loading branch information
stefanwichmann committed Jul 13, 2018
1 parent fd046c3 commit 3ad81ed
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func InitializeConfiguration(configurationFile string, enableWebInterface bool)
if err != nil {
return configuration, err
}
log.Printf("⚙ Configuration %v loaded", configuration.ConfigurationFile)
log.Printf("⚙ Configuration %v/%v loaded", getWorkingDirectory(), configuration.ConfigurationFile)
} else {
// write default config to disk
configuration.initializeDefaults()
Expand Down Expand Up @@ -165,7 +165,7 @@ func (configuration *Configuration) Write() error {
log.Debugf("⚙ Configuration hasn't changed. Omitting write.")
return nil
}
log.Debugf("⚙ Configuration changed. Saving...")
log.Debugf("⚙ Configuration changed. Saving to %v/%v", getWorkingDirectory(), configuration.ConfigurationFile)
json, err := json.MarshalIndent(configuration, "", " ")
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions kelvin.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func main() {
flag.Parse()
configureLogging()
log.Printf("Kelvin %v starting up... 🚀", applicationVersion)
log.Debugf("Current working directory: %v", getWorkingDirectory())
go CheckForUpdate(applicationVersion, *forceUpdate)
go validateSystemTime()
go handleSIGHUP()
Expand Down
9 changes: 9 additions & 0 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import "os/exec"
import "os"
import "fmt"
import "math"
import "path/filepath"

func containsString(slice []string, element string) bool {
for _, current := range slice {
Expand Down Expand Up @@ -102,3 +103,11 @@ func Restart() {
cmd.Start()
os.Exit(0)
}

func getWorkingDirectory() string {
ex, err := os.Executable()
if err != nil {
return ""
}
return filepath.Dir(ex)
}

0 comments on commit 3ad81ed

Please sign in to comment.