Skip to content

common/loggers: Write PrintTimerIfDelayed output to stdErr #13171

@jmooring

Description

@jmooring

In #13138 we made all logging (info, warn, error) log to stderr and let stdout be reserved for program output.

When you run hugo against a project that includes a module that has not been downloaded yet, this is written to stdout:

hugo: collected modules in 962 ms

If you run the command hugo list all before the module has been downloaded, the resulting CSV data is invalid.

If seems like the message above should be logged to stdErr instead.

defer c.logger.PrintTimerIfDelayed(time.Now(), "hugo: collected modules")

// PrintTimerIfDelayed prints a time statement to the FEEDBACK logger
// if considerable time is spent.
func (l *logAdapter) PrintTimerIfDelayed(start time.Time, name string) {
elapsed := time.Since(start)
milli := int(1000 * elapsed.Seconds())
if milli < 500 {
return
}
l.Printf("%s in %v ms", name, milli)
}

Can we replace the last line in the above with this?

fmt.Fprintf(l.stdErr, "%s in %v ms", name, milli)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions