summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cache/filecache/integration_test.go5
-rw-r--r--commands/commandeer.go58
-rw-r--r--commands/deploy.go2
-rw-r--r--commands/hugobuilder.go27
-rw-r--r--commands/import.go11
-rw-r--r--commands/server.go19
-rw-r--r--commands/xcommand_template.go79
-rw-r--r--common/loggers/handlerdefault.go106
-rw-r--r--common/loggers/handlersmisc.go158
-rw-r--r--common/loggers/handlerterminal.go90
-rw-r--r--common/loggers/ignorableLogger.go63
-rw-r--r--common/loggers/logger.go303
-rw-r--r--common/loggers/logger_test.go156
-rw-r--r--common/loggers/loggerglobal.go53
-rw-r--r--common/loggers/loggers.go355
-rw-r--r--common/loggers/loggers_test.go60
-rw-r--r--config/allconfig/allconfig.go3
-rw-r--r--config/allconfig/load.go5
-rw-r--r--config/commonConfig.go8
-rw-r--r--config/commonConfig_test.go4
-rw-r--r--deploy/deploy.go81
-rw-r--r--deploy/deploy_test.go13
-rw-r--r--deps/deps.go32
-rw-r--r--go.mod6
-rw-r--r--go.sum12
-rw-r--r--helpers/general.go149
-rw-r--r--helpers/general_test.go56
-rw-r--r--helpers/testhelpers_test.go4
-rw-r--r--hugofs/nosymlink_fs.go1
-rw-r--r--hugofs/nosymlink_test.go8
-rw-r--r--hugofs/walk.go2
-rw-r--r--hugolib/alias.go1
-rw-r--r--hugolib/alias_test.go5
-rw-r--r--hugolib/config_test.go3
-rw-r--r--hugolib/filesystems/basefs.go4
-rw-r--r--hugolib/hugo_modules_test.go10
-rw-r--r--hugolib/hugo_sites.go6
-rw-r--r--hugolib/hugo_sites_build.go34
-rw-r--r--hugolib/hugo_sites_build_test.go2
-rw-r--r--hugolib/integrationtest_builder.go12
-rw-r--r--hugolib/mount_filters_test.go3
-rw-r--r--hugolib/page__new.go2
-rw-r--r--hugolib/page_test.go8
-rw-r--r--hugolib/pagebundler_test.go10
-rw-r--r--hugolib/pages_capture.go2
-rw-r--r--hugolib/pages_capture_test.go2
-rw-r--r--hugolib/renderstring_test.go5
-rw-r--r--hugolib/resource_chain_test.go2
-rw-r--r--hugolib/site.go23
-rw-r--r--hugolib/site_new.go37
-rw-r--r--hugolib/site_render.go2
-rw-r--r--hugolib/testhelpers_test.go4
-rw-r--r--langs/i18n/i18n.go5
-rw-r--r--langs/i18n/i18n_test.go7
-rw-r--r--markup/asciidocext/convert_test.go18
-rw-r--r--markup/goldmark/convert_test.go4
-rw-r--r--markup/goldmark/toc_test.go9
-rw-r--r--markup/org/convert.go3
-rw-r--r--markup/org/convert_test.go2
-rw-r--r--markup/pandoc/convert_test.go2
-rw-r--r--markup/rst/convert_test.go2
-rw-r--r--modules/client.go5
-rw-r--r--parser/metadecoders/decoder.go6
-rw-r--r--resources/page/pagemeta/page_frontmatter.go4
-rw-r--r--resources/page/testhelpers_page_test.go2
-rw-r--r--resources/resource_spec.go4
-rw-r--r--resources/resource_transformers/babel/babel.go6
-rw-r--r--resources/resource_transformers/babel/integration_test.go5
-rw-r--r--resources/resource_transformers/postcss/integration_test.go17
-rw-r--r--resources/resource_transformers/postcss/postcss.go11
-rw-r--r--resources/resource_transformers/postcss/postcss_test.go6
-rw-r--r--resources/resource_transformers/tocss/dartsass/client.go10
-rw-r--r--resources/resource_transformers/tocss/dartsass/integration_test.go34
-rw-r--r--tpl/collections/collections.go3
-rw-r--r--tpl/data/data.go5
-rw-r--r--tpl/data/data_test.go11
-rw-r--r--tpl/data/resources_test.go6
-rw-r--r--tpl/fmt/fmt.go51
-rw-r--r--transform/livereloadinject/livereloadinject.go5
-rw-r--r--transform/metainject/hugogenerator.go6
80 files changed, 1273 insertions, 1082 deletions
diff --git a/cache/filecache/integration_test.go b/cache/filecache/integration_test.go
index a59ea048d..a8a45988e 100644
--- a/cache/filecache/integration_test.go
+++ b/cache/filecache/integration_test.go
@@ -16,11 +16,10 @@ package filecache_test
import (
"path/filepath"
- jww "github.com/spf13/jwalterweatherman"
-
"testing"
"time"
+ "github.com/bep/logg"
qt "github.com/frankban/quicktest"
"github.com/gohugoio/hugo/htesting"
"github.com/gohugoio/hugo/hugolib"
@@ -80,7 +79,7 @@ iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAA
`
b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{T: t, TxtarString: files, Running: true, RunGC: true, NeedsOsFS: true, LogLevel: jww.LevelInfo},
+ hugolib.IntegrationTestConfig{T: t, TxtarString: files, Running: true, RunGC: true, NeedsOsFS: true, LogLevel: logg.LevelInfo},
).Build()
b.Assert(b.GCCount, qt.Equals, 0)
diff --git a/commands/commandeer.go b/commands/commandeer.go
index f7b711973..7322a210a 100644
--- a/commands/commandeer.go
+++ b/commands/commandeer.go
@@ -28,12 +28,11 @@ import (
"syscall"
"time"
- jww "github.com/spf13/jwalterweatherman"
-
"go.uber.org/automaxprocs/maxprocs"
"github.com/bep/clock"
"github.com/bep/lazycache"
+ "github.com/bep/logg"
"github.com/bep/overlayfs"
"github.com/bep/simplecobra"
@@ -114,7 +113,6 @@ type rootCommand struct {
baseURL string
gc bool
poll string
- panicOnWarning bool
forceSyncStatic bool
printPathWarnings bool
printUnusedTemplates bool
@@ -308,7 +306,7 @@ func (r *rootCommand) ConfigFromProvider(key int32, cfg config.Provider) (*commo
func (r *rootCommand) HugFromConfig(conf *commonConfig) (*hugolib.HugoSites, error) {
h, _, err := r.hugoSites.GetOrCreate(r.configVersionID.Load(), func(key int32) (*hugolib.HugoSites, error) {
- depsCfg := deps.DepsCfg{Configs: conf.configs, Fs: conf.fs, Logger: r.logger}
+ depsCfg := deps.DepsCfg{Configs: conf.configs, Fs: conf.fs, LogOut: r.logger.Out(), LogLevel: r.logger.Level()}
return hugolib.NewHugoSites(depsCfg)
})
return h, err
@@ -320,7 +318,7 @@ func (r *rootCommand) Hugo(cfg config.Provider) (*hugolib.HugoSites, error) {
if err != nil {
return nil, err
}
- depsCfg := deps.DepsCfg{Configs: conf.configs, Fs: conf.fs, Logger: r.logger}
+ depsCfg := deps.DepsCfg{Configs: conf.configs, Fs: conf.fs, LogOut: r.logger.Out(), LogLevel: r.logger.Level()}
return hugolib.NewHugoSites(depsCfg)
})
return h, err
@@ -410,7 +408,6 @@ func (r *rootCommand) PreRun(cd, runner *simplecobra.Commandeer) error {
return err
}
- loggers.PanicOnWarning.Store(r.panicOnWarning)
r.commonConfigs = lazycache.New[int32, *commonConfig](lazycache.Options{MaxEntries: 5})
r.hugoSites = lazycache.New[int32, *hugolib.HugoSites](lazycache.Options{MaxEntries: 5})
@@ -418,43 +415,48 @@ func (r *rootCommand) PreRun(cd, runner *simplecobra.Commandeer) error {
}
func (r *rootCommand) createLogger(running bool) (loggers.Logger, error) {
- var (
- outHandle = r.Out
- stdoutThreshold = jww.LevelWarn
- )
-
- if r.verbose {
- helpers.Deprecated("--verbose", "use --logLevel info", false)
- stdoutThreshold = jww.LevelInfo
- }
-
- if r.debug {
- helpers.Deprecated("--debug", "use --logLevel debug", false)
- stdoutThreshold = jww.LevelDebug
- }
+ level := logg.LevelWarn
if r.logLevel != "" {
switch strings.ToLower(r.logLevel) {
case "debug":
- stdoutThreshold = jww.LevelDebug
+ level = logg.LevelDebug
case "info":
- stdoutThreshold = jww.LevelInfo
+ level = logg.LevelInfo
case "warn", "warning":
- stdoutThreshold = jww.LevelWarn
+ level = logg.LevelWarn
case "error":
- stdoutThreshold = jww.LevelError
+ level = logg.LevelError
default:
return nil, fmt.Errorf("invalid log level: %q, must be one of debug, warn, info or error", r.logLevel)
}
+ } else {
+ if r.verbose {
+ helpers.Deprecated("--verbose", "use --logLevel info", false)
+ level = logg.LevelInfo
+ }
+
+ if r.debug {
+ helpers.Deprecated("--debug", "use --logLevel debug", false)
+ level = logg.LevelDebug
+ }
}
- loggers.InitGlobalLogger(stdoutThreshold, jww.LevelWarn, outHandle, io.Discard)
- helpers.InitLoggers()
- return loggers.NewLogger(stdoutThreshold, jww.LevelWarn, outHandle, io.Discard, running), nil
+ optsLogger := loggers.Options{
+ Distinct: true,
+ Level: level,
+ Stdout: r.Out,
+ Stderr: r.Out,
+ StoreErrors: running,
+ }
+
+ return loggers.New(optsLogger), nil
+
}
func (r *rootCommand) Reset() {
r.logger.Reset()
+ loggers.Log().Reset()
}
// IsTestRun reports whether the command is running as a test.
@@ -530,7 +532,7 @@ func applyLocalFlagsBuild(cmd *cobra.Command, r *rootCommand) {
cmd.Flags().StringP("layoutDir", "l", "", "filesystem path to layout directory")
cmd.Flags().BoolVar(&r.gc, "gc", false, "enable to run some cleanup tasks (remove unused cache files) after the build")
cmd.Flags().StringVar(&r.poll, "poll", "", "set this to a poll interval, e.g --poll 700ms, to use a poll based approach to watch for file system changes")
- cmd.Flags().BoolVar(&r.panicOnWarning, "panicOnWarning", false, "panic on first WARNING log")
+ cmd.Flags().Bool("panicOnWarning", false, "panic on first WARNING log")
cmd.Flags().Bool("templateMetrics", false, "display metrics about template executions")
cmd.Flags().Bool("templateMetricsHints", false, "calculate some improvement hints when combined with --templateMetrics")
cmd.Flags().BoolVar(&r.forceSyncStatic, "forceSyncStatic", false, "copy all files when static is changed.")
diff --git a/commands/deploy.go b/commands/deploy.go
index 8dae4bd88..82127adf4 100644
--- a/commands/deploy.go
+++ b/commands/deploy.go
@@ -52,7 +52,7 @@ documentation.
if err != nil {
return err
}
- deployer, err := deploy.New(h.Configs.GetFirstLanguageConfig(), h.PathSpec.PublishFs)
+ deployer, err := deploy.New(h.Configs.GetFirstLanguageConfig(), h.Log, h.PathSpec.PublishFs)
if err != nil {
return err
}
diff --git a/commands/hugobuilder.go b/commands/hugobuilder.go
index 95dbb1ca8..60e558c70 100644
--- a/commands/hugobuilder.go
+++ b/commands/hugobuilder.go
@@ -26,11 +26,13 @@ import (
"sync"
"time"
+ "github.com/bep/logg"
"github.com/bep/simplecobra"
"github.com/fsnotify/fsnotify"
"github.com/gohugoio/hugo/common/herrors"
"github.com/gohugoio/hugo/common/htime"
"github.com/gohugoio/hugo/common/hugo"
+ "github.com/gohugoio/hugo/common/loggers"
"github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/common/terminal"
"github.com/gohugoio/hugo/common/types"
@@ -68,7 +70,6 @@ type hugoBuilder struct {
onConfigLoaded func(reloaded bool) error
fastRenderMode bool
- buildWatch bool
showErrorInBrowser bool
errState hugoBuilderErrState
@@ -131,7 +132,7 @@ func (e *hugoBuilderErrState) wasErr() bool {
}
func (c *hugoBuilder) errCount() int {
- return int(c.r.logger.LogCounters().ErrorCounter.Count())
+ return c.r.logger.LoggCount(logg.LevelError) + loggers.Log().LoggCount(logg.LevelError)
}
// getDirList provides NewWatcher() with a list of directories to watch for changes.
@@ -363,7 +364,7 @@ func (c *hugoBuilder) newWatcher(pollIntervalStr string, dirList ...string) (*wa
configFiles = conf.configs.LoadingInfo.ConfigFiles
})
- c.r.logger.Println("Watching for config changes in", strings.Join(configFiles, ", "))
+ c.r.Println("Watching for config changes in", strings.Join(configFiles, ", "))
for _, configFile := range configFiles {
watcher.Add(configFile)
configSet[configFile] = true
@@ -461,6 +462,7 @@ func (c *hugoBuilder) copyStatic() (map[string]uint64, error) {
}
func (c *hugoBuilder) copyStaticTo(sourceFs *filesystems.SourceFilesystem) (uint64, error) {
+ infol := c.r.logger.InfoCommand("copy static")
publishDir := helpers.FilePathSeparator
if sourceFs.PublishFolder != "" {
@@ -484,13 +486,13 @@ func (c *hugoBuilder) copyStaticTo(sourceFs *filesystems.SourceFilesystem) (uint
syncer.SrcFs = fs
if syncer.Delete {
- c.r.logger.Infoln("removing all files from destination that don't exist in static dirs")
+ infol.Logf("removing all files from destination that don't exist in static dirs")
syncer.DeleteFilter = func(f os.FileInfo) bool {
return f.IsDir() && strings.HasPrefix(f.Name(), ".")
}
}
- c.r.logger.Infoln("syncing static files to", publishDir)
+ infol.Logf("syncing static files to %s", publishDir)
// because we are using a baseFs (to get the union right).
// set sync src to root
@@ -545,14 +547,13 @@ func (c *hugoBuilder) fullBuild(noBuildLock bool) error {
langCount map[string]uint64
)
- if !c.r.quiet {
- fmt.Println("Start building sites … ")
- fmt.Println(hugo.BuildVersionString())
- if terminal.IsTerminal(os.Stdout) {
- defer func() {
- fmt.Print(showCursor + clearLine)
- }()
- }
+ c.r.logger.Println("Start building sites … ")
+ c.r.logger.Println(hugo.BuildVersionString())
+ c.r.logger.Println()
+ if terminal.IsTerminal(os.Stdout) {
+ defer func() {
+ fmt.Print(showCursor + clearLine)
+ }()
}
copyStaticFunc := func() error {
diff --git a/commands/import.go b/commands/import.go
index 30ada15f8..f2c56a9a1 100644
--- a/commands/import.go
+++ b/commands/import.go
@@ -19,12 +19,11 @@ import (
"errors"
"fmt"
"io"
+ "log"
"os"
"path/filepath"
"regexp"
- jww "github.com/spf13/jwalterweatherman"
-
"strconv"
"strings"
"time"
@@ -299,7 +298,7 @@ func (c *importCommand) convertJekyllMetaData(m any, postName string, postDate t
}
func (c *importCommand) convertJekyllPost(path, relPath, targetDir string, draft bool) error {
- jww.TRACE.Println("Converting", path)
+ log.Println("Converting", path)
filename := filepath.Base(path)
postDate, postName, err := c.parseJekyllFilename(filename)
@@ -308,7 +307,7 @@ func (c *importCommand) convertJekyllPost(path, relPath, targetDir string, draft
return nil
}
- jww.TRACE.Println(filename, postDate, postName)
+ log.Println(filename, postDate, postName)
targetFile := filepath.Join(targetDir, relPath)
targetParentDir := filepath.Dir(targetFile)
@@ -367,7 +366,7 @@ func (c *importCommand) copyJekyllFilesAndFolders(jekyllRoot, dest string, jekyl
if _, ok := jekyllPostDirs[entry.Name()]; !ok {
err = hugio.CopyDir(fs, sfp, dfp, nil)
if err != nil {
- jww.ERROR.Println(err)
+ c.r.logger.Errorln(err)
}
}
}
@@ -388,7 +387,7 @@ func (c *importCommand) copyJekyllFilesAndFolders(jekyllRoot, dest string, jekyl
if !isExcept && entry.Name()[0] != '.' && entry.Name()[0] != '_' {
err = hugio.CopyFile(fs, sfp, dfp)
if err != nil {
- jww.ERROR.Println(err)
+ c.r.logger.Errorln(err)
}
}
}
diff --git a/commands/server.go b/commands/server.go
index 80036618c..7e6ec5b13 100644
--- a/commands/server.go
+++ b/commands/server.go
@@ -67,7 +67,6 @@ import (
)
var (
- logErrorRe = regexp.MustCompile(`(?s)ERROR \d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2} `)
logDuplicateTemplateExecuteRe = regexp.MustCompile(`: template: .*?:\d+:\d+: executing ".*?"`)