From 2d3f1be6a495143d7e82f6396a49dfff6cabc3e4 Mon Sep 17 00:00:00 2001 From: Sebastien Douheret Date: Fri, 8 Mar 2019 15:08:36 +0100 Subject: [PATCH] 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 --- lib/xdsconfig/config.go | 11 +++++++++-- 1 file 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" -- 2.16.6