-
Notifications
You must be signed in to change notification settings - Fork 10
Set IG logger level based on global log level #715
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ import ( | |
|
|
||
| igconfig "github.com/inspektor-gadget/inspektor-gadget/pkg/config" | ||
| containercollection "github.com/inspektor-gadget/inspektor-gadget/pkg/container-collection" | ||
| iglogger "github.com/inspektor-gadget/inspektor-gadget/pkg/logger" | ||
| beUtils "github.com/kubescape/backend/pkg/utils" | ||
| "github.com/kubescape/go-logger" | ||
| "github.com/kubescape/go-logger/helpers" | ||
|
|
@@ -162,10 +163,10 @@ func main() { | |
| // Create clients | ||
| logger.L().Info("Kubernetes mode is true") | ||
| k8sClient := k8sinterface.NewKubernetesApi() | ||
|
|
||
| // Fetch cluster UID from kube-system namespace | ||
| clusterUID := utils.GetClusterUID(k8sClient.GetKubernetesClient()) | ||
|
|
||
| storageClient, err := storage.CreateStorage(clusterData.Namespace) | ||
| if err != nil { | ||
| logger.L().Ctx(ctx).Fatal("error creating the storage client", helpers.Error(err)) | ||
|
|
@@ -365,6 +366,11 @@ func main() { | |
| if err := igconfig.Config.ReadInConfig(); err != nil { | ||
| logger.L().Warning("reading IG config", helpers.Error(err)) | ||
| } | ||
| if logger.L().GetLevel() == "debug" { | ||
| iglogger.DefaultLogger().SetLevel(iglogger.DebugLevel) | ||
| } else { | ||
| iglogger.DefaultLogger().SetLevel(iglogger.ErrorLevel) | ||
matthyx marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
Comment on lines
+369
to
+373
|
||
| igK8sClient, err := containercollection.NewK8sClient(cfg.NodeName, "", "") | ||
| if err != nil { | ||
| logger.L().Fatal("error creating IG Kubernetes client", helpers.Error(err)) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import block is no longer gofmt-sorted after adding iglogger (the inspektor-gadget imports should be ordered lexicographically). Please run gofmt or reorder imports to avoid inconsistent formatting across the repo.