feat(blogo): add process steps on logs

This commit is contained in:
Guz
2025-01-10 11:36:40 -03:00
parent 983373a220
commit a9d3aa0203
2 changed files with 12 additions and 8 deletions

View File

@@ -72,7 +72,7 @@ func (b *Blogo) Use(p Plugin) {
}
func (b *Blogo) ServeHTTP(w http.ResponseWriter, r *http.Request) {
log := b.log.With(slog.String("path", r.URL.Path))
log := b.log.With(slog.String("step", "SERVE"), slog.String("path", r.URL.Path))
log.Debug("Serving endpoint")
@@ -134,14 +134,15 @@ func (b *Blogo) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
func (b *Blogo) Init() error {
b.log.Debug("Initializing blogo")
log := b.log.With(slog.String("step", "INITIALIZATION"))
log.Debug("Initializing blogo")
if len(b.sources) == 0 {
b.log.Debug("No SourcerPlugin found, using default one")
log.Debug("No SourcerPlugin found, using default one")
b.Use(&defaultSourcer{})
}
if len(b.renderers) == 0 {
b.log.Debug("No RendererPlugin found, using default one")
log.Debug("No RendererPlugin found, using default one")
b.Use(&defaultRenderer{})
}

View File

@@ -16,6 +16,7 @@
package blogo
import (
"errors"
"io"
"io/fs"
)
@@ -24,12 +25,14 @@ type Plugin interface {
Name() string
}
type SourcerPlugin interface {
Plugin
Source() (fs.FS, error)
}
var ErrRendererNotSupportedFile = errors.New("this file is not supported by renderer")
type RendererPlugin interface {
Plugin
Render(src fs.File, out io.Writer) error
}
type SourcerPlugin interface {
Plugin
Source() (fs.FS, error)
}