forked from hashicorp/terraform-provider-azurerm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger_diagnostics.go
40 lines (32 loc) · 897 Bytes
/
logger_diagnostics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package sdk
import (
"fmt"
"log"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
)
var _ Logger = &DiagnosticsLogger{}
type DiagnosticsLogger struct {
diagnostics diag.Diagnostics
}
func (d *DiagnosticsLogger) Info(message string) {
log.Printf("[INFO] %s", message)
}
func (d *DiagnosticsLogger) Infof(format string, args ...interface{}) {
log.Printf("[INFO] "+format, args...)
}
func (d *DiagnosticsLogger) Warn(message string) {
d.diagnostics = append(d.diagnostics, diag.Diagnostic{
Severity: diag.Warning,
Summary: message,
Detail: message,
AttributePath: nil,
})
}
func (d *DiagnosticsLogger) Warnf(format string, args ...interface{}) {
d.diagnostics = append(d.diagnostics, diag.Diagnostic{
Severity: diag.Warning,
Summary: fmt.Sprintf(format, args...),
Detail: fmt.Sprintf(format, args...),
AttributePath: nil,
})
}