diff --git a/commands/commandeer.go b/commands/commandeer.go
index c55806980e4..679342f9bbc 100644
--- a/commands/commandeer.go
+++ b/commands/commandeer.go
@@ -14,6 +14,9 @@
package commands
import (
+ "errors"
+ "fmt"
+
"os"
"path/filepath"
"regexp"
@@ -21,15 +24,17 @@ import (
"sync"
"time"
+ "github.com/gohugoio/hugo/livereload"
+
"github.com/gohugoio/hugo/config"
"github.com/spf13/cobra"
- "github.com/spf13/afero"
-
"github.com/gohugoio/hugo/hugolib"
+ "github.com/spf13/afero"
"github.com/bep/debounce"
+ "github.com/gohugoio/hugo/common/loggers"
"github.com/gohugoio/hugo/common/types"
"github.com/gohugoio/hugo/deps"
"github.com/gohugoio/hugo/helpers"
@@ -72,6 +77,78 @@ type commandeer struct {
configured bool
paused bool
+
+ errorHandler *errorHandler
+}
+
+type errorHandler struct {
+ logger *loggers.Logger
+ sync.RWMutex
+ err *buildError
+}
+
+type buildError struct {
+ logger *loggers.Logger
+ What string
+ Err error
+}
+
+func (b buildError) log() {
+ b.logger.ERROR.Println(b.Error())
+}
+
+func (b buildError) Error() string {
+ return fmt.Sprintf("%s: %s", b.What, b.Err)
+}
+
+func (c *commandeer) getError() *buildError {
+ h := c.errorHandler
+ h.RLock()
+ defer h.RUnlock()
+ return h.err
+}
+
+func (c *commandeer) getErrorWithContext() interface{} {
+ h := c.errorHandler
+ h.RLock()
+ defer h.RUnlock()
+ if h.err == nil && h.logger.ErrorCounter.Count() == 0 {
+ return nil
+ }
+ m := make(map[string]interface{})
+
+ var err error
+
+ if h.logger.ErrorCounter.Count() > 0 {
+ err = &buildError{What: "Error(s) in log", Err: errors.New(h.logger.Errors.String())}
+ } else {
+ err = h.err
+ }
+
+ m["Error"] = err
+ m["Version"] = hugoVersionString()
+
+ return m
+}
+
+func (c *commandeer) handleError(what string, err error) error {
+ h := c.errorHandler
+ h.Lock()
+ defer h.Unlock()
+
+ if err == nil {
+ h.err = nil
+ return nil
+ }
+
+ h.err = &buildError{logger: h.logger, What: what, Err: err}
+ h.err.log()
+
+ // TODO(bep) server error config
+ // Need to refresh the browser to show the error page.
+ livereload.ForceRefresh()
+
+ return h.err
}
func (c *commandeer) Set(key string, value interface{}) {
@@ -244,11 +321,13 @@ func (c *commandeer) loadConfig(mustHaveConfigFile, running bool) error {
}
}
- logger, err := c.createLogger(config)
+ logger, err := c.createLogger(config, running)
if err != nil {
return err
}
+ c.errorHandler = &errorHandler{logger: logger}
+
cfg.Logger = logger
createMemFs := config.GetBool("renderToMemory")
diff --git a/commands/commands.go b/commands/commands.go
index 54eb03b5b9a..8670d498303 100644
--- a/commands/commands.go
+++ b/commands/commands.go
@@ -14,12 +14,10 @@
package commands
import (
- "os"
-
+ "github.com/gohugoio/hugo/common/loggers"
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/helpers"
"github.com/spf13/cobra"
- jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/nitro"
)
@@ -242,7 +240,7 @@ func (cc *hugoBuilderCommon) handleFlags(cmd *cobra.Command) {
_ = cmd.Flags().SetAnnotation("theme", cobra.BashCompSubdirsInDir, []string{"themes"})
}
-func checkErr(logger *jww.Notepad, err error, s ...string) {
+func checkErr(logger *loggers.Logger, err error, s ...string) {
if err == nil {
return
}
@@ -255,25 +253,3 @@ func checkErr(logger *jww.Notepad, err error, s ...string) {
}
logger.ERROR.Println(err)
}
-
-func stopOnErr(logger *jww.Notepad, err error, s ...string) {
- if err == nil {
- return
- }
-
- defer os.Exit(-1)
-
- if len(s) == 0 {
- newMessage := err.Error()
- // Printing an empty string results in a error with
- // no message, no bueno.
- if newMessage != "" {
- logger.CRITICAL.Println(newMessage)
- }
- }
- for _, message := range s {
- if message != "" {
- logger.CRITICAL.Println(message)
- }
- }
-}
diff --git a/commands/hugo.go b/commands/hugo.go
index 2e7353d5152..94193582891 100644
--- a/commands/hugo.go
+++ b/commands/hugo.go
@@ -21,13 +21,16 @@ import (
"os/signal"
"sort"
"sync/atomic"
+
+ "github.com/gohugoio/hugo/common/loggers"
+
"syscall"
"github.com/gohugoio/hugo/hugolib/filesystems"
+ "github.com/pkg/errors"
"golang.org/x/sync/errgroup"
- "log"
"os"
"path/filepath"
"runtime"
@@ -85,7 +88,7 @@ func Execute(args []string) Response {
}
if err == nil {
- errCount := int(jww.LogCountForLevelsGreaterThanorEqualTo(jww.LevelError))
+ errCount := int(loggers.GlobalErrorCounter.Count())
if errCount > 0 {
err = fmt.Errorf("logged %d errors", errCount)
} else if resp.Result != nil {
@@ -118,7 +121,7 @@ func initializeConfig(mustHaveConfigFile, running bool,
}
-func (c *commandeer) createLogger(cfg config.Provider) (*jww.Notepad, error) {
+func (c *commandeer) createLogger(cfg config.Provider, running bool) (*loggers.Logger, error) {
var (
logHandle = ioutil.Discard
logThreshold = jww.LevelWarn
@@ -161,7 +164,7 @@ func (c *commandeer) createLogger(cfg config.Provider) (*jww.Notepad, error) {
jww.SetStdoutThreshold(stdoutThreshold)
helpers.InitLoggers()
- return jww.NewNotepad(stdoutThreshold, logThreshold, outHandle, logHandle, "", log.Ldate|log.Ltime), nil
+ return loggers.NewLogger(stdoutThreshold, logThreshold, outHandle, logHandle, running), nil
}
func initializeFlags(cmd *cobra.Command, cfg config.Provider) {
@@ -637,7 +640,7 @@ func (c *commandeer) fullRebuild() {
c.commandeerHugoState = &commandeerHugoState{}
err := c.loadConfig(true, true)
if err != nil {
- jww.ERROR.Println("Failed to reload config:", err)
+ c.handleError("Failed to reload config", errors.WithStack(err))
// Set the processing on pause until the state is recovered.
c.paused = true
} else {
@@ -645,9 +648,9 @@ func (c *commandeer) fullRebuild() {
}
if !c.paused {
- if err := c.buildSites(); err != nil {
- jww.ERROR.Println(err)
- } else if !c.h.buildWatch && !c.Cfg.GetBool("disableLiveReload") {
+ err := c.buildSites()
+ c.handleError("Build failed", errors.WithStack(err))
+ if err == nil && !c.h.buildWatch && !c.Cfg.GetBool("disableLiveReload") {
livereload.ForceRefresh()
}
}
@@ -839,11 +842,12 @@ func (c *commandeer) newWatcher(dirList ...string) (*watcher.Batcher, error) {
c.Logger.FEEDBACK.Printf("Syncing all static files\n")
_, err := c.copyStatic()
if err != nil {
- stopOnErr(c.Logger, err, "Error copying static files to publish dir")
+ c.handleError("Error copying static files to publish dir", errors.WithStack(err))
+ break
}
} else {
if err := staticSyncer.syncsStaticEvents(staticEvents); err != nil {
- c.Logger.ERROR.Println(err)
+ c.handleError("Error syncing static files to publish dir", errors.WithStack(err))
continue
}
}
@@ -917,7 +921,7 @@ func (c *commandeer) newWatcher(dirList ...string) (*watcher.Batcher, error) {
}
case err := <-watcher.Errors:
if err != nil {
- c.Logger.ERROR.Println(err)
+ c.handleError("Error while watching", errors.WithStack(err))
}
}
}
diff --git a/commands/server.go b/commands/server.go
index 27999fa6c2a..a50c615ad2f 100644
--- a/commands/server.go
+++ b/commands/server.go
@@ -29,6 +29,7 @@ import (
"time"
"github.com/gohugoio/hugo/livereload"
+ "github.com/gohugoio/hugo/tpl"
"github.com/gohugoio/hugo/config"
@@ -271,10 +272,11 @@ func (sc *serverCmd) server(cmd *cobra.Command, args []string) error {
}
type fileServer struct {
- baseURLs []string
- roots []string
- c *commandeer
- s *serverCmd
+ baseURLs []string
+ roots []string
+ errorTemplate tpl.Template
+ c *commandeer
+ s *serverCmd
}
func (f *fileServer) createEndpoint(i int) (*http.ServeMux, string, string, error) {
@@ -316,6 +318,16 @@ func (f *fileServer) createEndpoint(i int) (*http.ServeMux, string, string, erro
decorate := func(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+
+ // First check the error state
+ err := f.c.getErrorWithContext()
+ if err != nil {
+ errTemplate := defaultBuildErrorTemplate
+ w.WriteHeader(errTemplate.statusCode) // TODO(bep) error server improve
+ f.errorTemplate.Execute(w, err)
+ return
+ }
+
if f.s.noHTTPCache {
w.Header().Set("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0")
w.Header().Set("Pragma", "no-cache")
@@ -365,11 +377,17 @@ func (c *commandeer) serve(s *serverCmd) error {
roots = []string{""}
}
+ templ, err := c.hugo.TextTmpl.Parse("__server_error", defaultBuildErrorTemplate.templ)
+ if err != nil {
+ return err
+ }
+
srv := &fileServer{
- baseURLs: baseURLs,
- roots: roots,
- c: c,
- s: s,
+ baseURLs: baseURLs,
+ roots: roots,
+ c: c,
+ s: s,
+ errorTemplate: templ,
}
doLiveReload := !c.Cfg.GetBool("disableLiveReload")
diff --git a/commands/server_errors.go b/commands/server_errors.go
new file mode 100644
index 00000000000..83a3e2d8b43
--- /dev/null
+++ b/commands/server_errors.go
@@ -0,0 +1,94 @@
+// Copyright 2018 The Hugo Authors. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package commands
+
+import (
+ "html/template"
+ "io"
+)
+
+type errorTemplate struct {
+ // To text template to produce a nice looking error page in the browser.
+ templ string
+
+ // The default HTTP status code shown for this error.
+ statusCode int
+}
+
+var defaultBuildErrorTemplate = errorTemplate{
+ templ: `
+
+
+
+ Hugo Server: Error
+
+
+
+
+ {{ .Error.What }}
+ {{ highlight .Error.Err "bash" "noclasses=true,style=github" }}
+ {{ .Version }}
+ Reload Page
+
+
+
+`,
+ statusCode: 500,
+}
+
+func (templ errorTemplate) buildErrorPage(data interface{}, w io.Writer) error {
+ t, err := template.New("").Parse(templ.templ)
+ if err != nil {
+ return err
+ }
+
+ return t.Execute(w, data)
+}
diff --git a/commands/version.go b/commands/version.go
index ea4e4c926c0..b85f53725fe 100644
--- a/commands/version.go
+++ b/commands/version.go
@@ -14,14 +14,16 @@
package commands
import (
+ "fmt"
"runtime"
"strings"
+ jww "github.com/spf13/jwalterweatherman"
+
"github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/hugolib"
"github.com/gohugoio/hugo/resource/tocss/scss"
"github.com/spf13/cobra"
- jww "github.com/spf13/jwalterweatherman"
)
var _ cmder = (*versionCmd)(nil)
@@ -45,6 +47,10 @@ func newVersionCmd() *versionCmd {
}
func printHugoVersion() {
+ jww.FEEDBACK.Println(hugoVersionString())
+}
+
+func hugoVersionString() string {
program := "Hugo Static Site Generator"
version := "v" + helpers.CurrentHugoVersion.String()
@@ -64,5 +70,6 @@ func printHugoVersion() {
buildDate = "unknown"
}
- jww.FEEDBACK.Println(program, version, osArch, "BuildDate:", buildDate)
+ return fmt.Sprintf("%s %s %s BuildDate: %s", program, version, osArch, buildDate)
+
}
diff --git a/common/loggers/loggers.go b/common/loggers/loggers.go
index 2f7f36b3440..0356b55c16c 100644
--- a/common/loggers/loggers.go
+++ b/common/loggers/loggers.go
@@ -14,6 +14,8 @@
package loggers
import (
+ "bytes"
+ "io"
"io/ioutil"
"log"
"os"
@@ -21,17 +23,76 @@ import (
jww "github.com/spf13/jwalterweatherman"
)
+// Counts ERROR logs to the global jww logger.
+var GlobalErrorCounter *jww.Counter
+
+func init() {
+ GlobalErrorCounter = &jww.Counter{}
+ jww.SetLogListeners(jww.LogCounter(GlobalErrorCounter, jww.LevelError))
+}
+
+// Logger wraps a *loggers.Logger and some other related logging state.
+type Logger struct {
+ *jww.Notepad
+ ErrorCounter *jww.Counter
+
+ // This is only set in server mode.
+ Errors *bytes.Buffer
+}
+
+// Reset resets the logger's internal state.
+func (l *Logger) Reset() {
+ l.ErrorCounter.Reset()
+ if l.Errors != nil {
+ l.Errors.Reset()
+ }
+}
+
+// NewLogger creates a new Logger for the given thresholds
+func NewLogger(stdoutThreshold, logThreshold jww.Threshold, outHandle, logHandle io.Writer, saveErrors bool) *Logger {
+ return newLogger(stdoutThreshold, logThreshold, outHandle, logHandle, saveErrors)
+}
+
// NewDebugLogger is a convenience function to create a debug logger.
-func NewDebugLogger() *jww.Notepad {
- return jww.NewNotepad(jww.LevelDebug, jww.LevelError, os.Stdout, ioutil.Discard, "", log.Ldate|log.Ltime)
+func NewDebugLogger() *Logger {
+ return newBasicLogger(jww.LevelDebug)
}
// NewWarningLogger is a convenience function to create a warning logger.
-func NewWarningLogger() *jww.Notepad {
- return jww.NewNotepad(jww.LevelWarn, jww.LevelError, os.Stdout, ioutil.Discard, "", log.Ldate|log.Ltime)
+func NewWarningLogger() *Logger {
+ return newBasicLogger(jww.LevelWarn)
}
// NewErrorLogger is a convenience function to create an error logger.
-func NewErrorLogger() *jww.Notepad {
- return jww.NewNotepad(jww.LevelError, jww.LevelError, os.Stdout, ioutil.Discard, "", log.Ldate|log.Ltime)
+func NewErrorLogger() *Logger {
+ return newBasicLogger(jww.LevelError)
+}
+
+func newLogger(stdoutThreshold, logThreshold jww.Threshold, outHandle, logHandle io.Writer, saveErrors bool) *Logger {
+ errorCounter := &jww.Counter{}
+ listeners := []jww.LogListener{jww.LogCounter(errorCounter, jww.LevelError)}
+ var errorBuff *bytes.Buffer
+ if saveErrors {
+ errorBuff = new(bytes.Buffer)
+ errorCapture := func(t jww.Threshold) io.Writer {
+ if t != jww.LevelError {
+ // Only interested in ERROR
+ return nil
+ }
+
+ return errorBuff
+ }
+
+ listeners = append(listeners, errorCapture)
+ }
+
+ return &Logger{
+ Notepad: jww.NewNotepad(stdoutThreshold, logThreshold, outHandle, logHandle, "", log.Ldate|log.Ltime, listeners...),
+ ErrorCounter: errorCounter,
+ Errors: errorBuff,
+ }
+}
+
+func newBasicLogger(t jww.Threshold) *Logger {
+ return newLogger(t, jww.LevelError, os.Stdout, ioutil.Discard, false)
}
diff --git a/deps/deps.go b/deps/deps.go
index 2b66a153f4b..f5ec4f83934 100644
--- a/deps/deps.go
+++ b/deps/deps.go
@@ -16,7 +16,6 @@ import (
"github.com/gohugoio/hugo/resource"
"github.com/gohugoio/hugo/source"
"github.com/gohugoio/hugo/tpl"
- jww "github.com/spf13/jwalterweatherman"
)
// Deps holds dependencies used by many.
@@ -25,7 +24,7 @@ import (
type Deps struct {
// The logger to use.
- Log *jww.Notepad `json:"-"`
+ Log *loggers.Logger `json:"-"`
// Used to log errors that may repeat itself many times.
DistinctErrorLog *helpers.DistinctLogger
@@ -256,7 +255,7 @@ func (d Deps) ForLanguage(cfg DepsCfg) (*Deps, error) {
type DepsCfg struct {
// The Logger to use.
- Logger *jww.Notepad
+ Logger *loggers.Logger
// The file systems to use
Fs *hugofs.Fs
diff --git a/go.mod b/go.mod
index 62f22531fff..8a320971df8 100644
--- a/go.mod
+++ b/go.mod
@@ -21,8 +21,10 @@ require (
github.com/fortytw2/leaktest v1.2.0
github.com/fsnotify/fsnotify v1.4.7
github.com/gobwas/glob v0.2.3
+ github.com/google/pprof v0.0.0-20181002142953-f36417847b1c // indirect
github.com/gorilla/websocket v1.4.0
github.com/hashicorp/go-immutable-radix v1.0.0
+ github.com/ianlancetaylor/demangle v0.0.0-20180714043527-fcd258a6f0b4 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jdkato/prose v1.1.0
github.com/kr/pretty v0.1.0 // indirect
@@ -38,7 +40,7 @@ require (
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
github.com/nicksnyder/go-i18n v1.10.0
github.com/olekukonko/tablewriter v0.0.0-20180506121414-d4647c9c7a84
- github.com/pmezard/go-difflib v1.0.0 // indirect
+ github.com/pkg/errors v0.8.0
github.com/russross/blackfriday v0.0.0-20180804101149-46c73eb196ba
github.com/sanity-io/litter v1.1.0
github.com/sergi/go-diff v1.0.0 // indirect
@@ -47,7 +49,7 @@ require (
github.com/spf13/cast v1.2.0
github.com/spf13/cobra v0.0.3
github.com/spf13/fsync v0.0.0-20170320142552-12a01e648f05
- github.com/spf13/jwalterweatherman v1.0.0
+ github.com/spf13/jwalterweatherman v1.0.1-0.20181005085228-103a6da826d0
github.com/spf13/nitro v0.0.0-20131003134307-24d7ef30a12d
github.com/spf13/pflag v1.0.2
github.com/spf13/viper v1.2.0
@@ -57,12 +59,16 @@ require (
github.com/tdewolff/test v0.0.0-20171106182207-265427085153 // indirect
github.com/wellington/go-libsass v0.0.0-20180624165032-615eaa47ef79 // indirect
github.com/yosssi/ace v0.0.5
+ go.opencensus.io v0.17.0 // indirect
+ golang.org/x/arch v0.0.0-20180920145803-b19384d3c130 // indirect
+ golang.org/x/crypto v0.0.0-20181001203147-e3636079e1a4 // indirect
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f
golang.org/x/text v0.3.0
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/yaml.v2 v2.2.1
+ grpc.go4.org v0.0.0-20170609214715-11d0a25b4919 // indirect
)
exclude github.com/chaseadamsio/goorgeous v2.0.0+incompatible
diff --git a/go.sum b/go.sum
index 5a71e5d7690..7d53f86c21e 100644
--- a/go.sum
+++ b/go.sum
@@ -1,3 +1,5 @@
+collectd.org v0.3.0 h1:iNBHGw1VvPJxH2B6RiFWFZ+vsjo1lCdRszBeOuwGi00=
+git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69 h1:+tu3HOoMXB7RXEINRVIpxJCT+KdYiI7LAEAUrOw3dIU=
github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69/go.mod h1:L1AbZdiDllfyYH5l5OkAaZtk7VkWe89bPJFmnDBNHxg=
github.com/BurntSushi/toml v0.0.0-20170626110600-a368813c5e64 h1:BuYewlQyh/jroxY8qx41SrzD8Go17GkyCyAeVmprvQI=
@@ -14,6 +16,7 @@ github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VEN
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY=
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
+github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/bep/debounce v1.1.0 h1:6ocXeW2iZ/7vAzgXz82J00tYxncMiEEBExPftTtOQzk=
github.com/bep/debounce v1.1.0/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0=
github.com/bep/gitmap v1.0.0 h1:cTTZwq7vpGuhwefKCBDV9UrHnZAPVJTvoWobimrqkUc=
@@ -40,6 +43,10 @@ github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
+github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
+github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
+github.com/google/pprof v0.0.0-20181002142953-f36417847b1c h1:gIPn6u19B7jF7guvt28xKMpVht1vlhroy/a9mtiKb/o=
+github.com/google/pprof v0.0.0-20181002142953-f36417847b1c/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0=
@@ -50,6 +57,8 @@ github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCO
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
+github.com/ianlancetaylor/demangle v0.0.0-20180714043527-fcd258a6f0b4 h1:eWmTY5/yaZWgZR+HjyGOCXgM++IEwo/KgxxtYhai4LU=
+github.com/ianlancetaylor/demangle v0.0.0-20180714043527-fcd258a6f0b4/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jdkato/prose v1.1.0 h1:LpvmDGwbKGTgdCH3a8VJL56sr7p/wOFPw/R4lM4PfFg=
@@ -71,6 +80,7 @@ github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-runewidth v0.0.3 h1:a+kO+98RDGEfo6asOGMmpodZq4FNtnGP54yps8BzLR4=
github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
+github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/miekg/mmark v1.3.6 h1:t47x5vThdwgLJzofNsbsAl7gmIiJ7kbDQN5BxwBmwvY=
github.com/miekg/mmark v1.3.6/go.mod h1:w7r9mkTvpS55jlfyn22qJ618itLryxXBhA7Jp3FIlkw=
github.com/mitchellh/hashstructure v1.0.0 h1:ZkRJX1CyOoTkar7p/mLS5TZU4nJ1Rn/F8u9dGS02Q3Y=
@@ -85,10 +95,17 @@ github.com/nicksnyder/go-i18n v1.10.0 h1:5AzlPKvXBH4qBzmZ09Ua9Gipyruv6uApMcrNZdo
github.com/nicksnyder/go-i18n v1.10.0/go.mod h1:HrK7VCrbOvQoUAQ7Vpy7i87N7JZZZ7R2xBGjv0j365Q=
github.com/olekukonko/tablewriter v0.0.0-20180506121414-d4647c9c7a84 h1:fiKJgB4JDUd43CApkmCeTSQlWjtTtABrU2qsgbuP0BI=
github.com/olekukonko/tablewriter v0.0.0-20180506121414-d4647c9c7a84/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
+github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8=
github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
+github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
+github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
+github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
+github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
+github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/russross/blackfriday v0.0.0-20180804101149-46c73eb196ba h1:8Vzt8HxRjy7hp1eqPKVoAEPK9npQFW2510qlobGzvi0=
github.com/russross/blackfriday v0.0.0-20180804101149-46c73eb196ba/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/sanity-io/litter v1.1.0 h1:BllcKWa3VbZmOZbDCoszYLk7zCsKHz5Beossi8SUcTc=
@@ -107,6 +124,8 @@ github.com/spf13/fsync v0.0.0-20170320142552-12a01e648f05 h1:pQHm7pxjSgC54M1rtLS
github.com/spf13/fsync v0.0.0-20170320142552-12a01e648f05/go.mod h1:jdsEoy1w+v0NpuwXZEaRAH6ADTDmzfRnE2eVwshwFrM=
github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
+github.com/spf13/jwalterweatherman v1.0.1-0.20181005085228-103a6da826d0 h1:kPJPXmEs6V1YyXfHFbp1NCpdqhvFVssh2FGx7+OoJLM=
+github.com/spf13/jwalterweatherman v1.0.1-0.20181005085228-103a6da826d0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
github.com/spf13/nitro v0.0.0-20131003134307-24d7ef30a12d h1:ihvj2nmx8eqWjlgNgdW6h0DyGJuq5GiwHadJkG0wXtQ=
github.com/spf13/nitro v0.0.0-20131003134307-24d7ef30a12d/go.mod h1:jU8A+8xL+6n1OX4XaZtCj4B3mIa64tULUsD6YegdpFo=
github.com/spf13/pflag v1.0.2 h1:Fy0orTDgHdbnzHcsOgfCN4LtHf0ec3wwtiwJqwvf3Gc=
@@ -125,6 +144,13 @@ github.com/wellington/go-libsass v0.0.0-20180624165032-615eaa47ef79 h1:ivqgxj/zO
github.com/wellington/go-libsass v0.0.0-20180624165032-615eaa47ef79/go.mod h1:mxgxgam0N0E+NAUMHLcu20Ccfc3mVpDkyrLDayqfiTs=
github.com/yosssi/ace v0.0.5 h1:tUkIP/BLdKqrlrPwcmH0shwEEhTRHoGnc1wFIWmaBUA=
github.com/yosssi/ace v0.0.5/go.mod h1:ALfIzm2vT7t5ZE7uoIZqF3TQ7SAOyupFZnkrF5id+K0=
+go.opencensus.io v0.17.0 h1:2Cu88MYg+1LU+WVD+NWwYhyP0kKgRlN9QjWGaX0jKTE=
+go.opencensus.io v0.17.0/go.mod h1:mp1VrMQxhlqqDpKvH4UcQUa4YwlzNmymAjPrDdfxNpI=
+go4.org v0.0.0-20180809161055-417644f6feb5 h1:+hE86LblG4AyDgwMCLTE6FOlM9+qjHSYS+rKqxUVdsM=
+golang.org/x/arch v0.0.0-20180920145803-b19384d3c130 h1:Vsc61gop4hfHdzQNolo6Fi/sw7TnJ2yl3ZR4i7bYirs=
+golang.org/x/arch v0.0.0-20180920145803-b19384d3c130/go.mod h1:cYlCBUl1MsqxdiKgmc4uh7TxZfWSFLOGSRR090WDxt8=
+golang.org/x/crypto v0.0.0-20181001203147-e3636079e1a4 h1:Vk3wNqEZwyGyei9yq5ekj7frek2u7HUfffJ1/opblzc=
+golang.org/x/crypto v0.0.0-20181001203147-e3636079e1a4/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81 h1:00VmoueYNlNz/aHIilyyQz/MHSqGoWJzpFv/HW8xpzI=
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA=
@@ -133,10 +159,17 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6Zh
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180906133057-8cf3aee42992 h1:BH3eQWeGbwRU2+wxxuuPOdFBmaiBH81O8BugSjHeTFg=
golang.org/x/sys v0.0.0-20180906133057-8cf3aee42992/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
+golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs=
+golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
+google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
+google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
+google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+grpc.go4.org v0.0.0-20170609214715-11d0a25b4919 h1:tmXTu+dfa+d9Evp8NpJdgOy6+rt8/x4yG7qPBrtNfLY=
+grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o=
diff --git a/hugolib/alias.go b/hugolib/alias.go
index 73d8acafce7..bcf8f1963ec 100644
--- a/hugolib/alias.go
+++ b/hugolib/alias.go
@@ -22,12 +22,12 @@ import (
"runtime"
"strings"
+ "github.com/gohugoio/hugo/common/loggers"
+
"github.com/gohugoio/hugo/output"
"github.com/gohugoio/hugo/publisher"
"github.com/gohugoio/hugo/tpl"
- jww "github.com/spf13/jwalterweatherman"
-
"github.com/gohugoio/hugo/helpers"
)
@@ -47,11 +47,11 @@ func init() {
type aliasHandler struct {
t tpl.TemplateFinder
- log *jww.Notepad
+ log *loggers.Logger
allowRoot bool
}
-func newAliasHandler(t tpl.TemplateFinder, l *jww.Notepad, allowRoot bool) aliasHandler {
+func newAliasHandler(t tpl.TemplateFinder, l *loggers.Logger, allowRoot bool) aliasHandler {
return aliasHandler{t, l, allowRoot}
}
diff --git a/hugolib/hugo_sites.go b/hugolib/hugo_sites.go
index 3ff31ece36a..f61d522a858 100644
--- a/hugolib/hugo_sites.go
+++ b/hugolib/hugo_sites.go
@@ -21,6 +21,7 @@ import (
"strings"
"sync"
+ "github.com/gohugoio/hugo/common/loggers"
"github.com/gohugoio/hugo/deps"
"github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/langs"
@@ -29,7 +30,6 @@ import (
"github.com/gohugoio/hugo/i18n"
"github.com/gohugoio/hugo/tpl"
"github.com/gohugoio/hugo/tpl/tplimpl"
- jww "github.com/spf13/jwalterweatherman"
)
// HugoSites represents the sites to build. Each site represents a language.
@@ -69,7 +69,7 @@ func (h *HugoSites) NumLogErrors() int {
if h == nil {
return 0
}
- return int(h.Log.LogCountForLevelsGreaterThanorEqualTo(jww.LevelError))
+ return int(h.Log.ErrorCounter.Count())
}
func (h *HugoSites) PrintProcessingStats(w io.Writer) {
@@ -301,7 +301,8 @@ func (h *HugoSites) reset() {
// resetLogs resets the log counters etc. Used to do a new build on the same sites.
func (h *HugoSites) resetLogs() {
- h.Log.ResetLogCounters()
+ h.Log.Reset()
+ loggers.GlobalErrorCounter.Reset()
for _, s := range h.Sites {
s.Deps.DistinctErrorLog = helpers.NewDistinctLogger(h.Log.ERROR)
}
diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go
index 8ca2128a166..5bb328aa286 100644
--- a/hugolib/hugo_sites_build.go
+++ b/hugolib/hugo_sites_build.go
@@ -19,8 +19,6 @@ import (
"errors"
- jww "github.com/spf13/jwalterweatherman"
-
"github.com/fsnotify/fsnotify"
"github.com/gohugoio/hugo/helpers"
)
@@ -79,7 +77,7 @@ func (h *HugoSites) Build(config BuildCfg, events ...fsnotify.Event) error {
h.Log.FEEDBACK.Println()
}
- errorCount := h.Log.LogCountForLevel(jww.LevelError)
+ errorCount := h.Log.ErrorCounter.Count()
if errorCount > 0 {
return fmt.Errorf("logged %d error(s)", errorCount)
}
diff --git a/hugolib/page_bundler_capture.go b/hugolib/page_bundler_capture.go
index fbfad0103a2..ca41df1fe71 100644
--- a/hugolib/page_bundler_capture.go
+++ b/hugolib/page_bundler_capture.go
@@ -20,6 +20,9 @@ import (
"path"
"path/filepath"
"runtime"
+
+ "github.com/gohugoio/hugo/common/loggers"
+
"sort"
"strings"
"sync"
@@ -33,7 +36,6 @@ import (
"golang.org/x/sync/errgroup"
"github.com/gohugoio/hugo/source"
- jww "github.com/spf13/jwalterweatherman"
)
var errSkipCyclicDir = errors.New("skip potential cyclic dir")
@@ -47,7 +49,7 @@ type capturer struct {
sourceSpec *source.SourceSpec
fs afero.Fs
- logger *jww.Notepad
+ logger *loggers.Logger
// Filenames limits the content to process to a list of filenames/directories.
// This is used for partial building in server mode.
@@ -61,7 +63,7 @@ type capturer struct {
}
func newCapturer(
- logger *jww.Notepad,
+ logger *loggers.Logger,
sourceSpec *source.SourceSpec,
handler captureResultHandler,
contentChanges *contentChangeMap,
diff --git a/hugolib/page_bundler_capture_test.go b/hugolib/page_bundler_capture_test.go
index ace96b633ad..d6128352c0a 100644
--- a/hugolib/page_bundler_capture_test.go
+++ b/hugolib/page_bundler_capture_test.go
@@ -22,8 +22,6 @@ import (
"github.com/gohugoio/hugo/common/loggers"
- jww "github.com/spf13/jwalterweatherman"
-
"runtime"
"strings"
"sync"
@@ -100,9 +98,6 @@ func TestPageBundlerCaptureSymlinks(t *testing.T) {
assert.NoError(c.capture())
- // Symlink back to content skipped to prevent infinite recursion.
- assert.Equal(uint64(3), logger.LogCountForLevelsGreaterThanorEqualTo(jww.LevelWarn))
-
expected := `
F:
/base/a/page_s.md
diff --git a/hugolib/pagemeta/page_frontmatter.go b/hugolib/pagemeta/page_frontmatter.go
index c1139bd907c..88f6f3a11e4 100644
--- a/hugolib/pagemeta/page_frontmatter.go
+++ b/hugolib/pagemeta/page_frontmatter.go
@@ -14,17 +14,14 @@
package pagemeta
import (
- "io/ioutil"
- "log"
- "os"
"strings"
"time"
+ "github.com/gohugoio/hugo/common/loggers"
"github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/config"
"github.com/spf13/cast"
- jww "github.com/spf13/jwalterweatherman"
)
// FrontMatterHandler maps front matter into Page fields and .Params.
@@ -40,7 +37,7 @@ type FrontMatterHandler struct {
// A map of all date keys configured, including any custom.
allDateKeys map[string]bool
- logger *jww.Notepad
+ logger *loggers.Logger
}
// FrontMatterDescriptor describes how to handle front matter for a given Page.
@@ -263,10 +260,10 @@ func toLowerSlice(in interface{}) []string {
// NewFrontmatterHandler creates a new FrontMatterHandler with the given logger and configuration.
// If no logger is provided, one will be created.
-func NewFrontmatterHandler(logger *jww.Notepad, cfg config.Provider) (FrontMatterHandler, error) {
+func NewFrontmatterHandler(logger *loggers.Logger, cfg config.Provider) (FrontMatterHandler, error) {
if logger == nil {
- logger = jww.NewNotepad(jww.LevelWarn, jww.LevelWarn, os.Stdout, ioutil.Discard, "", log.Ldate|log.Ltime)
+ logger = loggers.NewWarningLogger()
}
frontMatterConfig, err := newFrontmatterConfig(cfg)
diff --git a/hugolib/shortcode_test.go b/hugolib/shortcode_test.go
index df7b7103f98..0f60f8e5ab7 100644
--- a/hugolib/shortcode_test.go
+++ b/hugolib/shortcode_test.go
@@ -24,8 +24,6 @@ import (
"github.com/spf13/viper"
- jww "github.com/spf13/jwalterweatherman"
-
"github.com/spf13/afero"
"github.com/gohugoio/hugo/output"
@@ -777,7 +775,7 @@ NotFound: {{< thisDoesNotExist >}}
"thisDoesNotExist",
)
- require.Equal(t, uint64(1), s.Log.LogCountForLevel(jww.LevelError))
+ require.Equal(t, uint64(1), s.Log.ErrorCounter.Count())
}
diff --git a/hugolib/testhelpers_test.go b/hugolib/testhelpers_test.go
index 27edf3fdd6b..9afb69badb8 100644
--- a/hugolib/testhelpers_test.go
+++ b/hugolib/testhelpers_test.go
@@ -14,7 +14,6 @@ import (
"github.com/gohugoio/hugo/langs"
"github.com/sanity-io/litter"
- jww "github.com/spf13/jwalterweatherman"
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/deps"
@@ -26,6 +25,7 @@ import (
"os"
+ "github.com/gohugoio/hugo/common/loggers"
"github.com/gohugoio/hugo/hugofs"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -38,7 +38,7 @@ type sitesBuilder struct {
Fs *hugofs.Fs
T testing.TB
- logger *jww.Notepad
+ logger *loggers.Logger
dumper litter.Options
@@ -103,7 +103,7 @@ func (s *sitesBuilder) Running() *sitesBuilder {
return s
}
-func (s *sitesBuilder) WithLogger(logger *jww.Notepad) *sitesBuilder {
+func (s *sitesBuilder) WithLogger(logger *loggers.Logger) *sitesBuilder {
s.logger = logger
return s
}
diff --git a/i18n/i18n.go b/i18n/i18n.go
index 73417fb3240..d436ea58d37 100644
--- a/i18n/i18n.go
+++ b/i18n/i18n.go
@@ -14,6 +14,7 @@
package i18n
import (
+ "github.com/gohugoio/hugo/common/loggers"
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/helpers"
"github.com/nicksnyder/go-i18n/i18n/bundle"
@@ -28,11 +29,11 @@ var (
type Translator struct {
translateFuncs map[string]bundle.TranslateFunc
cfg config.Provider
- logger *jww.Notepad
+ logger *loggers.Logger
}
// NewTranslator creates a new Translator for the given language bundle and configuration.
-func NewTranslator(b *bundle.Bundle, cfg config.Provider, logger *jww.Notepad) Translator {
+func NewTranslator(b *bundle.Bundle, cfg config.Provider, logger *loggers.Logger) Translator {
t := Translator{cfg: cfg, logger: logger, translateFuncs: make(map[string]bundle.TranslateFunc)}
t.initFuncs(b)
return t
diff --git a/i18n/i18n_test.go b/i18n/i18n_test.go
index 5075839ff2f..84b7384d075 100644
--- a/i18n/i18n_test.go
+++ b/i18n/i18n_test.go
@@ -19,24 +19,19 @@ import (
"github.com/gohugoio/hugo/tpl/tplimpl"
+ "github.com/gohugoio/hugo/common/loggers"
"github.com/gohugoio/hugo/langs"
"github.com/spf13/afero"
"github.com/gohugoio/hugo/deps"
- "io/ioutil"
- "os"
-
- "log"
-
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/hugofs"
- jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/viper"
"github.com/stretchr/testify/require"
)
-var logger = jww.NewNotepad(jww.LevelError, jww.LevelError, os.Stdout, ioutil.Discard, "", log.Ldate|log.Ltime)
+var logger = loggers.NewErrorLogger()
type i18nTest struct {
data map[string][]byte
diff --git a/resource/resource.go b/resource/resource.go
index dd9cbbd4179..a18d03aabf3 100644
--- a/resource/resource.go
+++ b/resource/resource.go
@@ -32,8 +32,6 @@ import (
"github.com/gohugoio/hugo/common/hugio"
"github.com/gohugoio/hugo/common/loggers"
- jww "github.com/spf13/jwalterweatherman"
-
"github.com/spf13/afero"
"github.com/gobwas/glob"
@@ -273,7 +271,7 @@ type Spec struct {
MediaTypes media.Types
OutputFormats output.Formats
- Logger *jww.Notepad
+ Logger *loggers.Logger
TextTemplates tpl.TemplateParseFinder
@@ -287,7 +285,7 @@ type Spec struct {
GenAssetsPath string
}
-func NewSpec(s *helpers.PathSpec, logger *jww.Notepad, outputFormats output.Formats, mimeTypes media.Types) (*Spec, error) {
+func NewSpec(s *helpers.PathSpec, logger *loggers.Logger, outputFormats output.Formats, mimeTypes media.Types) (*Spec, error) {
imaging, err := decodeImaging(s.Cfg.GetStringMap("imaging"))
if err != nil {
@@ -542,7 +540,7 @@ type resourceHash struct {
type publishOnce struct {
publisherInit sync.Once
publisherErr error
- logger *jww.Notepad
+ logger *loggers.Logger
}
func (l *publishOnce) publish(s Source) error {
diff --git a/tpl/collections/collections_test.go b/tpl/collections/collections_test.go
index dc8929f39fe..0a5aa5caaf5 100644
--- a/tpl/collections/collections_test.go
+++ b/tpl/collections/collections_test.go
@@ -17,21 +17,18 @@ import (
"errors"
"fmt"
"html/template"
- "io/ioutil"
- "log"
"math/rand"
- "os"
"reflect"
"testing"
"time"
"github.com/gohugoio/hugo/common/collections"
+ "github.com/gohugoio/hugo/common/loggers"
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/deps"
"github.com/gohugoio/hugo/helpers"
"github.com/gohugoio/hugo/hugofs"
"github.com/gohugoio/hugo/langs"
- jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -937,7 +934,7 @@ func newDeps(cfg config.Provider) *deps.Deps {
Cfg: cfg,
Fs: hugofs.NewMem(l),
ContentSpec: cs,
- Log: jww.NewNotepad(jww.LevelError, jww.LevelError, os.Stdout, ioutil.Discard, "", log.Ldate|log.Ltime),
+ Log: loggers.NewErrorLogger(),
}
}
diff --git a/tpl/data/data_test.go b/tpl/data/data_test.go
index 6bee0d52481..9ef969244a9 100644
--- a/tpl/data/data_test.go
+++ b/tpl/data/data_test.go
@@ -113,11 +113,11 @@ func TestGetCSV(t *testing.T) {
require.NoError(t, err, msg)
if _, ok := test.expect.(bool); ok {
- require.Equal(t, 1, int(ns.deps.Log.LogCountForLevelsGreaterThanorEqualTo(jww.LevelError)))
+ require.Equal(t, 1, int(ns.deps.Log.ErrorCounter.Count()))
require.Nil(t, got)
continue
}
- require.Equal(t, 0, int(ns.deps.Log.LogCountForLevelsGreaterThanorEqualTo(jww.LevelError)))
+ require.Equal(t, 0, int(ns.deps.Log.ErrorCounter.Count()))
require.NotNil(t, got, msg)
assert.EqualValues(t, test.expect, got, msg)
@@ -198,14 +198,14 @@ func TestGetJSON(t *testing.T) {
continue
}
- if errLevel, ok := test.expect.(jww.Threshold); ok {
- logCount := ns.deps.Log.LogCountForLevelsGreaterThanorEqualTo(errLevel)
+ if errLevel, ok := test.expect.(jww.Threshold); ok && errLevel >= jww.LevelError {
+ logCount := ns.deps.Log.ErrorCounter.Count()
require.True(t, logCount >= 1, fmt.Sprintf("got log count %d", logCount))
continue
}
require.NoError(t, err, msg)
- require.Equal(t, 0, int(ns.deps.Log.LogCountForLevelsGreaterThanorEqualTo(jww.LevelError)), msg)
+ require.Equal(t, 0, int(ns.deps.Log.ErrorCounter.Count()), msg)
require.NotNil(t, got, msg)
assert.EqualValues(t, test.expect, got, msg)
diff --git a/tpl/tplimpl/template_funcs_test.go b/tpl/tplimpl/template_funcs_test.go
index 8594c67a455..04bb4941a7e 100644
--- a/tpl/tplimpl/template_funcs_test.go
+++ b/tpl/tplimpl/template_funcs_test.go
@@ -21,10 +21,7 @@ import (
"testing"
"time"
- "io/ioutil"
- "log"
- "os"
-
+ "github.com/gohugoio/hugo/common/loggers"
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/deps"
"github.com/gohugoio/hugo/helpers"
@@ -35,13 +32,12 @@ import (
"github.com/gohugoio/hugo/tpl/internal"
"github.com/gohugoio/hugo/tpl/partials"
"github.com/spf13/afero"
- jww "github.com/spf13/jwalterweatherman"
"github.com/spf13/viper"
"github.com/stretchr/testify/require"
)
var (
- logger = jww.NewNotepad(jww.LevelFatal, jww.LevelFatal, os.Stdout, ioutil.Discard, "", log.Ldate|log.Ltime)
+ logger = loggers.NewErrorLogger()
)
func newTestConfig() config.Provider {