diff options
author | Alan Pearce | 2024-05-19 15:42:36 +0200 |
---|---|---|
committer | Alan Pearce | 2024-05-19 15:53:32 +0200 |
commit | 09ee2de72936ea0b0edc5d3360ce1c72803a817b (patch) | |
tree | 427a590fba06e58554586aad8995fcb6e7a559f3 /internal/builder/builder.go | |
parent | 4064f933a965f2fb2ce43d3c2d5bd54ccd33978c (diff) | |
download | website-09ee2de72936ea0b0edc5d3360ce1c72803a817b.tar.lz website-09ee2de72936ea0b0edc5d3360ce1c72803a817b.tar.zst website-09ee2de72936ea0b0edc5d3360ce1c72803a817b.zip |
log in logfmt via zap, with nicer console output in dev
Diffstat (limited to 'internal/builder/builder.go')
-rw-r--r-- | internal/builder/builder.go | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/internal/builder/builder.go b/internal/builder/builder.go index cb3b670..a8205a3 100644 --- a/internal/builder/builder.go +++ b/internal/builder/builder.go @@ -3,13 +3,13 @@ package builder import ( "fmt" "io" - "log/slog" "net/url" "os" "path" "slices" "website/internal/config" + "website/internal/log" cp "github.com/otiai10/copy" "github.com/pkg/errors" @@ -27,7 +27,7 @@ func mkdirp(dirs ...string) error { } func outputToFile(output io.Reader, filename ...string) error { - slog.Debug(fmt.Sprintf("outputting file %s", path.Join(filename...))) + log.Debug("outputting file", "filename", path.Join(filename...)) file, err := os.OpenFile(path.Join(filename...), os.O_WRONLY|os.O_CREATE, 0644) if err != nil { return errors.WithMessage(err, "could not open output file") @@ -41,7 +41,7 @@ func outputToFile(output io.Reader, filename ...string) error { } func build(outDir string, config config.Config) error { - slog.Debug(fmt.Sprintf("output directory %s", outDir)) + log.Debug("output", "dir", outDir) privateDir := path.Join(outDir, "private") if err := mkdirp(privateDir); err != nil { return errors.WithMessage(err, "could not create private directory") @@ -62,7 +62,7 @@ func build(outDir string, config config.Config) error { if err := mkdirp(publicDir, "post"); err != nil { return errors.WithMessage(err, "could not create post output directory") } - slog.Debug("reading posts") + log.Debug("reading posts") posts, tags, err := readPosts("content", "post", publicDir) if err != nil { return err @@ -72,7 +72,7 @@ func build(outDir string, config config.Config) error { if err := mkdirp(publicDir, "post", post.Basename); err != nil { return errors.WithMessage(err, "could not create directory for post") } - slog.Debug("rendering post", "post", post.Basename) + log.Debug("rendering post", "post", post.Basename) output, err := renderPost(post, config) if err != nil { return errors.WithMessagef(err, "could not render post %s", post.Input) @@ -85,7 +85,7 @@ func build(outDir string, config config.Config) error { if err := mkdirp(publicDir, "tags"); err != nil { return errors.WithMessage(err, "could not create directory for tags") } - slog.Debug("rendering tags list") + log.Debug("rendering tags list") output, err := renderTags(tags, config, "/tags") if err != nil { return errors.WithMessage(err, "could not render tags") @@ -104,7 +104,7 @@ func build(outDir string, config config.Config) error { if err := mkdirp(publicDir, "tags", tag); err != nil { return errors.WithMessage(err, "could not create directory") } - slog.Debug("rendering tags page", "tag", tag) + log.Debug("rendering tags page", "tag", tag) output, err := renderListPage(tag, config, matchingPosts, "/tags/"+tag) if err != nil { return errors.WithMessage(err, "could not render tag page") @@ -113,7 +113,7 @@ func build(outDir string, config config.Config) error { return err } - slog.Debug("rendering tags feed", "tag", tag) + log.Debug("rendering tags feed", "tag", tag) output, err = renderFeed( fmt.Sprintf("%s - %s", config.Title, tag), config, @@ -128,7 +128,7 @@ func build(outDir string, config config.Config) error { } } - slog.Debug("rendering list page") + log.Debug("rendering list page") listPage, err := renderListPage("", config, posts, "/post") if err != nil { return errors.WithMessage(err, "could not render list page") @@ -137,7 +137,7 @@ func build(outDir string, config config.Config) error { return err } - slog.Debug("rendering feed") + log.Debug("rendering feed") feed, err := renderFeed(config.Title, config, posts, "feed") if err != nil { return errors.WithMessage(err, "could not render feed") @@ -146,7 +146,7 @@ func build(outDir string, config config.Config) error { return err } - slog.Debug("rendering feed styles") + log.Debug("rendering feed styles") feedStyles, err := renderFeedStyles() if err != nil { return errors.WithMessage(err, "could not render feed styles") @@ -155,7 +155,7 @@ func build(outDir string, config config.Config) error { return err } - slog.Debug("rendering homepage") + log.Debug("rendering homepage") homePage, err := renderHomepage(config, posts, "/") if err != nil { return errors.WithMessage(err, "could not render homepage") @@ -164,7 +164,7 @@ func build(outDir string, config config.Config) error { return err } - slog.Debug("rendering 404 page") + log.Debug("rendering 404 page") notFound, err := render404(config, "/404.html") if err != nil { return errors.WithMessage(err, "could not render 404 page") |