Add hclog adapter and gating to eventer (#1915)
This contains to related things: 1. An adapter allowing an hclog interface to take in information and send them to the eventer 2. A gate on the eventer, which is the analogue to the behavior prior to eventing where we'd ensure logs were not printed prior to the startup information. Without this, plugin logs using the hclog adapter will start showing up too early.
This commit is contained in:
1 parent
7eb29261b2
commit
e596daf34d
17 files changed
+879
-53
No files matched your search
@@ -125,7 +125,14 @@ func New(ctx context.Context, conf *Config) (*Controller, error) {
|
||||
}
|
||||
}
|
||||
|
||||
var pluginLogger hclog.Logger
|
||||
for _, enabledPlugin := range c.enabledPlugins {
|
||||
if pluginLogger == nil {
|
||||
pluginLogger, err = event.NewHclogLogger(ctx, c.conf.Server.Eventer)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error creating host catalog plugin logger: %w", err)
|
||||
}
|
||||
}
|
||||
switch enabledPlugin {
|
||||
case base.EnabledPluginHostLoopback:
|
||||
plg := pluginhost.NewWrappingPluginClient(pluginhost.NewLoopbackPlugin())
|
||||
@@ -145,6 +152,7 @@ func New(ctx context.Context, conf *Config) (*Controller, error) {
|
||||
pluginutil.WithPluginExecutionDirectory(conf.RawConfig.Plugins.ExecutionDir),
|
||||
pluginutil.WithPluginsFilesystem(host_plugin_assets.HostPluginPrefix, host_plugin_assets.FileSystem()),
|
||||
),
|
||||
external_host_plugins.WithLogger(pluginLogger.Named(pluginType)),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error creating %s host plugin: %w", pluginType, err)
|
||||
|
||||
Reference in new issue
Block a user