Skip to content

Commit 95e6146

Browse files
committed
chore: Add logging function to ClusterResource
1 parent bc7e50b commit 95e6146

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

terraform-provider-constellation/internal/provider/cluster_resource.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,3 +1401,24 @@ type nopSpinner struct{ io.Writer }
14011401
func (s *nopSpinner) Start(string, bool) {}
14021402
func (s *nopSpinner) Stop() {}
14031403
func (s *nopSpinner) Write([]byte) (n int, err error) { return 1, nil }
1404+
1405+
func (r *ClusterResource) logWithContext(ctx context.Context, level string, msg string, additionalFields ...map[string]interface{}) {
1406+
fields := map[string]interface{}{
1407+
"resource": "ClusterResource",
1408+
}
1409+
for _, af := range additionalFields {
1410+
for k, v := range af {
1411+
fields[k] = v
1412+
}
1413+
}
1414+
switch level {
1415+
case "DEBUG":
1416+
tflog.Debug(ctx, msg, fields)
1417+
case "INFO":
1418+
tflog.Info(ctx, msg, fields)
1419+
case "WARN":
1420+
tflog.Warn(ctx, msg, fields)
1421+
case "ERROR":
1422+
tflog.Error(ctx, msg, fields)
1423+
}
1424+
}

0 commit comments

Comments
 (0)