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:
7
classes/logger.go
Normal file
7
classes/logger.go
Normal 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")
|
||||
@@ -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{}
|
||||
|
||||
Reference in New Issue
Block a user