From e772cf4217ead58a364782da67c43deed4a64311 Mon Sep 17 00:00:00 2001 From: Cosmin Tupangiu Date: Thu, 5 Dec 2024 16:54:55 +0100 Subject: [PATCH] agent: Fix init logging 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 --- cmd/planner-agent/main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/planner-agent/main.go b/cmd/planner-agent/main.go index e0fa104..b84393d 100644 --- a/cmd/planner-agent/main.go +++ b/cmd/planner-agent/main.go @@ -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) @@ -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)