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:
Jeff Mitchell authored and GitHub committed 2022-03-16 17:25:34 -04:00
1 parent 7eb29261b2
commit e596daf34d
17 files changed
+879 -53

No files matched your search

+27
View File
@@ -4,6 +4,7 @@ import (
"net/url"
"time"
"github.com/hashicorp/go-hclog"
wrapping "github.com/hashicorp/go-kms-wrapping/v2"
)
@@ -42,6 +43,11 @@ type options struct {
withSchema *url.URL
withAuditWrapper wrapping.Wrapper
withFilterOperations AuditFilterOperations
withGating bool
withNoGateLocking bool
// These options are related to the hclog adapter
withHclogLevel hclog.Level
withBroker broker // test only option
withAuditSink bool // test only option
@@ -196,3 +202,24 @@ func WithFilterOperations(fop AuditFilterOperations) Option {
o.withFilterOperations = fop
}
}
// WithHclogLevel is an option to specify a log level if using the adapter
func WithHclogLevel(with hclog.Level) Option {
return func(o *options) {
o.withHclogLevel = with
}
}
// WithGating starts the eventer in gated mode
func WithGating(with bool) Option {
return func(o *options) {
o.withGating = with
}
}
// WithNoGateLocking is used when trawling through the existing queue to ensure we don't deadlock
func WithNoGateLocking(with bool) Option {
return func(o *options) {
o.withNoGateLocking = with
}
}