From bad9e1fb5ead14bc18cff81cf5f9cd9a260188cd Mon Sep 17 00:00:00 2001 From: Deluan Date: Sun, 28 Dec 2025 12:50:04 -0500 Subject: [PATCH] refactor(plugins): enhance debug logging for plugin actions and recompile logic Signed-off-by: Deluan --- plugins/manager.go | 6 ++++-- plugins/watcher.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/manager.go b/plugins/manager.go index f04ea4fe4..0b0f0f486 100644 --- a/plugins/manager.go +++ b/plugins/manager.go @@ -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) diff --git a/plugins/watcher.go b/plugins/watcher.go index c8f2fa9dd..58eb673b3 100644 --- a/plugins/watcher.go +++ b/plugins/watcher.go @@ -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)