allow to customize the log level

The old log-verbose flag is not appropriate anymore.
You should now use the log-level flag to set your preferred log level.
The default level is "debug" as before, you can also set "info", "warn",
"error"

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2022-07-13 10:40:24 +02:00
parent 8fc4971df1
commit e0ce2e2e8a
16 changed files with 95 additions and 57 deletions

View File

@@ -104,7 +104,7 @@ type Manager struct {
}
// Initialize initializes the configured plugins
func Initialize(configs []Config, logVerbose bool) error {
func Initialize(configs []Config, logLevel string) error {
logger.Debug(logSender, "", "initialize")
Handler = Manager{
Configs: configs,
@@ -112,7 +112,7 @@ func Initialize(configs []Config, logVerbose bool) error {
closed: 0,
authScopes: -1,
}
setLogLevel(logVerbose)
setLogLevel(logLevel)
if len(configs) == 0 {
return nil
}
@@ -733,11 +733,16 @@ func (m *Manager) Cleanup() {
}
}
func setLogLevel(logVerbose bool) {
if logVerbose {
pluginsLogLevel = hclog.Debug
} else {
func setLogLevel(logLevel string) {
switch logLevel {
case "info":
pluginsLogLevel = hclog.Info
case "warn":
pluginsLogLevel = hclog.Warn
case "error":
pluginsLogLevel = hclog.Error
default:
pluginsLogLevel = hclog.Debug
}
}