diff options
author | bogem <albertnigma@gmail.com> | 2017-02-20 13:53:11 +0500 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-02-21 15:08:45 +0100 |
commit | 7934db91694128f2b036e0b98a076fc679bf8d67 (patch) | |
tree | 836e5c61509e3c63248208bf89c86b7a31b868cd /commands | |
parent | 9e52477d94f56364fbdfa1a70692429eb05d7242 (diff) |
commands: Cache logFile in createLogger
Diffstat (limited to 'commands')
-rw-r--r-- | commands/hugo.go | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/commands/hugo.go b/commands/hugo.go index cfadd2262..65a3a9556 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -398,22 +398,21 @@ func InitializeConfig(subCmdVs ...*cobra.Command) (*deps.DepsCfg, error) { func createLogger(cfg config.Provider) (*jww.Notepad, error) { var ( logHandle = ioutil.Discard + logThreshold = jww.LevelWarn + logFile = cfg.GetString("logFile") outHandle = os.Stdout stdoutThreshold = jww.LevelError - logThreshold = jww.LevelWarn ) - if verboseLog || logging || (cfg.GetString("logFile") != "") { - + if verboseLog || logging || (logFile != "") { var err error - if cfg.GetString("logFile") != "" { - path := cfg.GetString("logFile") - logHandle, err = os.OpenFile(path, os.O_RDWR|os.O_APPEND|os.O_CREATE, 0666) + if logFile != "" { + logHandle, err = os.OpenFile(logFile, os.O_RDWR|os.O_APPEND|os.O_CREATE, 0666) if err != nil { - return nil, newSystemError("Failed to open log file:", path, err) + return nil, newSystemError("Failed to open log file:", logFile, err) } } else { - logHandle, err = ioutil.TempFile(os.TempDir(), "hugo") + logHandle, err = ioutil.TempFile("", "hugo") if err != nil { return nil, newSystemError(err) } |