Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
belimawr committed Jan 25, 2024
1 parent 118982c commit 4be50d6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -318,4 +318,4 @@ replace (
// Exclude this version because the version has an invalid checksum.
exclude github.com/docker/distribution v2.8.0+incompatible

replace github.com/elastic/elastic-agent-libs => github.com/belimawr/elastic-agent-libs v0.2.9-0.20240125141844-ffbc66f6350b
replace github.com/elastic/elastic-agent-libs => github.com/belimawr/elastic-agent-libs v0.2.9-0.20240125162154-3b1dfe492873
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,8 @@ github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:W
github.com/aws/aws-sdk-go v1.15.11/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0=
github.com/aws/aws-sdk-go v1.43.16/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo=
github.com/aymerick/raymond v2.0.2+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/belimawr/elastic-agent-libs v0.2.9-0.20240125141844-ffbc66f6350b h1:GkQYbSAj4LRD/kcMYG89MN3mLTiT5M5/hFKgvSG0DwA=
github.com/belimawr/elastic-agent-libs v0.2.9-0.20240125141844-ffbc66f6350b/go.mod h1:pGMj5myawdqu+xE+WKvM5FQzKQ/MonikkWOzoFTJxaU=
github.com/belimawr/elastic-agent-libs v0.2.9-0.20240125162154-3b1dfe492873 h1:SaT/SfyaB6k77dHDUe9489z6Eu8FAqnbMmlUtWQT9sw=
github.com/belimawr/elastic-agent-libs v0.2.9-0.20240125162154-3b1dfe492873/go.mod h1:pGMj5myawdqu+xE+WKvM5FQzKQ/MonikkWOzoFTJxaU=
github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/agent/configuration/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type SettingsConfig struct {
GRPC *GRPCConfig `yaml:"grpc" config:"grpc" json:"grpc"`
MonitoringConfig *monitoringCfg.MonitoringConfig `yaml:"monitoring" config:"monitoring" json:"monitoring"`
LoggingConfig *logger.Config `yaml:"logging,omitempty" config:"logging,omitempty" json:"logging,omitempty"`
SensitiveLoggingConfig *logger.Config `yaml:"logging.sensitive,omitempty" config:"logging.sensitive,omitempty" json:"logging.sensitive,omitempty"`
SensitiveLoggingConfig *logger.Config `config:"-" yaml:"-" json:"-"`
Upgrade *UpgradeConfig `yaml:"upgrade" config:"upgrade" json:"upgrade"`

// standalone config
Expand Down
1 change: 0 additions & 1 deletion pkg/component/runtime/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,6 @@ func createLogWriter(comp component.Component, baseLog *logger.Logger, cmdSpec *
"source": comp.ID,
},
)

return newLogWriter(newLogger.Core(), cmdSpec.Log, ll, unitLevels, src)
}

Expand Down
10 changes: 7 additions & 3 deletions pkg/core/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ func NewWithLogpLevel(name string, level logp.Level, logInternal bool) (*Logger,
defaultCfg := DefaultLoggingConfig()
defaultCfg.Level = level

return new(name, defaultCfg, nil, logInternal)
sensitiveConfig := DefaultSensitiveLoggingConfig()
sensitiveConfig.Level = level

return new(name, defaultCfg, sensitiveConfig, logInternal)
}

// NewFromConfig takes the user configuration and generate the right logger.
Expand All @@ -82,7 +85,7 @@ func AddCallerSkip(l *Logger, skip int) *Logger {
return l.WithOptions(zap.AddCallerSkip(skip))
}

// New creates a new logger from the provided configurations.
// new creates a new logger from the provided configurations.
//
// If `sensitiveLoggerCfg` is not nil, a core is created from it and added to
// to the logger. If `logInternal` is true, a core logging to
Expand Down Expand Up @@ -173,7 +176,8 @@ func DefaultSensitiveLoggingConfig() *Config {
cfg.Files.MaxSize = 5 * 1024 * 1024
cfg.Files.MaxBackups = 2
cfg.Files.Permissions = 0600 // default user only
root, _ := utils.HasRoot() // error ignored
cfg.Files.RedirectStderr = false
root, _ := utils.HasRoot() // error ignored
if !root {
// when not running as root, the default changes to include the group
cfg.Files.Permissions = 0660
Expand Down

0 comments on commit 4be50d6

Please sign in to comment.