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. A failed settings import is reported once (bonfire.Reported).
This commit is contained in:
@@ -123,7 +123,7 @@ func Submit(app *backpack.App) http.HandlerFunc {
|
||||
var bucket *blob.Bucket
|
||||
if shot != nil {
|
||||
if bucket, ok = app.Lookup[*blob.Bucket](); !ok || bucket == nil {
|
||||
slog.Default().Error("golem15.feedback: upload bucket is not configured")
|
||||
pluginLog.Error("golem15.feedback: upload bucket is not configured")
|
||||
writeOpaque500(w)
|
||||
return
|
||||
}
|
||||
@@ -137,7 +137,7 @@ func Submit(app *backpack.App) http.HandlerFunc {
|
||||
ConsoleLog: inputString(input, "console_log"),
|
||||
}
|
||||
if err := classes.StoreSubmission(ctx, app, gdb, bucket, sub, shot); err != nil {
|
||||
slog.Default().Error("golem15.feedback: storing a submission failed", slog.Any("error", err))
|
||||
pluginLog.Error("golem15.feedback: storing a submission failed", slog.Any("error", err))
|
||||
writeOpaque500(w)
|
||||
return
|
||||
}
|
||||
|
||||
7
controllers/api/logger.go
Normal file
7
controllers/api/logger.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package api
|
||||
|
||||
import "git.golem15.com/golem15/summercms/modules/diary"
|
||||
|
||||
// pluginLog is the plugin's logger: its records carry component=feedback, so
|
||||
// config/log.yaml can raise or lower them (log.components.feedback).
|
||||
var pluginLog = diary.For("feedback")
|
||||
Reference in New Issue
Block a user