mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
1773d71d5b
commit
50cc7fe545
3 changed files with 6 additions and 6 deletions
|
@ -14,14 +14,14 @@ workson: []
|
||||||
hugoversion:
|
hugoversion:
|
||||||
relatedfuncs: [printf]
|
relatedfuncs: [printf]
|
||||||
deprecated: false
|
deprecated: false
|
||||||
aliases: []
|
aliases: [/functions/errorf]
|
||||||
---
|
---
|
||||||
|
|
||||||
`errorf` or `warnf` will evaluate a format string, then output the result to the ERROR or WARNING log (and only once per error message to avoid flooding the log).
|
`errorf` or `warnf` will evaluate a format string, then output the result to the ERROR or WARNING log (and only once per error message to avoid flooding the log).
|
||||||
|
|
||||||
Any ERROR will also cause the build to fail (the `hugo` command will `exit -1`).
|
Any ERROR will also cause the build to fail (the `hugo` command will `exit -1`).
|
||||||
|
|
||||||
Note that the WARNING will only be printed to the console.
|
Both functions return an empty string, so the messages are only printed to the console.
|
||||||
|
|
||||||
```
|
```
|
||||||
{{ errorf "Failed to handle page %q" .Path }}
|
{{ errorf "Failed to handle page %q" .Path }}
|
||||||
|
|
|
@ -51,11 +51,11 @@ func (ns *Namespace) Println(a ...interface{}) string {
|
||||||
return _fmt.Sprintln(a...)
|
return _fmt.Sprintln(a...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Errorf formats according to a format specifier and returns the string as a
|
// Errorf formats according to a format specifier and logs an ERROR.
|
||||||
// value that satisfies error.
|
// It returns an empty string.
|
||||||
func (ns *Namespace) Errorf(format string, a ...interface{}) string {
|
func (ns *Namespace) Errorf(format string, a ...interface{}) string {
|
||||||
ns.errorLogger.Printf(format, a...)
|
ns.errorLogger.Printf(format, a...)
|
||||||
return _fmt.Sprintf(format, a...)
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warnf formats according to a format specifier and logs a WARNING.
|
// Warnf formats according to a format specifier and logs a WARNING.
|
||||||
|
|
|
@ -53,7 +53,7 @@ func init() {
|
||||||
ns.AddMethodMapping(ctx.Errorf,
|
ns.AddMethodMapping(ctx.Errorf,
|
||||||
[]string{"errorf"},
|
[]string{"errorf"},
|
||||||
[][2]string{
|
[][2]string{
|
||||||
{`{{ errorf "%s." "failed" }}`, `failed.`},
|
{`{{ errorf "%s." "failed" }}`, ``},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue