fix(agent): pass quiet flag earlier (#13020)
This commit is contained in:
parent
74134a0de6
commit
c84940b388
|
|
@ -211,6 +211,7 @@ func (t *Telegraf) watchLocalConfig(signals chan os.Signal, fConfig string) {
|
||||||
func (t *Telegraf) loadConfiguration() (*config.Config, error) {
|
func (t *Telegraf) loadConfiguration() (*config.Config, error) {
|
||||||
// If no other options are specified, load the config file and run.
|
// If no other options are specified, load the config file and run.
|
||||||
c := config.NewConfig()
|
c := config.NewConfig()
|
||||||
|
c.Agent.Quiet = t.quiet
|
||||||
c.OutputFilters = t.outputFilters
|
c.OutputFilters = t.outputFilters
|
||||||
c.InputFilters = t.inputFilters
|
c.InputFilters = t.inputFilters
|
||||||
c.SecretStoreFilters = t.secretstoreFilters
|
c.SecretStoreFilters = t.secretstoreFilters
|
||||||
|
|
|
||||||
|
|
@ -443,6 +443,10 @@ func (c *Config) LoadConfig(path string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, path := range paths {
|
for _, path := range paths {
|
||||||
|
if !c.Agent.Quiet {
|
||||||
|
log.Printf("I! Loading config: %s", path)
|
||||||
|
}
|
||||||
|
|
||||||
data, err := LoadConfigFile(path)
|
data, err := LoadConfigFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error loading config file %s: %w", path, err)
|
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) {
|
func LoadConfigFile(config string) ([]byte, error) {
|
||||||
if fetchURLRe.MatchString(config) {
|
if fetchURLRe.MatchString(config) {
|
||||||
log.Printf("I! Loading config url: %s", config)
|
|
||||||
u, err := url.Parse(config)
|
u, err := url.Parse(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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
|
// 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)
|
buffer, err := os.ReadFile(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue