feat: console help, examples and named loggers (SummerCMS v0.4.0)

Every command gets long help and examples, descriptions in imperative
sentence case, and a warn-only TestCommandsDocumented over bonfire.CheckDocs.
The plugin logs through a diary component logger instead of the process
default logger. Requires SummerCMS v0.4.0; command names and flags unchanged.
This commit is contained in:
Jakub Zych
2026-10-21 17:35:43 +02:00
parent 46898c2c75
commit 96c790df39
10 changed files with 191 additions and 17 deletions

7
classes/logger.go Normal file
View File

@@ -0,0 +1,7 @@
package classes
import "git.golem15.com/golem15/summercms/modules/diary"
// pluginLog is the plugin's logger: its records carry component=sitemap, so
// config/log.yaml can raise or lower them (log.components.sitemap).
var pluginLog = diary.For("sitemap")

View File

@@ -4,7 +4,6 @@ import (
"bytes"
"encoding/json"
"io"
"log/slog"
"os"
"strings"
"time"
@@ -33,7 +32,7 @@ func LoadManifest(path string) Manifest {
return nil
}
if info.Size() > ManifestMaxBytes {
slog.Default().Warn("golem15.sitemap: updates manifest is too large; lastmod omitted", "path", path, "max_bytes", ManifestMaxBytes)
pluginLog.Warn("golem15.sitemap: updates manifest is too large; lastmod omitted", "path", path, "max_bytes", ManifestMaxBytes)
return nil
}
f, err := os.Open(path)
@@ -48,7 +47,7 @@ func LoadManifest(path string) Manifest {
raw = bytes.TrimSpace(raw)
var decoded map[string]any
if len(raw) == 0 || raw[0] != '{' || json.Unmarshal(raw, &decoded) != nil {
slog.Default().Warn("golem15.sitemap: updates manifest is not a JSON object; lastmod omitted", "path", path)
pluginLog.Warn("golem15.sitemap: updates manifest is not a JSON object; lastmod omitted", "path", path)
return nil
}
m := Manifest{}