|
4 | 4 | package views |
5 | 5 |
|
6 | 6 | import ( |
7 | | - "encoding/json" |
8 | 7 | "fmt" |
9 | 8 | "strings" |
10 | | - "time" |
11 | 9 |
|
12 | | - "github.com/hashicorp/go-hclog" |
13 | 10 | "github.com/hashicorp/terraform/internal/command/arguments" |
14 | 11 | "github.com/hashicorp/terraform/internal/tfdiags" |
15 | 12 | ) |
@@ -98,18 +95,21 @@ func (v *InitJSON) Output(messageCode InitMessageCode, params ...any) { |
98 | 95 | return |
99 | 96 | } |
100 | 97 |
|
101 | | - current_timestamp := time.Now().UTC().Format(hclog.TimeFormat) |
102 | | - json_data := map[string]string{ |
103 | | - "@level": "info", |
104 | | - "@message": preppedMessage, |
105 | | - "@module": "terraform.ui", |
106 | | - "@timestamp": current_timestamp, |
107 | | - "type": "init_output", |
108 | | - "message_code": string(messageCode), |
109 | | - } |
110 | | - |
111 | | - init_output, _ := json.Marshal(json_data) |
112 | | - v.view.view.streams.Println(string(init_output)) |
| 98 | + // Logged data includes by default: |
| 99 | + // @level as "info" |
| 100 | + // @module as "terraform.ui" (See NewJSONView) |
| 101 | + // @timestamp formatted in the default way |
| 102 | + // |
| 103 | + // In the method below we: |
| 104 | + // * Set @message as the first argument value |
| 105 | + // * Annotate with extra data: |
| 106 | + // "type":"init_output" |
| 107 | + // "message_code":"<value>" |
| 108 | + v.view.log.Info( |
| 109 | + preppedMessage, |
| 110 | + "type", "init_output", |
| 111 | + "message_code", string(messageCode), |
| 112 | + ) |
113 | 113 | } |
114 | 114 |
|
115 | 115 | func (v *InitJSON) LogInitMessage(messageCode InitMessageCode, params ...any) { |
|
0 commit comments