mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-16 20:53:59 +02:00
@@ -441,7 +441,7 @@ func (r *rootCommand) createLogger(running bool) (loggers.Logger, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
optsLogger := loggers.Options{
|
optsLogger := loggers.Options{
|
||||||
Distinct: true,
|
DistinctLevel: logg.LevelWarn,
|
||||||
Level: level,
|
Level: level,
|
||||||
Stdout: r.Out,
|
Stdout: r.Out,
|
||||||
Stderr: r.Out,
|
Stderr: r.Out,
|
||||||
|
@@ -40,7 +40,7 @@ type Options struct {
|
|||||||
Level logg.Level
|
Level logg.Level
|
||||||
Stdout io.Writer
|
Stdout io.Writer
|
||||||
Stderr io.Writer
|
Stderr io.Writer
|
||||||
Distinct bool
|
DistinctLevel logg.Level
|
||||||
StoreErrors bool
|
StoreErrors bool
|
||||||
HandlerPost func(e *logg.Entry) error
|
HandlerPost func(e *logg.Entry) error
|
||||||
SuppressStatements map[string]bool
|
SuppressStatements map[string]bool
|
||||||
@@ -92,8 +92,8 @@ func New(opts Options) Logger {
|
|||||||
logHandler = multi.New(handlers...)
|
logHandler = multi.New(handlers...)
|
||||||
|
|
||||||
var logOnce *logOnceHandler
|
var logOnce *logOnceHandler
|
||||||
if opts.Distinct {
|
if opts.DistinctLevel != 0 {
|
||||||
logOnce = newLogOnceHandler(logg.LevelWarn)
|
logOnce = newLogOnceHandler(opts.DistinctLevel)
|
||||||
logHandler = newStopHandler(logOnce, logHandler)
|
logHandler = newStopHandler(logOnce, logHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ func New(opts Options) Logger {
|
|||||||
// NewDefault creates a new logger with the default options.
|
// NewDefault creates a new logger with the default options.
|
||||||
func NewDefault() Logger {
|
func NewDefault() Logger {
|
||||||
opts := Options{
|
opts := Options{
|
||||||
Distinct: true,
|
DistinctLevel: logg.LevelWarn,
|
||||||
Level: logg.LevelWarn,
|
Level: logg.LevelWarn,
|
||||||
Stdout: os.Stdout,
|
Stdout: os.Stdout,
|
||||||
Stderr: os.Stdout,
|
Stderr: os.Stdout,
|
||||||
|
@@ -29,7 +29,7 @@ func TestLogDistinct(t *testing.T) {
|
|||||||
c := qt.New(t)
|
c := qt.New(t)
|
||||||
|
|
||||||
opts := loggers.Options{
|
opts := loggers.Options{
|
||||||
Distinct: true,
|
DistinctLevel: logg.LevelWarn,
|
||||||
StoreErrors: true,
|
StoreErrors: true,
|
||||||
Stdout: io.Discard,
|
Stdout: io.Discard,
|
||||||
Stderr: io.Discard,
|
Stderr: io.Discard,
|
||||||
@@ -85,7 +85,6 @@ func TestOptionStoreErrors(t *testing.T) {
|
|||||||
|
|
||||||
c.Assert(sb.String(), qt.Contains, "error 1")
|
c.Assert(sb.String(), qt.Contains, "error 1")
|
||||||
c.Assert(sb.String(), qt.Contains, "ERROR")
|
c.Assert(sb.String(), qt.Contains, "ERROR")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLogCount(t *testing.T) {
|
func TestLogCount(t *testing.T) {
|
||||||
@@ -124,7 +123,6 @@ func TestSuppressStatements(t *testing.T) {
|
|||||||
c.Assert(errorsStr, qt.Not(qt.Contains), "error 1")
|
c.Assert(errorsStr, qt.Not(qt.Contains), "error 1")
|
||||||
c.Assert(errorsStr, qt.Contains, "error 2")
|
c.Assert(errorsStr, qt.Contains, "error 2")
|
||||||
c.Assert(l.LoggCount(logg.LevelError), qt.Equals, 1)
|
c.Assert(l.LoggCount(logg.LevelError), qt.Equals, 1)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestReset(t *testing.T) {
|
func TestReset(t *testing.T) {
|
||||||
@@ -132,7 +130,7 @@ func TestReset(t *testing.T) {
|
|||||||
|
|
||||||
opts := loggers.Options{
|
opts := loggers.Options{
|
||||||
StoreErrors: true,
|
StoreErrors: true,
|
||||||
Distinct: true,
|
DistinctLevel: logg.LevelWarn,
|
||||||
Stdout: io.Discard,
|
Stdout: io.Discard,
|
||||||
Stderr: io.Discard,
|
Stderr: io.Discard,
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,7 @@ func InitGlobalLogger(level logg.Level, panicOnWarnings bool) {
|
|||||||
log = New(
|
log = New(
|
||||||
Options{
|
Options{
|
||||||
Level: level,
|
Level: level,
|
||||||
Distinct: true,
|
DistinctLevel: logg.LevelInfo,
|
||||||
HandlerPost: logHookLast,
|
HandlerPost: logHookLast,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@@ -397,7 +397,7 @@ func (s *IntegrationTestBuilder) initBuilder() error {
|
|||||||
Stdout: w,
|
Stdout: w,
|
||||||
Stderr: w,
|
Stderr: w,
|
||||||
Level: s.Cfg.LogLevel,
|
Level: s.Cfg.LogLevel,
|
||||||
Distinct: true,
|
DistinctLevel: logg.LevelWarn,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -117,7 +117,7 @@ func NewHugoSites(cfg deps.DepsCfg) (*HugoSites, error) {
|
|||||||
|
|
||||||
logOpts := loggers.Options{
|
logOpts := loggers.Options{
|
||||||
Level: cfg.LogLevel,
|
Level: cfg.LogLevel,
|
||||||
Distinct: true, // This will drop duplicate log warning and errors.
|
DistinctLevel: logg.LevelWarn, // This will drop duplicate log warning and errors.
|
||||||
HandlerPost: logHookLast,
|
HandlerPost: logHookLast,
|
||||||
Stdout: cfg.LogOut,
|
Stdout: cfg.LogOut,
|
||||||
Stderr: cfg.LogOut,
|
Stderr: cfg.LogOut,
|
||||||
|
Reference in New Issue
Block a user