diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2019-03-08 15:08:36 +0100 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2019-04-08 22:10:51 +0200 |
commit | 2d3f1be6a495143d7e82f6396a49dfff6cabc3e4 (patch) | |
tree | ab29026f4252f68fe40864eae6c8d064db975061 /lib/xdsconfig/config.go | |
parent | e84a0fe4302e6dc56add83890e9629066fef97c3 (diff) |
Fix logfile setting
Logic to set logs file is:
- default 'stdout' (logfile option default value)
- else use file (or filepath) set by --logfile option
- else use LogsDir field of config file
Change-Id: I980e095d97cb06774fd03921ccae6e176af91984
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'lib/xdsconfig/config.go')
-rw-r--r-- | lib/xdsconfig/config.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/xdsconfig/config.go b/lib/xdsconfig/config.go index ef94f0a..16390ae 100644 --- a/lib/xdsconfig/config.go +++ b/lib/xdsconfig/config.go @@ -112,11 +112,18 @@ func Init(ctx *cli.Context, log *logrus.Logger) (*Config, error) { // Handle where Logs are redirected: // default 'stdout' (logfile option default value) // else use file (or filepath) set by --logfile option - // that may be overwritten by LogsDir field of config file + // else use LogsDir field of config file logF := c.Options.LogFile logD := c.FileConf.LogsDir if logF != "stdout" { - if logD != "" { + if logF != "" { + if common.IsDir(logF) { + logD = logF + logF = filepath.Join(logF, "xds-agent.log") + } else { + logD = filepath.Dir(logF) + } + } else if logD != "" { lf := filepath.Base(logF) if lf == "" || lf == "." { lf = "xds-agent.log" |