diff --git a/internal/command/views/init.go b/internal/command/views/init.go index ab16c436b14c..d16c74afb734 100644 --- a/internal/command/views/init.go +++ b/internal/command/views/init.go @@ -4,10 +4,8 @@ package views import ( - "encoding/json" "fmt" "strings" - "time" "github.com/hashicorp/terraform/internal/command/arguments" "github.com/hashicorp/terraform/internal/tfdiags" @@ -97,18 +95,21 @@ func (v *InitJSON) Output(messageCode InitMessageCode, params ...any) { return } - current_timestamp := time.Now().UTC().Format(time.RFC3339) - json_data := map[string]string{ - "@level": "info", - "@message": preppedMessage, - "@module": "terraform.ui", - "@timestamp": current_timestamp, - "type": "init_output", - "message_code": string(messageCode), - } - - init_output, _ := json.Marshal(json_data) - v.view.view.streams.Println(string(init_output)) + // Logged data includes by default: + // @level as "info" + // @module as "terraform.ui" (See NewJSONView) + // @timestamp formatted in the default way + // + // In the method below we: + // * Set @message as the first argument value + // * Annotate with extra data: + // "type":"init_output" + // "message_code":"" + v.view.log.Info( + preppedMessage, + "type", "init_output", + "message_code", string(messageCode), + ) } func (v *InitJSON) LogInitMessage(messageCode InitMessageCode, params ...any) {