Skip to content

Commit

Permalink
Remove log line from support archive zip. (#3346)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukas Hinterreiter <[email protected]>
  • Loading branch information
StefanHauth and luhi-DT authored Jun 24, 2024
1 parent 0d48847 commit e2edd4f
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cmd/csi/init/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/Dynatrace/dynatrace-operator/cmd/config"
dtcsi "github.com/Dynatrace/dynatrace-operator/pkg/controllers/csi"
"github.com/Dynatrace/dynatrace-operator/pkg/controllers/csi/metadata"
"github.com/Dynatrace/dynatrace-operator/pkg/logd"
"github.com/Dynatrace/dynatrace-operator/pkg/version"
"github.com/pkg/errors"
"github.com/spf13/afero"
Expand Down Expand Up @@ -51,6 +52,7 @@ func (builder CommandBuilder) buildRun() func(*cobra.Command, []string) error {
return func(cmd *cobra.Command, args []string) error {
unix.Umask(dtcsi.UnixUmask)
version.LogVersion()
logd.LogBaseLoggerSettings()

kubeConfig, err := builder.configProvider.GetConfig()
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions cmd/csi/provisioner/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
dtcsi "github.com/Dynatrace/dynatrace-operator/pkg/controllers/csi"
"github.com/Dynatrace/dynatrace-operator/pkg/controllers/csi/metadata"
csiprovisioner "github.com/Dynatrace/dynatrace-operator/pkg/controllers/csi/provisioner"
"github.com/Dynatrace/dynatrace-operator/pkg/logd"
"github.com/Dynatrace/dynatrace-operator/pkg/util/dtotel"
"github.com/Dynatrace/dynatrace-operator/pkg/version"
"github.com/pkg/errors"
Expand Down Expand Up @@ -106,6 +107,7 @@ func (builder CommandBuilder) buildRun() func(*cobra.Command, []string) error {
return func(cmd *cobra.Command, args []string) error {
unix.Umask(dtcsi.UnixUmask)
version.LogVersion()
logd.LogBaseLoggerSettings()

kubeConfig, err := builder.configProvider.GetConfig()
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions cmd/csi/server/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
dtcsi "github.com/Dynatrace/dynatrace-operator/pkg/controllers/csi"
csidriver "github.com/Dynatrace/dynatrace-operator/pkg/controllers/csi/driver"
"github.com/Dynatrace/dynatrace-operator/pkg/controllers/csi/metadata"
"github.com/Dynatrace/dynatrace-operator/pkg/logd"
"github.com/Dynatrace/dynatrace-operator/pkg/util/dtotel"
"github.com/Dynatrace/dynatrace-operator/pkg/version"
"github.com/pkg/errors"
Expand Down Expand Up @@ -110,6 +111,7 @@ func (builder CommandBuilder) buildRun() func(*cobra.Command, []string) error {
return func(cmd *cobra.Command, args []string) error {
unix.Umask(dtcsi.UnixUmask)
version.LogVersion()
logd.LogBaseLoggerSettings()

kubeConfig, err := builder.configProvider.GetConfig()
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions cmd/operator/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/Dynatrace/dynatrace-operator/cmd/config"
cmdManager "github.com/Dynatrace/dynatrace-operator/cmd/manager"
"github.com/Dynatrace/dynatrace-operator/pkg/controllers/certificates"
"github.com/Dynatrace/dynatrace-operator/pkg/logd"
"github.com/Dynatrace/dynatrace-operator/pkg/util/dtotel"
"github.com/Dynatrace/dynatrace-operator/pkg/util/kubeobjects/pod"
"github.com/Dynatrace/dynatrace-operator/pkg/util/kubesystem"
Expand Down Expand Up @@ -125,6 +126,7 @@ func (builder CommandBuilder) setClientFromConfig(kubeCfg *rest.Config) (Command
func (builder CommandBuilder) buildRun() func(cmd *cobra.Command, args []string) error {
return func(cmd *cobra.Command, args []string) error {
version.LogVersion()
logd.LogBaseLoggerSettings()

kubeCfg, err := builder.configProvider.GetConfig()
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions cmd/troubleshoot/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func clusterOptions(opts *cluster.Options) {
func (builder CommandBuilder) buildRun() func(*cobra.Command, []string) error {
return func(cmd *cobra.Command, args []string) error {
version.LogVersion()
logd.LogBaseLoggerSettings()

kubeConfig, err := builder.configProvider.GetConfig()
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions cmd/webhook/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
cmdManager "github.com/Dynatrace/dynatrace-operator/cmd/manager"
dynatracev1beta1 "github.com/Dynatrace/dynatrace-operator/pkg/api/v1beta1/dynakube"
dynatracev1beta2 "github.com/Dynatrace/dynatrace-operator/pkg/api/v1beta2/dynakube"
"github.com/Dynatrace/dynatrace-operator/pkg/logd"
"github.com/Dynatrace/dynatrace-operator/pkg/util/dtotel"
"github.com/Dynatrace/dynatrace-operator/pkg/util/kubeobjects/pod"
"github.com/Dynatrace/dynatrace-operator/pkg/util/kubesystem"
Expand Down Expand Up @@ -119,6 +120,7 @@ func startCertificateWatcher(webhookManager manager.Manager, namespace string, p
func (builder CommandBuilder) buildRun() func(*cobra.Command, []string) error {
return func(cmd *cobra.Command, args []string) error {
version.LogVersion()
logd.LogBaseLoggerSettings()

kubeConfig, err := builder.configProvider.GetConfig()
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion pkg/logd/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ func Get() Logger {
baseLoggerOnce.Do(func() {
logLevel := readLogLevelFromEnv()
baseLogger = createLogger(NewPrettyLogWriter(), logLevel)
baseLogger.Info("logging level", "logLevel", logLevel.String())
})

return baseLogger
}

func LogBaseLoggerSettings() {
logLevel := readLogLevelFromEnv()
baseLogger.Info("logging level", "logLevel", logLevel.String())
}

func createLogger(out io.Writer, logLevel zapcore.Level) Logger {
// It's important to create only one "main" logd to avoid excessive memory usage, creating a full logd is rather expensive,
// deriving other loggers by WithName is rather cheap
Expand Down

0 comments on commit e2edd4f

Please sign in to comment.