summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
Diffstat (limited to 'commands')
-rw-r--r--commands/hugo.go5
-rw-r--r--commands/server.go20
2 files changed, 17 insertions, 8 deletions
diff --git a/commands/hugo.go b/commands/hugo.go
index ada1e1cef..8dfd4b4bd 100644
--- a/commands/hugo.go
+++ b/commands/hugo.go
@@ -736,10 +736,7 @@ func (c *commandeer) buildSites(noBuildLock bool) (err error) {
func (c *commandeer) handleBuildErr(err error, msg string) {
c.buildErr = err
-
- c.logger.Errorln(msg + ":\n")
- c.logger.Errorln(helpers.FirstUpper(err.Error()))
-
+ c.logger.Errorln(msg + ": " + cleanErrorLog(err.Error()))
}
func (c *commandeer) rebuildSites(events []fsnotify.Event) error {
diff --git a/commands/server.go b/commands/server.go
index 27b12cb32..036fa9eaa 100644
--- a/commands/server.go
+++ b/commands/server.go
@@ -469,14 +469,26 @@ func (f *fileServer) createEndpoint(i int) (*http.ServeMux, net.Listener, string
return mu, listener, u.String(), endpoint, nil
}
-var logErrorRe = regexp.MustCompile(`(?s)ERROR \d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2} `)
+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 ".*?"`)
+ logDuplicateTemplateParseRe = regexp.MustCompile(`: template: .*?:\d+:\d*`)
+)
func removeErrorPrefixFromLog(content string) string {
return logErrorRe.ReplaceAllLiteralString(content, "")
}
+
+var logReplacer = strings.NewReplacer(
+ "can't", "can’t", // Chroma lexer does'nt do well with "can't"
+ "*hugolib.pageState", "page.Page", // Page is the public interface.
+)
+
func cleanErrorLog(content string) string {
- content = strings.ReplaceAll(content, "Rebuild failed:\n", "")
- content = strings.ReplaceAll(content, "\n", "")
+ content = strings.ReplaceAll(content, "\n", " ")
+ content = logReplacer.Replace(content)
+ content = logDuplicateTemplateExecuteRe.ReplaceAllString(content, "")
+ content = logDuplicateTemplateParseRe.ReplaceAllString(content, "")
seen := make(map[string]bool)
parts := strings.Split(content, ": ")
keep := make([]string, 0, len(parts))
@@ -515,7 +527,7 @@ func (c *commandeer) serve(s *serverCmd) error {
c: c,
s: s,
errorTemplate: func(ctx any) (io.Reader, error) {
- templ, found := c.hugo().Tmpl().Lookup("server/error.html")
+ templ, found := c.hugo().Tmpl().Lookup("_server/error.html")
if !found {
panic("template server/error.html not found")
}