Skip to content

Commit

Permalink
fix: Remove PluginConfig.LogLevel and set default log level to Off
Browse files Browse the repository at this point in the history
  • Loading branch information
mhmd-azeez committed Sep 26, 2024
1 parent 1aa7887 commit 2ce0533
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions extism.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ type PluginConfig struct {
ModuleConfig wazero.ModuleConfig
RuntimeConfig wazero.RuntimeConfig
EnableWasi bool
LogLevel LogLevel
ObserveAdapter *observe.AdapterBase
ObserveOptions *observe.Options
}
Expand Down Expand Up @@ -147,11 +146,16 @@ func (p *Plugin) SetLogger(logger func(LogLevel, string)) {
}

func (p *Plugin) Log(level LogLevel, message string) {
if level < LogLevel(pluginLogLevel.Load()) {
return
minimumLevel := LogLevel(pluginLogLevel.Load())

// If the global log level hasn't been set, use LogLevelOff as default
if minimumLevel == logLevelUnset {
minimumLevel = LogLevelOff
}

p.log(level, message)
if level >= minimumLevel {
p.log(level, message)
}
}

func (p *Plugin) Logf(level LogLevel, format string, args ...any) {
Expand Down Expand Up @@ -351,7 +355,7 @@ var pluginLogLevel = atomic.Int32{}

// SetPluginLogLevel sets the log level for the plugin
func SetLogLevel(level LogLevel) {
pluginLogLevel.Store(int32(level.ExtismCompat()))
pluginLogLevel.Store(int32(level))
}

// NewPlugin creates a new Extism plugin with the given manifest, configuration, and host functions.
Expand Down

0 comments on commit 2ce0533

Please sign in to comment.