|
4 | 4 | package views |
5 | 5 |
|
6 | 6 | import ( |
| 7 | + "encoding/json" |
7 | 8 | "fmt" |
8 | 9 | "strings" |
| 10 | + "time" |
9 | 11 |
|
10 | 12 | "github.com/hashicorp/terraform/internal/command/arguments" |
11 | 13 | "github.com/hashicorp/terraform/internal/tfdiags" |
@@ -95,21 +97,18 @@ func (v *InitJSON) Output(messageCode InitMessageCode, params ...any) { |
95 | 97 | return |
96 | 98 | } |
97 | 99 |
|
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 | | - ) |
| 100 | + current_timestamp := time.Now().UTC().Format(hclog.TimeFormat) |
| 101 | + json_data := map[string]string{ |
| 102 | + "@level": "info", |
| 103 | + "@message": preppedMessage, |
| 104 | + "@module": "terraform.ui", |
| 105 | + "@timestamp": current_timestamp, |
| 106 | + "type": "init_output", |
| 107 | + "message_code": string(messageCode), |
| 108 | + } |
| 109 | + |
| 110 | + init_output, _ := json.Marshal(json_data) |
| 111 | + v.view.view.streams.Println(string(init_output)) |
113 | 112 | } |
114 | 113 |
|
115 | 114 | func (v *InitJSON) LogInitMessage(messageCode InitMessageCode, params ...any) { |
|
0 commit comments