Skip to content

Commit

Permalink
agent: Fix init logging
Browse files Browse the repository at this point in the history
Fix bug when logger was initialized in the wrong place.
This commit puts the init phase in the _Execute_ method of the run
command.

Signed-off-by: Cosmin Tupangiu <[email protected]>
  • Loading branch information
tupyy committed Dec 5, 2024
1 parent 3d33aa9 commit e772cf4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cmd/planner-agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ func NewAgentCommand() *agentCmd {
zap.S().Fatalf("Error validating config: %v", err)
}

return a
}

func (a *agentCmd) Execute() error {
logLvl, err := zap.ParseAtomicLevel(a.config.LogLevel)
if err != nil {
logLvl = zap.NewAtomicLevelAt(zapcore.InfoLevel)
Expand All @@ -65,10 +69,6 @@ func NewAgentCommand() *agentCmd {
undo := zap.ReplaceGlobals(logger)
defer undo()

return a
}

func (a *agentCmd) Execute() error {
agentID, err := a.getAgentID()
if err != nil {
zap.S().Fatalf("failed to retreive agent_id: %v", err)
Expand Down

0 comments on commit e772cf4

Please sign in to comment.