+ app, config: add symlink support, allow to specify absolute path in log_file
This commit is contained in:
parent
f857ed74ec
commit
70c56f7a18
6
app.go
6
app.go
|
@ -288,7 +288,11 @@ func configureLogger(args options) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logFilePath := filepath.Join(config.ourWorkingDir, ls.LogFile)
|
logFilePath := filepath.Join(config.ourWorkingDir, ls.LogFile)
|
||||||
file, err := os.OpenFile(logFilePath, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0755)
|
if filepath.IsAbs(ls.LogFile) {
|
||||||
|
logFilePath = ls.LogFile
|
||||||
|
}
|
||||||
|
|
||||||
|
file, err := os.OpenFile(logFilePath, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("cannot create a log file: %s", err)
|
log.Fatalf("cannot create a log file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
10
config.go
10
config.go
|
@ -137,9 +137,15 @@ var config = configuration{
|
||||||
|
|
||||||
// getConfigFilename returns path to the current config file
|
// getConfigFilename returns path to the current config file
|
||||||
func (c *configuration) getConfigFilename() string {
|
func (c *configuration) getConfigFilename() string {
|
||||||
configFile := config.ourConfigFilename
|
configFile, err := filepath.EvalSymlinks(config.ourConfigFilename)
|
||||||
|
if err != nil {
|
||||||
|
if !os.IsNotExist(err) {
|
||||||
|
log.Error("unexpected error while config file path evaluation: %s", err)
|
||||||
|
}
|
||||||
|
configFile = config.ourConfigFilename
|
||||||
|
}
|
||||||
if !filepath.IsAbs(configFile) {
|
if !filepath.IsAbs(configFile) {
|
||||||
configFile = filepath.Join(config.ourWorkingDir, config.ourConfigFilename)
|
configFile = filepath.Join(config.ourWorkingDir, configFile)
|
||||||
}
|
}
|
||||||
return configFile
|
return configFile
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue