refactor(plugins): enhance debug logging for plugin actions and recompile logic

Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Deluan 2025-12-28 12:50:04 -05:00
parent 6321dc1622
commit bad9e1fb5e
2 changed files with 5 additions and 3 deletions

View File

@ -352,7 +352,7 @@ func (m *Manager) updatePluginInDB(ctx context.Context, repo model.PluginReposit
wasEnabled := dbPlugin.Enabled
if wasEnabled {
if err := m.UnloadPlugin(dbPlugin.ID); err != nil {
log.Debug(ctx, "Plugin not loaded during change", "plugin", dbPlugin.ID)
log.Debug(ctx, "Plugin not loaded during change", "plugin", dbPlugin.ID, err)
}
}
dbPlugin.Path = path
@ -373,7 +373,7 @@ func (m *Manager) updatePluginInDB(ctx context.Context, repo model.PluginReposit
func (m *Manager) removePluginFromDB(ctx context.Context, repo model.PluginRepository, dbPlugin *model.Plugin) error {
if dbPlugin.Enabled {
if err := m.UnloadPlugin(dbPlugin.ID); err != nil {
log.Debug(ctx, "Plugin not loaded during removal", "plugin", dbPlugin.ID)
log.Debug(ctx, "Plugin not loaded during removal", "plugin", dbPlugin.ID, err)
}
}
if err := repo.Delete(dbPlugin.ID); err != nil {
@ -838,6 +838,8 @@ func (m *Manager) loadPluginWithConfig(name, wasmPath, configJSON string) error
compiled := info.compiled
needsRecompile := len(pluginManifest.AllowedHosts) > 0 || len(hostFunctions) > 0
// Recompile if needed. It is actually not a "recompile" since the first compilation
// should be cached by wazero. We just need to do it this way to provide the real host functions.
if needsRecompile {
log.Trace(m.ctx, "Recompiling plugin with host functions", "plugin", name)
info.compiled.Close(m.ctx)

View File

@ -144,7 +144,7 @@ func (m *Manager) processPluginEvent(pluginName string, eventType notify.Event)
m.debounceMu.Unlock()
action := determinePluginAction(eventType)
log.Debug(m.ctx, "Plugin event action (DB mode)", "plugin", pluginName, "action", action)
log.Debug(m.ctx, "Plugin event action", "plugin", pluginName, "action", action)
ctx := adminContext(m.ctx)
repo := m.ds.Plugin(ctx)