siyuan-note/siyuan · error
injectLogger
Error message
injectLogger: %v
What it means
injectLogger registers siyuan.logger (trace/debug/info/warn/error wrappers bound to the kernel logging package) into the plugin's goja runtime. Any Go panic during that registration is recovered and reported as this error, meaning the logger API could not be installed for the plugin.
Solutions
- Inspect the wrapped %v detail and report it upstream with the plugin name
- Update the kernel to the latest version
- Disable other plugins to rule out initialization interference
- Retry loading the plugin to rule out a transient failure
Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
try {
await loadPlugin(p);
} catch (e) {
if (String(e.message).startsWith('injectLogger:')) {
console.error('Logger API failed to install:', e.message);
}
} Prevention
- Keep the kernel updated; bootstrap injection panics are kernel-internal
- Feature-check siyuan.logger before use in plugin code
- Include the full wrapped error text in bug reports
When it happens
Trigger: A panic inside rt.NewObject(), logger.Set(...) calls, or loggerWrapper binding failures while bootstrapping the plugin runtime.
Common situations: Kernel-side defects during plugin bootstrap; seen when loading a plugin whose runtime setup fails before any plugin JS executes.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/708553bdec98d8cd.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/plugin/api_logger.go:56
}
func (p *Printer) Error(s string) {
go print(p.name, s, logging.LogErrorf)
}
// print logs the message line by line with the plugin name as prefix, using the provided log function.
func print(name, s string, logf func(format string, v ...any)) {
rows := strings.SplitSeq(s, "\n")
for row := range rows {
logf("[plugin:%s] %s", name, row)
}
}
// injectLogger adds siyuan.logger to the goja context.
func injectLogger(p *KernelPlugin, rt *goja.Runtime, siyuan *goja.Object) (err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("injectLogger: %v", r)
}
}()
logger := rt.NewObject()
lo.Must0(logger.Set("trace", rt.ToValue(loggerWrapper(p, logging.LogTracef))))
lo.Must0(logger.Set("debug", rt.ToValue(loggerWrapper(p, logging.LogDebugf))))
lo.Must0(logger.Set("info", rt.ToValue(loggerWrapper(p, logging.LogInfof))))
lo.Must0(logger.Set("warn", rt.ToValue(loggerWrapper(p, logging.LogWarnf))))
lo.Must0(logger.Set("error", rt.ToValue(loggerWrapper(p, logging.LogErrorf))))
lo.Must0(ObjectFreeze(rt, logger))
lo.Must0(siyuan.Set("logger", logger))
return
}
// loggerWrapper returns a JS-callable function that logs a message at the given level.View on GitHub (pinned to 9f775e8a12)