fix(agent): pass quiet flag earlier (#13020)

This commit is contained in:
Joshua Powers 2023-04-04 06:57:02 -06:00 committed by GitHub
parent 74134a0de6
commit c84940b388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -211,6 +211,7 @@ func (t *Telegraf) watchLocalConfig(signals chan os.Signal, fConfig string) {
func (t *Telegraf) loadConfiguration() (*config.Config, error) {
// If no other options are specified, load the config file and run.
c := config.NewConfig()
c.Agent.Quiet = t.quiet
c.OutputFilters = t.outputFilters
c.InputFilters = t.inputFilters
c.SecretStoreFilters = t.secretstoreFilters

View File

@ -443,6 +443,10 @@ func (c *Config) LoadConfig(path string) error {
}
for _, path := range paths {
if !c.Agent.Quiet {
log.Printf("I! Loading config: %s", path)
}
data, err := LoadConfigFile(path)
if err != nil {
return fmt.Errorf("error loading config file %s: %w", path, err)
@ -700,7 +704,6 @@ func escapeEnv(value string) string {
func LoadConfigFile(config string) ([]byte, error) {
if fetchURLRe.MatchString(config) {
log.Printf("I! Loading config url: %s", config)
u, err := url.Parse(config)
if err != nil {
return nil, err
@ -715,7 +718,6 @@ func LoadConfigFile(config string) ([]byte, error) {
}
// If it isn't a https scheme, try it as a file
log.Printf("I! Loading config file: %s", config)
buffer, err := os.ReadFile(config)
if err != nil {
return nil, err