Skip to content

Commit

Permalink
fix: add plugin log level
Browse files Browse the repository at this point in the history
This will set the plugin log level to the same level that is configured
for aether

Signed-off-by: Spazzy <brendankamp757@gmail.com>
  • Loading branch information
Spazzy757 committed May 29, 2024
1 parent eb498b7 commit f6a5dcc
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
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

0 comments on commit f6a5dcc

Please sign in to comment.