Skip to content

Commit

Permalink
commands, helpers, vendor: Update to the latest jww logger
Browse files Browse the repository at this point in the history
Updates #2701
  • Loading branch information
bep committed Jan 3, 2017
1 parent 2ac9817 commit c344b19
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
20 changes: 16 additions & 4 deletions commands/hugo.go
Expand Up @@ -17,6 +17,7 @@ package commands

import (
"fmt"
"io/ioutil"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -332,16 +333,27 @@ func InitializeConfig(subCmdVs ...*cobra.Command) error {
viper.Set("cacheDir", helpers.GetTempDir("hugo_cache", hugofs.Source()))
}

logFile := ioutil.Discard

if verboseLog || logging || (viper.IsSet("logFile") && viper.GetString("logFile") != "") {

var err error
if viper.IsSet("logFile") && viper.GetString("logFile") != "" {
jww.SetLogFile(viper.GetString("logFile"))
path := viper.GetString("logFile")
logFile, err = os.OpenFile(path, os.O_RDWR|os.O_APPEND|os.O_CREATE, 0666)
if err != nil {
return newSystemError("Failed to open log file:", path, err)
}
} else {
jww.UseTempLogFile("hugo")
logFile, err = ioutil.TempFile(os.TempDir(), "hugo")
if err != nil {
return newSystemError(err)
}
}
} else {
jww.DiscardLogging()
}

jww.SetLogOutput(logFile)

if quiet {
jww.SetStdoutThreshold(jww.LevelError)
} else if viper.GetBool("verbose") {
Expand Down
2 changes: 1 addition & 1 deletion helpers/general.go
Expand Up @@ -252,7 +252,7 @@ func NewDistinctErrorLogger() *DistinctLogger {
// NewDistinctFeedbackLogger creates a new DistinctLogger that can be used
// to give feedback to the user while not spamming with duplicates.
func NewDistinctFeedbackLogger() *DistinctLogger {
return &DistinctLogger{m: make(map[string]bool), logger: &jww.FEEDBACK}
return &DistinctLogger{m: make(map[string]bool), logger: jww.FEEDBACK}
}

var (
Expand Down
6 changes: 3 additions & 3 deletions vendor/vendor.json
Expand Up @@ -281,10 +281,10 @@
"revisionTime": "2016-11-30T04:45:28Z"
},
{
"checksumSHA1": "dkruahfhuLXXuyeCuRpsWlcRK+8=",
"checksumSHA1": "7NGKyJZL8VItCxYkEJxNh8l9O18=",
"path": "github.com/spf13/jwalterweatherman",
"revision": "33c24e77fb80341fe7130ee7c594256ff08ccc46",
"revisionTime": "2016-03-01T12:00:06Z"
"revision": "14fe3f27973f14e5d1bb8bb16f6153cc67b30652",
"revisionTime": "2017-01-03T11:13:15Z"
},
{
"checksumSHA1": "zLJY+lsX1e5OO6gRxQd5RfKgdQY=",
Expand Down

0 comments on commit c344b19

Please sign in to comment.