Skip to content

Commit

Permalink
command: Fix logger not initializing properly in envoy command (#16148)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyhavlov committed Feb 8, 2023
1 parent 166fdd1 commit d20bacb
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions command/connect/envoy/envoy.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,6 @@ func (c *cmd) init() {
flags.Merge(c.flags, c.http.ClientFlags())
flags.Merge(c.flags, c.http.MultiTenancyFlags())
c.help = flags.Usage(help, c.flags)

opts := hclog.LoggerOptions{Level: hclog.Off}
if c.enableLogging {
opts.Level = hclog.Debug
}
c.logger = hclog.New(&opts)
}

// canBindInternal is here mainly so we can unit test this with a constant net.Addr list
Expand Down Expand Up @@ -278,13 +272,18 @@ func (c *cmd) Run(args []string) int {
c.UI.Error(fmt.Sprintf("Error connecting to Consul agent: %s", err))
return 1
}
c.logger.Debug("Initialized API client")

// TODO: refactor
return c.run(c.flags.Args())
}

func (c *cmd) run(args []string) int {
opts := hclog.LoggerOptions{Level: hclog.Off}
if c.enableLogging {
opts.Level = hclog.Debug
}
c.logger = hclog.New(&opts)
c.logger.Debug("Starting Envoy config generation")

if c.nodeName != "" && c.proxyID == "" {
c.UI.Error("'-node-name' requires '-proxy-id'")
Expand Down

0 comments on commit d20bacb

Please sign in to comment.