Replace the old log setup, with structured logging etc.

Fixes #11124
This commit is contained in:
Bjørn Erik Pedersen
2023-06-16 08:17:42 +02:00
parent 0e79446586
commit 7c9fada778
80 changed files with 1273 additions and 1082 deletions

View File

@@ -13,7 +13,7 @@ import (
"sync"
"testing"
jww "github.com/spf13/jwalterweatherman"
"github.com/bep/logg"
qt "github.com/frankban/quicktest"
"github.com/fsnotify/fsnotify"
@@ -292,11 +292,9 @@ func (s *IntegrationTestBuilder) initBuilder() error {
}
if s.Cfg.LogLevel == 0 {
s.Cfg.LogLevel = jww.LevelWarn
s.Cfg.LogLevel = logg.LevelWarn
}
logger := loggers.NewBasicLoggerForWriter(s.Cfg.LogLevel, &s.logBuff)
isBinaryRe := regexp.MustCompile(`^(.*)(\.png|\.jpg)$`)
const dataSourceFilenamePrefix = "sourcefilename:"
@@ -350,7 +348,7 @@ func (s *IntegrationTestBuilder) initBuilder() error {
Flags: flags,
ConfigDir: configDir,
Fs: afs,
Logger: logger,
Logger: loggers.NewDefault(),
Environ: s.Cfg.Environ,
},
)
@@ -364,7 +362,7 @@ func (s *IntegrationTestBuilder) initBuilder() error {
s.Assert(err, qt.IsNil)
depsCfg := deps.DepsCfg{Configs: res, Fs: fs, Logger: logger}
depsCfg := deps.DepsCfg{Configs: res, Fs: fs, LogLevel: s.Cfg.LogLevel, LogOut: &s.logBuff}
sites, err := NewHugoSites(depsCfg)
if err != nil {
initErr = err
@@ -528,7 +526,7 @@ type IntegrationTestConfig struct {
// Will print the log buffer after the build
Verbose bool
LogLevel jww.Threshold
LogLevel logg.Level
// Whether it needs the real file system (e.g. for js.Build tests).
NeedsOsFS bool