diff --git a/plugin/storage/grpc/config/config.go b/plugin/storage/grpc/config/config.go index e8890d360a5..67aaca57ddc 100644 --- a/plugin/storage/grpc/config/config.go +++ b/plugin/storage/grpc/config/config.go @@ -29,6 +29,7 @@ import ( type Configuration struct { PluginBinary string `yaml:"binary"` PluginConfigurationFile string `yaml:"configuration-file"` + PluginLogLevel string `yaml:"log-level"` } // Build instantiates a StoragePlugin @@ -44,7 +45,7 @@ func (c *Configuration) Build() (shared.StoragePlugin, error) { Cmd: cmd, AllowedProtocols: []plugin.Protocol{plugin.ProtocolGRPC}, Logger: hclog.New(&hclog.LoggerOptions{ - Level: hclog.Warn, + Level: hclog.LevelFromString(c.PluginLogLevel), }), }) diff --git a/plugin/storage/grpc/factory_test.go b/plugin/storage/grpc/factory_test.go index 67a2607290f..e846380f82b 100644 --- a/plugin/storage/grpc/factory_test.go +++ b/plugin/storage/grpc/factory_test.go @@ -103,8 +103,10 @@ func TestWithConfiguration(t *testing.T) { command.ParseFlags([]string{ "--grpc-storage-plugin.binary=noop-grpc-plugin", "--grpc-storage-plugin.configuration-file=config.json", + "--grpc-storage-plugin.log-level=debug", }) f.InitFromViper(v) assert.Equal(t, f.options.Configuration.PluginBinary, "noop-grpc-plugin") assert.Equal(t, f.options.Configuration.PluginConfigurationFile, "config.json") + assert.Equal(t, f.options.Configuration.PluginLogLevel, "debug") } diff --git a/plugin/storage/grpc/options.go b/plugin/storage/grpc/options.go index 82cac8d9311..b2c0f17667f 100644 --- a/plugin/storage/grpc/options.go +++ b/plugin/storage/grpc/options.go @@ -22,8 +22,12 @@ import ( "github.com/jaegertracing/jaeger/plugin/storage/grpc/config" ) -const pluginBinary = "grpc-storage-plugin.binary" -const pluginConfigurationFile = "grpc-storage-plugin.configuration-file" +const ( + pluginBinary = "grpc-storage-plugin.binary" + pluginConfigurationFile = "grpc-storage-plugin.configuration-file" + pluginLogLevel = "grpc-storage-plugin.log-level" + defaultPluginLogLevel = "warn" +) // Options contains GRPC plugins configs and provides the ability // to bind them to command line flags @@ -35,10 +39,13 @@ type Options struct { func (opt *Options) AddFlags(flagSet *flag.FlagSet) { flagSet.String(pluginBinary, "", "The location of the plugin binary") flagSet.String(pluginConfigurationFile, "", "A path pointing to the plugin's configuration file, made available to the plugin with the --config arg") + flagSet.String(pluginLogLevel, defaultPluginLogLevel, "Set the log level of the plugin's logger") } // InitFromViper initializes Options with properties from viper func (opt *Options) InitFromViper(v *viper.Viper) { opt.Configuration.PluginBinary = v.GetString(pluginBinary) opt.Configuration.PluginConfigurationFile = v.GetString(pluginConfigurationFile) + opt.Configuration.PluginLogLevel = v.GetString(pluginLogLevel) + } diff --git a/plugin/storage/grpc/options_test.go b/plugin/storage/grpc/options_test.go index 510a1033e93..be0e3611b67 100644 --- a/plugin/storage/grpc/options_test.go +++ b/plugin/storage/grpc/options_test.go @@ -28,9 +28,11 @@ func TestOptionsWithFlags(t *testing.T) { command.ParseFlags([]string{ "--grpc-storage-plugin.binary=noop-grpc-plugin", "--grpc-storage-plugin.configuration-file=config.json", + "--grpc-storage-plugin.log-level=debug", }) opts.InitFromViper(v) assert.Equal(t, opts.Configuration.PluginBinary, "noop-grpc-plugin") assert.Equal(t, opts.Configuration.PluginConfigurationFile, "config.json") + assert.Equal(t, opts.Configuration.PluginLogLevel, "debug") }