Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add plugin log level #140

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/plugin/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (e *ExportPluginSystem) Load(ctx context.Context) error {
Logger: hclog.New(&hclog.LoggerOptions{
Name: "exporter",
Output: os.Stdout,
Level: hclog.Debug,
Level: getLogLevel(),
JSONFormat: true,
}),
})
Expand Down
23 changes: 23 additions & 0 deletions pkg/plugin/log.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package plugin

import (
"github.com/hashicorp/go-hclog"
"github.com/re-cinq/aether/pkg/config"
)

// getLogLevel is a helper function to get the log level from the config
func getLogLevel() hclog.Level {
level := config.AppConfig().LogLevel
switch level {
case "debug":
return hclog.Debug
case "info":
return hclog.Info
case "warn":
return hclog.Warn
case "error":
return hclog.Error
default:
return hclog.Info
}
}
2 changes: 1 addition & 1 deletion pkg/plugin/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (s *SourcePluginSystem) Load(ctx context.Context) error {
Logger: hclog.New(&hclog.LoggerOptions{
Name: "source",
Output: os.Stdout,
Level: hclog.Debug,
Level: getLogLevel(),
JSONFormat: true,
}),
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/source/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (m *Manager) Fetch(ctx context.Context) {
wg.Done()
return
}

logger.Debug("publishing instances", "instance count", len(instances))
err = m.publishInstances(instances)
if err != nil {
logger.Error("failed publishing instances", "error", err)
Expand Down
Loading